hmbdc
simplify-high-performance-messaging-programming
|
class to hold an hmbdc configuration More...
#include <Config.hpp>
Public Member Functions | |
Config () | |
empty config | |
Config (Config const &other) | |
copt ctor | |
Config & | operator= (Config const &other) |
assignment | |
Config (istream &&is, char const *section=nullptr) | |
construct using stream, optionally specifying the section name More... | |
Config (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... | |
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... | |
list< pair< string, string > > | content (unordered_set< string > const &skipThese=unordered_set< string >()) const |
get contents of all the effective configure in the form of list of string pairs More... | |
Friends | |
ostream & | operator<< (ostream &os, Config const &cfg) |
stream out the effective settings 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 !!!
|
inlineexplicit |
construct using stream, optionally specifying the section name
if the section is nullptr, just use the fallback values. if the section name cannot be found, throw an exception
is | stream as input providing a json stream |
section | pointing to the effective section in the json above |
|
inlineexplicit |
construct using stream, optionally specifying the section name
if the section is nullptr, just use the fallback values. if the section name cannot be found, throw an exception
is | stream as input providing a json stream |
section | pointing to the effective section in the json above |
|
inlineexplicit |
construct using a string, optionally specifying the section name
if the section is nullptr, just use the fallback values. if the section name cannot be found, throw an exception
json | string as input providing a json text |
section | pointing to the effective section in the json above |
|
inline |
construct using another ptree as fallbacks, optionally specifying the section name
if the section is nullptr, just use the fallback values. if the section name cannot be found, throw an exception
t | ptree as input providing fallbacks (and sections) |
section | pointing to the effective section in the ptree above |
|
inline |
construct using a fallback ptree, and specify the section ptree
if the section is nullptr, just use the fallback values. if the section name cannot be found, throw an exception
dft | ptree as input providing fallbacks |
section | ptree providing section specific values |
|
inline |
get contents of all the effective configure in the form of list of string pairs
only effective ones are shown
skipThese | skip those config params |
|
inline |
get a vector of value from the json array
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.
param | config parameter name |
throwIfMissing | - true if no config found, throw an exception; otherwise return empty |
T | type of the value |
|
inline |
Gets the child 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. Throw exception ptree_bad_path if all fail
[in] | param | config parameter name |
|
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
param | config parameter name |
throwIfMissing | - true if no config found, throw an exception; otherwise return empty |
T | type of the value |
|
inline |
get a number value in hex format
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. Throw exception ptree_bad_path if all fail
param | config parameter name |
T | numeric type of the value: int , uint64_t ... |
|
inline |
fill in a variable with a configured value retrieved using getExt
example cfg(abc, "abc")(def, "def");
to | destination |
param | config parameter |
throwIfMissing | - true if no config found, throw an exception |
|
inline |
|
inline |
|
inline |
change section name
the fallbacks also changes accordingly if possible
section | new section name |
sectionExists | check if the section exist in current config
|
|
inline |
set additional defaults
previously set defaults take precedence
c | a config holding configuration values |
|
friend |
stream out the effective settings
os | ostream |
cfg | The configuration |