Awali
Another Weighted Automata library
|
An options_t is a set of optional parameters that is passed on to called functions. More...
#include <options.hh>
Public Member Functions | |
options_t () | |
template<typename T > | |
options_t (internal::option_t< T > opt) | |
Creates an options_t from an internal::option_t by mapping it to its default value. More... | |
options_t (internal::option_value_pair_t pair) | |
Creates an options_t from one option/value pair. More... | |
options_t (std::initializer_list< internal::option_value_pair_t > list) | |
Creates an options_t from a list of option/value pairs. More... | |
options_t | operator+ (internal::option_value_pair_t const &pair) const |
Creates a new options_t that is the union of this options_t with another option/value pair. More... | |
options_t | operator+ (options_t const &other) const |
Creates a new options_t that is the union of this options_t with another options_t. More... | |
options_t & | operator+= (internal::option_value_pair_t const &other) |
Adds an option/value pair to this options_t, possibly overriding a previous value. More... | |
options_t & | operator+= (options_t const &other) |
Adds all option/value mapping in other to this options_t, possibly overriding previous values. More... | |
template<typename T > | |
internal::option_t< T >::value_t | operator[] (internal::option_t< T > option) |
Gets the value associated by to given option by this options_t. More... | |
An options_t is a set of optional parameters that is passed on to called functions.
More precisely, it is a map from registered internal::option_t to their expected value. Hence in general, adding new mappings to an options_t might override a previous mapping.
This class is an attempt to reduce the number of optional parameters in functions. It emulates the named optional parameters paradigm of high level languages (typically, in Python).
(Examples below assume using namespace awali
and using namespace awali::dyn
.)
See group Options for details on this mechanism.
awali::dyn::options_t::options_t | ( | std::initializer_list< internal::option_value_pair_t > | list | ) |
Creates an options_t from a list of option/value pairs.
list | List of option/value pairs. |
awali::dyn::options_t::options_t | ( | ) |
awali::dyn::options_t::options_t | ( | internal::option_value_pair_t | pair | ) |
Creates an options_t from one option/value pair.
pair | Option/value pair. |
awali::dyn::options_t::options_t | ( | internal::option_t< T > | opt | ) |
Creates an options_t from an internal::option_t by mapping it to its default value.
options_t awali::dyn::options_t::operator+ | ( | internal::option_value_pair_t const & | pair | ) | const |
Creates a new options_t that is the union of this options_t with another option/value pair.
If pair
gives a value to an option that is already defined in this options_t, the one in pair
in kept and the one in this options_t is ignored.
pair | option/value pair to be added. |
options_t& awali::dyn::options_t::operator+= | ( | internal::option_value_pair_t const & | other | ) |
internal::option_t<T>::value_t awali::dyn::options_t::operator[] | ( | internal::option_t< T > | option | ) |
Gets the value associated by to given option
by this options_t.
option |
option
.