LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
Class representing one of the available options to be selected. More...
#include "MultipleChoiceSelection.h"
Public Types | |
using | Choices_t = Choices |
using | Option_t = MultipleChoiceSelectionOption_t< Choices_t > |
Public Member Functions | |
template<typename... Aliases> | |
MultipleChoiceSelectionOption_t (Choices_t value, std::string name, Aliases...aliases) | |
Constructor: assigns value, name and aliases. More... | |
template<typename... Aliases> | |
std::enable_if_t< AllConvertibleToStrings_v< Aliases... >, Option_t & > | addAlias (std::string alias, Aliases...moreAliases) |
Adds aliases. More... | |
bool | match (std::string const &label) const |
Returns whether this option matches the specified label (name or alias). More... | |
Choices_t | value () const |
Returns a copy of the value of the option. More... | |
std::string | name () const |
Returns the name of the option (i.e. the main label). More... | |
std::vector< std::string > const & | labels () const |
Returns an iterable object with all the labels of the option. More... | |
operator std::string () const | |
Returns a string representing this option. More... | |
operator Choices_t () const | |
Returns the value of this option. More... | |
std::string | value_as_string () const |
std::string | value_as_string (std::string const &defValue) const |
Returns a string represent the value of the option, or defValue . More... | |
std::string | dump () const |
Returns in a string the name and all the aliases. More... | |
bool | operator== (Option_t const &option) const |
Returns whether the two options are the same (same value and name). More... | |
bool | operator!= (Option_t const &option) const |
Returns whether the two options are not the same. More... | |
template<typename... Aliases> | |
auto | addAlias (std::string alias, Aliases...moreAliases) -> std::enable_if_t< AllConvertibleToStrings_v< Aliases... >, Option_t & > |
Static Public Member Functions | |
static std::optional< std::string > | value_as_string (Choices_t value) |
Converts a value of type Choices_t into a string, if possible. More... | |
static std::string | value_as_string (Choices_t value, std::string const &defValue) |
Converts a value of type Choices_t into a string, if possible. More... | |
Private Types | |
using | Comparer_t = CaseInsensitiveComparer |
Static Private Member Functions | |
static bool | equal (std::string const &a, std::string const &b) |
Private Attributes | |
Choices_t | fValue |
The value associated to the option. More... | |
std::vector< std::string > | fLabels |
All the labels. More... | |
Class representing one of the available options to be selected.
An option has a value (of type Choices_t
) and a name as a string. It may also have aliases. The identity of the option is defined by the value: two option objects with the same value represent the same option.
Matching a label is encoded in this class: the option matches a label if its name or any of its aliases matches the proposed label in a case-insensitive comparison.
Definition at line 72 of file MultipleChoiceSelection.h.
using util::details::MultipleChoiceSelectionOption_t< Choices >::Choices_t = Choices |
Definition at line 77 of file MultipleChoiceSelection.h.
|
private |
Definition at line 74 of file MultipleChoiceSelection.h.
using util::details::MultipleChoiceSelectionOption_t< Choices >::Option_t = MultipleChoiceSelectionOption_t<Choices_t> |
Definition at line 78 of file MultipleChoiceSelection.h.
util::details::MultipleChoiceSelectionOption_t< Choices >::MultipleChoiceSelectionOption_t | ( | Choices_t | value, |
std::string | name, | ||
Aliases... | aliases | ||
) |
Constructor: assigns value, name and aliases.
Definition at line 580 of file MultipleChoiceSelection.h.
References util::details::MultipleChoiceSelectionOption_t< Choices >::addAlias(), and util::details::MultipleChoiceSelectionOption_t< Choices >::fLabels.
std::enable_if_t<AllConvertibleToStrings_v<Aliases...>, Option_t&> util::details::MultipleChoiceSelectionOption_t< Choices >::addAlias | ( | std::string | alias, |
Aliases... | moreAliases | ||
) |
auto util::details::MultipleChoiceSelectionOption_t< Choices >::addAlias | ( | std::string | alias, |
Aliases... | moreAliases | ||
) | -> std::enable_if_t<AllConvertibleToStrings_v<Aliases...>, Option_t&> |
Definition at line 593 of file MultipleChoiceSelection.h.
References util::details::MultipleChoiceSelectionOption_t< Choices >::addAlias(), and util::details::MultipleChoiceSelectionOption_t< Choices >::fLabels.
std::string util::details::MultipleChoiceSelectionOption_t< Choices >::dump | ( | ) | const |
Returns in a string the name and all the aliases.
Definition at line 647 of file MultipleChoiceSelection.h.
References util::details::MultipleChoiceSelectionOption_t< Choices >::fLabels, and util::details::MultipleChoiceSelectionOption_t< Choices >::value_as_string().
|
inlinestaticprivate |
Definition at line 142 of file MultipleChoiceSelection.h.
Referenced by util::details::MultipleChoiceSelectionOption_t< Choices >::match().
|
inline |
Returns an iterable object with all the labels of the option.
Definition at line 100 of file MultipleChoiceSelection.h.
Referenced by util::MultipleChoiceSelection< Choices >::addOption().
bool util::details::MultipleChoiceSelectionOption_t< Choices >::match | ( | std::string const & | label | ) | const |
Returns whether this option matches the specified label (name or alias).
Definition at line 606 of file MultipleChoiceSelection.h.
References util::details::MultipleChoiceSelectionOption_t< Choices >::equal(), and util::details::MultipleChoiceSelectionOption_t< Choices >::fLabels.
Referenced by util::details::operator!=(), and util::details::operator==().
|
inline |
Returns the name of the option (i.e. the main label).
Definition at line 97 of file MultipleChoiceSelection.h.
Referenced by util::details::MultipleChoiceSelectionOption_t< Choices >::operator!=(), util::details::operator<<(), util::details::MultipleChoiceSelectionOption_t< Choices >::operator==(), and util::details::MultipleChoiceSelectionOption_t< Choices >::value_as_string().
|
inline |
Returns the value of this option.
Definition at line 106 of file MultipleChoiceSelection.h.
References value.
|
inline |
Returns a string representing this option.
Definition at line 103 of file MultipleChoiceSelection.h.
|
inline |
Returns whether the two options are not the same.
Definition at line 127 of file MultipleChoiceSelection.h.
References util::details::CaseInsensitiveComparer::equal(), util::details::MultipleChoiceSelectionOption_t< Choices >::name(), value, and util::details::MultipleChoiceSelectionOption_t< Choices >::value().
|
inline |
Returns whether the two options are the same (same value and name).
Definition at line 121 of file MultipleChoiceSelection.h.
References util::details::CaseInsensitiveComparer::equal(), util::details::MultipleChoiceSelectionOption_t< Choices >::name(), value, and util::details::MultipleChoiceSelectionOption_t< Choices >::value().
|
inline |
Returns a copy of the value of the option.
Definition at line 94 of file MultipleChoiceSelection.h.
Referenced by util::MultipleChoiceSelection< Choices >::addAlias(), util::MultipleChoiceSelection< Choices >::addOption(), util::MultipleChoiceSelection< Choices >::findOption(), util::MultipleChoiceSelection< Choices >::get(), util::MultipleChoiceSelection< Choices >::hasOption(), util::details::MultipleChoiceSelectionOption_t< Choices >::operator!=(), util::details::operator!=(), util::details::MultipleChoiceSelectionOption_t< Choices >::operator==(), util::details::operator==(), and util::details::MultipleChoiceSelectionOption_t< Choices >::value_as_string().
std::string util::details::MultipleChoiceSelectionOption_t< Choices >::value_as_string | ( | ) | const |
Returns a string representing the value of the option.
That will be the name()
of the option if the value is not convertible to a string.
Definition at line 623 of file MultipleChoiceSelection.h.
References util::details::MultipleChoiceSelectionOption_t< Choices >::name().
Referenced by util::MultipleChoiceSelection< Choices >::addAlias(), util::details::MultipleChoiceSelectionOption_t< Choices >::dump(), util::MultipleChoiceSelection< Choices >::get(), and util::details::MultipleChoiceSelectionOption_t< Choices >::value_as_string().
std::string util::details::MultipleChoiceSelectionOption_t< Choices >::value_as_string | ( | std::string const & | defValue | ) | const |
Returns a string represent the value of the option, or defValue
.
Definition at line 615 of file MultipleChoiceSelection.h.
References util::details::MultipleChoiceSelectionOption_t< Choices >::value(), and util::details::MultipleChoiceSelectionOption_t< Choices >::value_as_string().
|
static |
Converts a value of type Choices_t
into a string, if possible.
Definition at line 630 of file MultipleChoiceSelection.h.
|
static |
Converts a value of type Choices_t
into a string, if possible.
Definition at line 638 of file MultipleChoiceSelection.h.
References util::details::MultipleChoiceSelectionOption_t< Choices >::value_as_string().
|
private |
All the labels.
Definition at line 140 of file MultipleChoiceSelection.h.
Referenced by util::details::MultipleChoiceSelectionOption_t< Choices >::addAlias(), util::details::MultipleChoiceSelectionOption_t< Choices >::dump(), util::details::MultipleChoiceSelectionOption_t< Choices >::match(), and util::details::MultipleChoiceSelectionOption_t< Choices >::MultipleChoiceSelectionOption_t().
|
private |
The value associated to the option.
Definition at line 139 of file MultipleChoiceSelection.h.