Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::attribute_set Class Reference

An attribute set class. More...

#include <attribute_set.hpp>

Public Types

typedef attribute_name key_type
 Key type. More...
 
typedef attribute mapped_type
 Mapped attribute type. More...
 
typedef std::pair< const
key_type, mapped_type
value_type
 Value type. More...
 
typedef value_typereference
 Reference type. More...
 
typedef value_type const & const_reference
 Const reference type. More...
 
typedef value_typepointer
 Pointer type. More...
 
typedef value_type const * const_pointer
 Const pointer type. More...
 
typedef std::size_t size_type
 Size type. More...
 
typedef std::ptrdiff_t difference_type
 Difference type. More...
 
typedef iter< false > iterator
 Iterator type. More...
 
typedef iter< true > const_iterator
 Const iterator type. More...
 

Public Member Functions

BOOST_LOG_API attribute_set ()
 Default constructor. More...
 
BOOST_LOG_API attribute_set (attribute_set const &that)
 Copy constructor. More...
 
 attribute_set (BOOST_RV_REF(attribute_set) that) BOOST_NOEXCEPT
 Move constructor. More...
 
BOOST_LOG_API ~attribute_set () BOOST_NOEXCEPT
 Destructor. More...
 
attribute_setoperator= (attribute_set that) BOOST_NOEXCEPT
 Copy assignment operator. More...
 
void swap (attribute_set &that) BOOST_NOEXCEPT
 Swaps two instances of the container. More...
 
BOOST_LOG_API iterator begin () BOOST_NOEXCEPT
 
BOOST_LOG_API iterator end () BOOST_NOEXCEPT
 
BOOST_LOG_API const_iterator begin () const BOOST_NOEXCEPT
 
BOOST_LOG_API const_iterator end () const BOOST_NOEXCEPT
 
BOOST_LOG_API size_type size () const BOOST_NOEXCEPT
 
bool empty () const BOOST_NOEXCEPT
 
BOOST_LOG_API iterator find (key_type key) BOOST_NOEXCEPT
 The method finds the attribute by name. More...
 
const_iterator find (key_type key) const BOOST_NOEXCEPT
 The method finds the attribute by name. More...
 
size_type count (key_type key) const BOOST_NOEXCEPT
 The method counts the number of the attribute occurrences in the container. More...
 
aux::attribute_set_reference_proxy operator[] (key_type key) BOOST_NOEXCEPT
 Combined lookup/insertion operator. More...
 
mapped_type operator[] (key_type key) const BOOST_NOEXCEPT
 Lookup operator. More...
 
BOOST_LOG_API std::pair
< iterator, bool > 
insert (key_type key, mapped_type const &data)
 Insertion method. More...
 
std::pair< iterator, bool > insert (const_reference value)
 Insertion method. More...
 
template<typename FwdIteratorT >
void insert (FwdIteratorT begin, FwdIteratorT end)
 Mass insertion method. More...
 
template<typename FwdIteratorT , typename OutputIteratorT >
void insert (FwdIteratorT begin, FwdIteratorT end, OutputIteratorT out)
 Mass insertion method with ability to acquire iterators to the inserted elements. More...
 
BOOST_LOG_API size_type erase (key_type key) BOOST_NOEXCEPT
 The method erases all attributes with the specified name. More...
 
BOOST_LOG_API void erase (iterator it) BOOST_NOEXCEPT
 The method erases the specified attribute. More...
 
BOOST_LOG_API void erase (iterator begin, iterator end) BOOST_NOEXCEPT
 The method erases all attributes within the specified range. More...
 
BOOST_LOG_API void clear () BOOST_NOEXCEPT
 The method removes all elements from the container. More...
 

Friends

class attribute_value_set
 
class aux::attribute_set_reference_proxy
 

Detailed Description

An attribute set class.

An attribute set is an associative container with attribute name as a key and pointer to the attribute as a mapped value. The container allows storing only one element for each distinct key value. In most regards attribute set container provides interface similar to std::unordered_map. However, there are differences in operator[] semantics and a number of optimizations with regard to iteration. Besides, attribute names are stored as a read-only attribute_name's instead of std::string, which saves memory and CPU time.

Member Typedef Documentation

Const iterator type.

Const pointer type.

Const reference type.

typedef std::ptrdiff_t boost::attribute_set::difference_type

Difference type.

typedef iter< false > boost::attribute_set::iterator

Iterator type.

Mapped attribute type.

Pointer type.

Reference type.

typedef std::size_t boost::attribute_set::size_type

Size type.

Value type.

Constructor & Destructor Documentation

BOOST_LOG_API boost::attribute_set::attribute_set ( )

Default constructor.

Postcondition
empty() == true
BOOST_LOG_API boost::attribute_set::attribute_set ( attribute_set const &  that)

Copy constructor.

