Boost C++ Libraries

PrevUpHomeNext

Class template basic_custom_mapping

boost::log::sinks::basic_custom_mapping — Customizable mapping.

Synopsis

// In header: <boost/log/sinks/attribute_mapping.hpp>

template<typename CharT, typename MappedT, typename AttributeValueT = int> 
class basic_custom_mapping :
  public boost::log::sinks::basic_mapping< CharT, MappedT >
{
public:
  // types
  typedef AttributeValueT             attribute_value_type;  // Attribute contained value type. 
  typedef base_type::char_type        char_type;             // Char type. 
  typedef base_type::string_type      string_type;           // String type. 
  typedef base_type::values_view_type values_view_type;      // Attribute values view type. 
  typedef base_type::mapped_type      mapped_type;           // Mapped value type. 

  // construct/copy/destruct
  explicit basic_custom_mapping(string_type const &, mapped_type const &);

  // public member functions
  mapped_type operator()(values_view_type const &) const;
  implementation_defined operator[](attribute_value_type const &);
};

Description

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] Note

Unlike many other components of the library, exact type of the attribute value must be specified in the template parameter AttributeValueT. Type sequences are not supported.

basic_custom_mapping public construct/copy/destruct

  1. explicit basic_custom_mapping(string_type const & name, 
                                  mapped_type const & default_value);

    Constructor

    Parameters:
    default_value

    The default native value that is returned if the conversion cannot be performed

    name

    Attribute name

basic_custom_mapping public member functions

  1. mapped_type operator()(values_view_type const & values) const;

    Extraction operator. Extracts the attribute value and attempts to map it onto the native value.

    Parameters:
    values

    A set of attribute values attached to a logging record

    Returns:

    A mapped value, if mapping was successfull, or the default value if mapping did not succeed.

  2. implementation_defined operator[](attribute_value_type const & key);

    Insertion operator

    Parameters:
    key

    Attribute value to be mapped

    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.


PrevUpHomeNext