|
| Config () |
| empty config
|
|
| Config (Config const &other) |
| copt ctor
|
|
Config & | operator= (Config const &other) |
| assignment
|
|
| Config (std::istream &&is, char const *section=nullptr) |
| construct using stream, optionally specifying the section name More...
|
|
| Config (std::istream &is, char const *section=nullptr) |
| construct using stream, optionally specifying the section name More...
|
|
| Config (char const *json, char const *section=nullptr) |
| construct using a string, optionally specifying the section name More...
|
|
| Config (ptree const &t, char const *section=nullptr) |
| construct using another ptree as fallbacks, optionally specifying the section name More...
|
|
| Config (ptree const &dft, ptree const §ion) |
| construct using a fallback ptree, and specify the section ptree More...
|
|
void | setAdditionalFallbackConfig (Config const &c) |
| set additional defaults More...
|
|
void | setDefaultUserConfig (Config const &c) |
| depracated
|
|
Config & | resetSection (char const *section, bool sectionExists=true) |
| change section name More...
|
|
template<typename ... Args> |
Config & | put (Args &&... args) |
| forward the call to ptree's put but return Configure More...
|
|
ptree const & | getChildExt (const path_type ¶m) |
| Gets the child from the config. More...
|
|
template<typename T > |
T | getExt (const path_type ¶m, bool throwIfMissing=true) const |
| get a value from the config More...
|
|
template<typename T > |
std::vector< T > | getArray (const path_type ¶m) const |
| get a vector of value from the json array More...
|
|
template<typename T > |
T | getHex (ptree::path_type const ¶m) const |
| get a number value in hex format More...
|
|
template<typename T > |
Config const & | operator() (T &to, const path_type ¶m, bool throwIfMissing=true) const |
| fill in a variable with a configured value retrieved using getExt More...
|
|
template<typename T > |
Config const & | operator() (std::unordered_set< T > &to, const path_type ¶m, bool throwIfMissing=true) const |
| fill an unordered_set with a configured value retrieved using getExt More...
|
|
template<typename T > |
Config const & | operator() (std::vector< T > &to, const path_type ¶m, bool throwIfMissing=true) const |
| fill an list with a configured value retrieved using getExt More...
|
|
std::list< std::pair< std::string, std::string > > | content (std::unordered_set< std::string > const &skipThese=std::unordered_set< std::string >()) const |
| get contents of all the effective configure in the form of list of string pairs More...
|
|
class to hold an hmbdc configuration
it is based on a two level (fallback and section) json. top level for the fallback values and lower level for the section specific values. a Config instance is always constructed to be associated to 0 or 1 specific section. shown below:
{
"parameter_1": "top level, value used as a fallback",
"parameter_2": "fallback is used when not configured in a section",
"section_A": {
"parameter_2": "lower level, a specific value effective in section_A",
"parameter_1": "a specific value effective in section_A"
},
"another_section": {
"parameter_2": "a specific value effective in another_section"
}
}
json array is not supported !!!
- Examples:
- hello-world.cpp.
template<typename T >
T hmbdc::app::config_detail::Config::getExt |
( |
const path_type & |
param, |
|
|
bool |
throwIfMissing = true |
|
) |
| const |
|
inline |
get a value from the config
check the section for it, if not found, try use fallback provided if still missing, search using the default user config values set by setDefaultUserConfig. If throwIfMissing, throw exception ptree_bad_path if all fail
- Parameters
-
param | config parameter name |
throwIfMissing | - true if no config found, throw an exception; otherwise return empty |
- Template Parameters
-
- Returns
- result