Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::sinks::basic_custom_mapping< MappedT, AttributeValueT > Class Template Reference

Customizable mapping. More...

#include <attribute_mapping.hpp>

Inheritance diagram for boost::sinks::basic_custom_mapping< MappedT, AttributeValueT >:
Collaboration diagram for boost::sinks::basic_custom_mapping< MappedT, AttributeValueT >:

Public Types

typedef AttributeValueT attribute_value_type
 Attribute contained value type. More...
 
typedef base_type::mapped_type mapped_type
 Mapped value type. More...
 
typedef mapped_type result_type
 Result type. More...
 

Public Member Functions

 basic_custom_mapping (attribute_name const &name, mapped_type const &default_value)
 Constructor. More...
 
mapped_type operator() (record_view const &rec) const
 Extraction operator. More...
 
reference_proxy operator[] (attribute_value_type const &key)
 Insertion operator. More...
 

Detailed Description

template<typename MappedT, typename AttributeValueT = int>
class boost::sinks::basic_custom_mapping< MappedT, AttributeValueT >

Customizable mapping.

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 AttributeValueT. Type sequences are not supported.

Member Typedef Documentation

template<typename MappedT, typename AttributeValueT = int>
typedef AttributeValueT boost::sinks::basic_custom_mapping< MappedT, AttributeValueT >::attribute_value_type

Attribute contained value type.

template<typename MappedT, typename AttributeValueT = int>
typedef base_type::mapped_type boost::sinks::basic_custom_mapping< MappedT, AttributeValueT >::mapped_type

Mapped value type.

template<typename MappedT>
typedef mapped_type boost::sinks::basic_mapping< MappedT >::result_type
inherited

Result type.

Constructor & Destructor Documentation

template<typename MappedT, typename AttributeValueT = int>
boost::sinks::basic_custom_mapping< MappedT, AttributeValueT >::basic_custom_mapping ( attribute_name const &  name,
mapped_type const &  default_value 
)
inlineexplicit

Constructor.

Parameters
nameAttribute name
default_valueThe default native value that is returned if the conversion cannot be performed

Member Function Documentation

template<typename MappedT, typename AttributeValueT = int>
mapped_type boost::sinks::basic_custom_mapping< MappedT, AttributeValueT >::operator() ( record_view const &  rec) const
inline

Extraction operator.

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

Parameters
recA log record to extract value from
Returns
A mapped value, if mapping was successful, or the default value if mapping did not succeed.
template<typename MappedT, typename AttributeValueT = int>
reference_proxy boost::sinks::basic_custom_mapping< MappedT, AttributeValueT >::operator[] ( attribute_value_type const &  key)
inline

Insertion operator.

Parameters
keyAttribute 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.

The documentation for this class was generated from the following file: