Associative configuration container. More...
#include <config.h>
Public Types | |
typedef boost::variant< double, std::vector< double > , std::string, std::vector < Config > > | value_t |
An individual value (double, double[], string, or Config[]) | |
typedef std::vector< Config > | vector_t |
typedef std::map< std::string, value_t > | values_t |
typedef values_t::iterator | iterator |
iterator | |
typedef values_t::const_iterator | const_iterator |
const_iterator | |
Public Member Functions | |
Config () | |
New empty config. | |
Config (const Config &) | |
Config & | operator= (const Config &) |
Assignment. | |
bool | tryGetAny (const std::string &name, value_t &ret) const |
const value_t & | getAny (const std::string &name) const |
void | setAny (const std::string &name, const value_t &val) |
void | swapAny (const std::string &name, value_t &val) |
Exchange a single parameter untyped. | |
template<typename T > | |
detail::RT< T >::type | get (const std::string &name) const |
template<typename T > | |
detail::RT< T >::type | get (const std::string &name, typename boost::call_traits< T >::param_type def) const |
template<typename T > | |
bool | tryGet (const std::string &name, T &val) const |
template<typename T > | |
void | set (const std::string &name, typename boost::call_traits< typename detail::is_config_value< T >::type >::param_type val) |
template<typename T > | |
void | swap (const std::string &name, typename boost::call_traits< typename detail::is_config_value< T >::type >::reference val) |
void | swap (Config &c) |
Exchange entire Config. | |
void | show (std::ostream &, unsigned indent=0) const |
Print listing of inner scope. | |
const_iterator | begin () const |
The first element. | |
const_iterator | end () const |
one after the last element | |
void | reserve (size_t) |
Config | new_scope () const |
Create a new inner scope. | |
void | push_scope () |
void | flatten () |
Associative configuration container.
Typed key/value storage. Value types must be:
Most common usage is get<>() and set<>() to fetch and store typed values. Generic code might also use getAny() or setAny().
Also has the notion
Config::Config | ( | const Config & | O | ) |
Build config from a single std::map (single scope) Copy ctor
Definition at line 15 of file config.cpp.
|
inline |
|
inline |
const Config::value_t & Config::getAny | ( | const std::string & | name | ) | const |
lookup untyped.
key_error | if name doesn't refer to an existing parameter |
Definition at line 58 of file config.cpp.
|
inline |
void Config::setAny | ( | const std::string & | name, |
const value_t & | val | ||
) |
add/replace with a new value, untyped
Definition at line 69 of file config.cpp.
|
inline |
|
inline |
bool Config::tryGetAny | ( | const std::string & | name, |
value_t & | ret | ||
) | const |
lookup untyped.
Definition at line 40 of file config.cpp.