boost::log::basic_attribute_set — An attribute set class.
// In header: <boost/log/attributes/attribute_set.hpp> template<typename CharT> class basic_attribute_set { public: // types typedef CharT char_type; // Character type. typedef std::basic_string< char_type > string_type; // String type. typedef basic_slim_string< char_type > key_type; // Key type. typedef shared_ptr< attribute > mapped_type; // Mapped attribute type. typedef std::pair< const key_type, mapped_type > value_type; // Value type. typedef std::allocator< value_type > allocator_type; // Allocator type. typedef allocator_type::reference reference; // Reference type. typedef allocator_type::const_reference const_reference; // Const reference type. typedef allocator_type::pointer pointer; // Pointer type. typedef allocator_type::const_pointer const_pointer; // Const pointer type. typedef allocator_type::size_type size_type; // Size type. typedef allocator_type::difference_type difference_type; // Difference type. typedef implementation_defined iterator; typedef implementation_defined const_iterator; // construct/copy/destruct basic_attribute_set(); basic_attribute_set(basic_attribute_set const &); basic_attribute_set& operator=(basic_attribute_set const &); ~basic_attribute_set(); // public member functions void swap(basic_attribute_set &); iterator begin(); iterator end(); const_iterator begin() const; const_iterator end() const; size_type size() const; bool empty() const; iterator find(key_type const &); iterator find(string_type const &); iterator find(const char_type *); const_iterator find(key_type const &) const; const_iterator find(string_type const &) const; const_iterator find(const char_type *) const; size_type count(key_type const &) const; size_type count(string_type const &) const; size_type count(const char_type *) const; reference_proxy operator[](key_type const &); reference_proxy operator[](string_type const &); reference_proxy operator[](const char_type *); mapped_type operator[](key_type const &) const; mapped_type operator[](string_type const &) const; mapped_type operator[](const char_type *) const; std::pair< iterator, bool > insert(key_type const &, mapped_type const &); std::pair< iterator, bool > insert(const_reference); template<typename FwdIteratorT> void insert(FwdIteratorT, FwdIteratorT); template<typename FwdIteratorT, typename OutputIteratorT> void insert(FwdIteratorT, FwdIteratorT, OutputIteratorT); size_type erase(key_type const &); void erase(iterator); void erase(iterator, iterator); void clear(); };
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::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 slim_string
's instead of std::string
, which is also saves memory and CPU time.
basic_attribute_set
public
construct/copy/destructbasic_attribute_set();
Default constructor.
Postconditions: |
|
basic_attribute_set(basic_attribute_set const & that);
Copy constructor.
Postconditions: |
|
basic_attribute_set& operator=(basic_attribute_set const & that);
Assignment operator.
Postconditions: |
|
~basic_attribute_set();
Destructor. All stored references to attributes are released.
basic_attribute_set
public member functionsvoid swap(basic_attribute_set & that);
Swaps two instances of the container.
Throws: Nothing.
iterator begin();
Returns: | Iterator to the first element of the container. |
iterator end();
Returns: | Iterator to the after-the-last element of the container. |
const_iterator begin() const;
Returns: | Constant iterator to the first element of the container. |
const_iterator end() const;
Returns: | Constant iterator to the after-the-last element of the container. |
size_type size() const;
Returns: | Number of elements in the container. |
bool empty() const;
Returns: | true if there are no elements in the container, false otherwise. |
iterator find(key_type const & key);
The method finds the attribute by name.
Parameters: |
|
||
Returns: | Iterator to the found element or end() if the attribute with such name is not found. |
iterator find(string_type const & key);
The method finds the attribute by name.
Parameters: |
|
||
Returns: | Iterator to the found element or |
iterator find(const char_type * key);
The method finds the attribute by name.
Parameters: |
|
||
Returns: | Iterator to the found element or |
const_iterator find(key_type const & key) const;
The method finds the attribute by name.
Parameters: |
|
||
Returns: | Iterator to the found element or |
const_iterator find(string_type const & key) const;
The method finds the attribute by name.
Parameters: |
|
||
Returns: | Iterator to the found element or |
const_iterator find(const char_type * key) const;
The method finds the attribute by name.
Parameters: |
|
||
Returns: | Iterator to the found element or |
size_type count(key_type const & key) const;
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: |
|
||
Returns: | The number of times the attribute is found in the container. |
size_type count(string_type const & key) const;
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: |
|
||
Returns: | The number of times the attribute is found in the container. |
size_type count(const char_type * key) const;
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: |
|
||
Returns: | The number of times the attribute is found in the container. |
reference_proxy operator[](key_type const & key);
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: |
|
||
Returns: | A smart reference object of unspecified type. |
reference_proxy operator[](string_type const & key);
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: |
|
||
Returns: | A smart reference object of unspecified type. |
reference_proxy operator[](const char_type * key);
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: |
|
||
Returns: | A smart reference object of unspecified type. |
mapped_type operator[](key_type const & key) const;
Lookup operator
Parameters: |
|
||
Returns: | If an element with the corresponding attribute name is found in the container, its mapped value is returned. Otherwise a refault-constructed mapped value is returned. |
mapped_type operator[](string_type const & key) const;
Lookup operator
Parameters: |
|
||
Returns: | If an element with the corresponding attribute name is found in the container, its mapped value is returned. Otherwise a refault-constructed mapped value is returned. |
mapped_type operator[](const char_type * key) const;
Lookup operator
Parameters: |
|
||
Returns: | If an element with the corresponding attribute name is found in the container, its mapped value is returned. Otherwise a refault-constructed mapped value is returned. |
std::pair< iterator, bool > insert(key_type const & key, mapped_type const & data);
Insertion method
Parameters: |
|
||||
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. |
std::pair< iterator, bool > insert(const_reference value);
Insertion method
Parameters: |
|
||
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. |
template<typename FwdIteratorT> void insert(FwdIteratorT begin, FwdIteratorT end);
Mass insertion method.
Parameters: |
|
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.
Parameters: |
|
size_type erase(key_type const & key);
The method erases all attributes with the specified name
Parameters: |
|
||
Postconditions: | All iterators to the erased elements become invalid. |
||
Returns: | Tne number of erased elements |
void erase(iterator it);
The method erases the specified attribute
Parameters: |
|
||
Postconditions: | All iterators to the erased element become invalid. |
||
Returns: | Tne number of erased elements |
void erase(iterator begin, iterator end);
The method erases all attributes within the specified range
Parameters: |
|
||||
Requires: | end is reachable from begin with a finite number of increments. |
||||
Postconditions: | All iterators to the erased elements become invalid. |
void clear();
The method removes all elements from the container
Postconditions: |
|