Boost C++ Libraries

PrevUpHomeNext

Class template basic_settings

boost::log::basic_settings — The class represents settings container.

Synopsis

// 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;
};

Description

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 functions

  1. bool empty() const;

    Checks if the container is empty (i.e. contains no sections and parameters).

  2. 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:
    section_name

    The name of the section in which the parameter resides

    Returns:

    An unspecified reference type that can be used for parameter name specifying

  3. 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:
    section_name

    The name of the section in which the parameter resides

    Returns:

    An unspecified reference type that can be used for parameter name specifying

  4. sections_type const & sections() const;

    Accessor for the map of sections

  5. sections_type & sections();

    Accessor for the map of sections

  6. bool has_section(string_type const & section_name) const;

    Checks if the specified section is present in the container.

    Parameters:
    section_name

    The name of the section

  7. 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:
    param_name

    The name of the parameter

    section_name

    The name of the section in which the parameter resides


PrevUpHomeNext