...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::log::sinks::basic_custom_mapping — Customizable mapping.
// In header: <boost/log/sinks/attribute_mapping.hpp> template<typename MappedT, typename AttributeValueT = int> class basic_custom_mapping : public boost::log::sinks::basic_mapping< MappedT > { public: // types typedef AttributeValueT attribute_value_type; // Attribute contained value type. typedef base_type::mapped_type mapped_type; // Mapped value type. // construct/copy/destruct explicit basic_custom_mapping(attribute_name const &, mapped_type const &); // public member functions mapped_type operator()(record_view const &) const; implementation_defined operator[](attribute_value_type const &); };
The class allows to setup a custom mapping between an attribute and native values. The mapping should be initialized similarly to the standard map
container, by using indexing operator and assignment.
Note | |
---|---|
Unlike many other components of the library, exact type of the attribute value must be specified in the template parameter |
basic_custom_mapping
public member functionsmapped_type operator()(record_view const & rec) const;
Extraction operator. Extracts the attribute value and attempts to map it onto the native value.
Parameters: |
|
||
Returns: |
A mapped value, if mapping was successful, or the default value if mapping did not succeed. |
implementation_defined operator[](attribute_value_type const & key);
Insertion operator
Parameters: |
|
||
Returns: |
An object of unspecified type that allows to insert a new mapping through assignment. The key argument becomes the key attribute value, and the assigned value becomes the mapped native value. |