Postcondition
size() == that.size() && std::equal(begin(), end(), that.begin()) == true
boost::attribute_set::attribute_set ( BOOST_RV_REF(attribute_set that)
inline

Move constructor.

BOOST_LOG_API boost::attribute_set::~attribute_set ( )

Destructor.

All stored references to attributes are released.

Member Function Documentation

BOOST_LOG_API iterator boost::attribute_set::begin ( )
Returns
Iterator to the first element of the container.
BOOST_LOG_API const_iterator boost::attribute_set::begin ( ) const
Returns
Constant iterator to the first element of the container.
BOOST_LOG_API void boost::attribute_set::clear ( )

The method removes all elements from the container.

Postcondition
empty() == true

Referenced by boost::sources::basic_logger< CharT, FinalT, ThreadingModelT >::remove_all_attributes_unlocked().

size_type boost::attribute_set::count ( key_type  key) const
inline

The method counts the number of the attribute occurrences in the container.

Since there can be only one attribute with a particular key, the method always return 0 or 1.

Parameters
keyAttribute name.
Returns
The number of times the attribute is found in the container.

References boost::end, and boost::algorithm::find().

bool boost::attribute_set::empty ( void  ) const
inline
Returns
true if there are no elements in the container, false otherwise.

References boost::size().

BOOST_LOG_API iterator boost::attribute_set::end ( )
Returns
Iterator to the after-the-last element of the container.

Referenced by boost::aux::attribute_set_reference_proxy::operator mapped_type().

BOOST_LOG_API const_iterator boost::attribute_set::end ( ) const
Returns
Constant iterator to the after-the-last element of the container.
BOOST_LOG_API size_type boost::attribute_set::erase ( key_type  key)

The method erases all attributes with the specified name.

Postcondition
All iterators to the erased elements become invalid.
Parameters
keyAttribute name.
Returns
Tne number of erased elements

Referenced by boost::sources::basic_logger< CharT, FinalT, ThreadingModelT >::remove_attribute_unlocked().

BOOST_LOG_API void boost::attribute_set::erase ( iterator  it)

The method erases the specified attribute.

Postcondition
All iterators to the erased element become invalid.
Parameters
itA valid iterator to the element to be erased.
Returns
Tne number of erased elements
BOOST_LOG_API void boost::attribute_set::erase ( iterator  begin,
iterator  end 
)

The method erases all attributes within the specified range.

Precondition
end is reachable from begin with a finite number of increments.
Postcondition
All iterators to the erased elements become invalid.
Parameters
beginAn iterator that points to the first element to be erased.
endAn iterator that points to the after-the-last element to be erased.
BOOST_LOG_API iterator boost::attribute_set::find ( key_type  key)

The method finds the attribute by name.

Parameters
keyAttribute name.
Returns
Iterator to the found element or end() if the attribute with such name is not found.

Referenced by boost::aux::attribute_set_reference_proxy::operator mapped_type().

const_iterator boost::attribute_set::find ( key_type  key) const
inline

The method finds the attribute by name.

Parameters
keyAttribute name.
Returns
Iterator to the found element or end() if the attribute with such name is not found.

References boost::algorithm::find().

BOOST_LOG_API std::pair< iterator, bool > boost::attribute_set::insert ( key_type  key,
mapped_type const &  data 
)

Insertion method.

Parameters
keyAttribute name.
dataPointer to the attribute. Must not be NULL.
Returns
A pair of values. If second is true, the insertion succeeded and the first component points to the inserted element. Otherwise the first component points to the element that prevents insertion.

Referenced by boost::sources::basic_logger< CharT, FinalT, ThreadingModelT >::add_attribute_unlocked(), and boost::aux::attribute_set_reference_proxy::operator=().

std::pair< iterator, bool > boost::attribute_set::insert ( const_reference  value)
inline

Insertion method.

Parameters
valueAn element to be inserted.
Returns
A pair of values. If second is true, the insertion succeeded and the first component points to the inserted element. Otherwise the first component points to the element that prevents insertion.

References boost::xpressive::insert.

template<typename FwdIteratorT >
void boost::attribute_set::insert ( FwdIteratorT  begin,
FwdIteratorT  end 
)
inline

Mass insertion method.

Parameters
beginA forward iterator that points to the first element to be inserted.
endA forward iterator that points to the after-the-last element to be inserted.

References boost::asio::begin, boost::end, and boost::xpressive::insert.

template<typename FwdIteratorT , typename OutputIteratorT >
void boost::attribute_set::insert ( FwdIteratorT  begin,
FwdIteratorT  end,
OutputIteratorT  out 
)
inline

Mass insertion method with ability to acquire iterators to the inserted elements.

Parameters
beginA forward iterator that points to the first element to be inserted.
endA forward iterator that points to the after-the-last element to be inserted.
outAn output iterator that receives results of insertion of the elements

References boost::asio::begin, boost::end, boost::xpressive::insert, and boost::out.

attribute_set& boost::attribute_set::operator= ( attribute_set  that)
inline

Copy assignment operator.

Postcondition
size() == that.size() && std::equal(begin(), end(), that.begin()) == true

References boost::swap.

aux::attribute_set_reference_proxy boost::attribute_set::operator[] ( key_type  key)
inline

Combined lookup/insertion operator.

The operator semantics depends on the further usage of the returned reference.

  • If the reference is used as an assignment target, the assignment expression is equivalent to element insertion, where the element is composed of the second argument of the operator[] as a key and the second argument of assignment as a mapped value.
  • If the returned reference is used in context where a conversion to the mapped type is required, the result of the conversion is equivalent to the mapped value found with the second argument of the operator[] as a key, if such an element exists in the container, or a default-constructed mapped value, if an element does not exist in the container.
Parameters
keyAttribute name.
Returns
A smart reference object of unspecified type.
mapped_type boost::attribute_set::operator[] ( key_type  key) const
inline

Lookup operator.

Parameters
keyAttribute name.
Returns
If an element with the corresponding attribute name is found in the container, its mapped value is returned. Otherwise a default-constructed mapped value is returned.

References boost::end, boost::algorithm::find(), and boost::it.

BOOST_LOG_API size_type boost::attribute_set::size ( ) const
Returns
Number of elements in the container.
void boost::attribute_set::swap ( attribute_set that)
inline

Friends And Related Function Documentation

friend class attribute_value_set
friend

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