boost::log::basic_settings — The class represents settings container.
// In header: <boost/log/utility/init/from_settings.hpp> template<typename CharT> class basic_settings { public: // types typedef CharT char_type; // Character type. typedef std::basic_string< char_type > string_type; // String type. typedef std::map< string_type, any > parameters_type; // The type of the map of parameters and their names. typedef std::map< string_type, parameters_type > sections_type; // The type of the map of sections. // public member functions bool empty() const; implementation_defined operator[](string_type const &); implementation_defined operator[](string_type const &) const; sections_type const & sections() const; sections_type & sections(); bool has_section(string_type const &) const; bool has_parameter(string_type const &, string_type const &) const; };
All settings are presented as a number of named parameters divided into named sections. There is only one layer of sections (i.e. there are no subsections), and all parameters reside in sections (i.e. no top-level parameters). The parameters may have any type compatible with boost::any
, which is used to store parameters. Individual parameters may be queried via subscript operators, like this:
any param = settings["Section1"]["Param1"]; // reads parameter "Param1" in section "Section1" // returns empty value if no such parameter exists settings["Section2"]["Param2"] = 10; // sets the parameter "Param2" in section "Section2" to value 10 (of type int)
There are also other methods to work with parameters.
basic_settings
public member functionsbool empty() const;
Checks if the container is empty (i.e. contains no sections and parameters).
implementation_defined operator[](string_type const & section_name);
Accessor to a single parameter. This operator should be used in conjunction with the subsequent subscript operator that designates the parameter name.
Parameters: |
|
||
Returns: | An unspecified reference type that can be used for parameter name specifying |
implementation_defined operator[](string_type const & section_name) const;
Accessor to a single parameter. This operator should be used in conjunction with the subsequent subscript operator that designates the parameter name.
Parameters: |
|
||
Returns: | An unspecified reference type that can be used for parameter name specifying |
sections_type const & sections() const;
Accessor for the map of sections
sections_type & sections();
Accessor for the map of sections
bool has_section(string_type const & section_name) const;
Checks if the specified section is present in the container.
Parameters: |
|
bool has_parameter(string_type const & section_name, string_type const & param_name) const;
Checks if the specified parameter is present in the container.
Parameters: |
|