Boost C++ Libraries

PrevUpHomeNext

Class template basic_attribute_set

boost::log::basic_attribute_set — An attribute set class.

Synopsis

// 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();
};

Description

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 types

  1. typedef implementation_defined iterator;

    Iterator type. The iterator complies to the bidirectional iterator requirements.

  2. typedef implementation_defined const_iterator;

    Constant iterator type. The iterator complies to the bidirectional iterator requirements with read-only capabilities.

basic_attribute_set public construct/copy/destruct

  1. basic_attribute_set();

    Default constructor.

    Postconditions:

    empty() == true

  2. basic_attribute_set(basic_attribute_set const & that);

    Copy constructor.

    Postconditions:

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

  3. basic_attribute_set& operator=(basic_attribute_set const & that);

    Assignment operator.

    Postconditions:

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

  4. ~basic_attribute_set();

    Destructor. All stored references to attributes are released.

basic_attribute_set public member functions

  1. void swap(basic_attribute_set & that);

    Swaps two instances of the container.

    Throws: Nothing.

  2. iterator begin();

    Returns:

    Iterator to the first element of the container.

  3. iterator end();

    Returns:

    Iterator to the after-the-last element of the container.

  4. const_iterator begin() const;

    Returns:

    Constant iterator to the first element of the container.

  5. const_iterator end() const;

    Returns:

    Constant iterator to the after-the-last element of the container.

  6. size_type size() const;

    Returns:

    Number of elements in the container.

  7. bool empty() const;

    Returns:

    true if there are no elements in the container, false otherwise.

  8. iterator find(key_type const & key);

    The method finds the attribute by name.

    Parameters:
    key

    Attribute name.

    Returns:

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

  9. iterator find(string_type const & key);

    The method finds the attribute by name.

    Parameters:
    key

    Attribute name.

    Returns:

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

  10. iterator find(const char_type * key);

    The method finds the attribute by name.

    Parameters:
    key

    Attribute name. Must not be NULL, must point to a zero-terminated string.

    Returns:

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

  11. const_iterator find(key_type const & key) const;

    The method finds the attribute by name.

    Parameters:
    key

    Attribute name.

    Returns:

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

  12. const_iterator find(string_type const & key) const;

    The method finds the attribute by name.

    Parameters:
    key

    Attribute name.

    Returns:

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

  13. const_iterator find(const char_type * key) const;

    The method finds the attribute by name.

    Parameters:
    key

    Attribute name. Must not be NULL, must point to a zero-terminated string.

    Returns:

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

  14. 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:
    key

    Attribute name.

    Returns:

    The number of times the attribute is found in the container.

  15. 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:
    key

    Attribute name.

    Returns:

    The number of times the attribute is found in the container.

  16. 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:
    key

    Attribute name. Must not be NULL, must point to a zero-terminated string.

    Returns:

    The number of times the attribute is found in the container.

  17. 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:
    key

    Attribute name.

    Returns:

    A smart reference object of unspecified type.

  18. 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:
    key

    Attribute name.

    Returns:

    A smart reference object of unspecified type.

  19. 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:
    key

    Attribute name. Must not be NULL, must point to a zero-terminated string.

    Returns:

    A smart reference object of unspecified type.

  20. mapped_type operator[](key_type const & key) const;

    Lookup operator

    Parameters:
    key

    Attribute name.

    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.

  21. mapped_type operator[](string_type const & key) const;

    Lookup operator

    Parameters:
    key

    Attribute name.

    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.

  22. mapped_type operator[](const char_type * key) const;

    Lookup operator

    Parameters:
    key

    Attribute name. Must not be NULL, must point to a zero-terminated string.

    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.

  23. std::pair< iterator, bool > 
    insert(key_type const & key, mapped_type const & data);

    Insertion method

    Parameters:
    data

    Pointer to the attribute. Must not be NULL.

    key

    Attribute name.

    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.

  24. std::pair< iterator, bool > insert(const_reference value);

    Insertion method

    Parameters:
    value

    An 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.

  25. template<typename FwdIteratorT> 
      void insert(FwdIteratorT begin, FwdIteratorT end);

    Mass insertion method.

    Parameters:
    begin

    A forward iterator that points to the first element to be inserted.

    end

    A forward iterator that points to the after-the-last element to be inserted.

  26. 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:
    begin

    A forward iterator that points to the first element to be inserted.

    end

    A forward iterator that points to the after-the-last element to be inserted.

    out

    An output iterator that receives results of insertion of the elements

  27. size_type erase(key_type const & key);

    The method erases all attributes with the specified name

    Parameters:
    key

    Attribute name.

    Postconditions:

    All iterators to the erased elements become invalid.

    Returns:

    Tne number of erased elements

  28. void erase(iterator it);

    The method erases the specified attribute

    Parameters:
    it

    A valid iterator to the element to be erased.

    Postconditions:

    All iterators to the erased element become invalid.

    Returns:

    Tne number of erased elements

  29. void erase(iterator begin, iterator end);

    The method erases all attributes within the specified range

    Parameters:
    begin

    An iterator that points to the first element to be erased.

    end

    An iterator that points to the after-the-last element to be erased.

    Requires:

    end is reachable from begin with a finite number of increments.

    Postconditions:

    All iterators to the erased elements become invalid.

  30. void clear();

    The method removes all elements from the container

    Postconditions:

    empty() == true


PrevUpHomeNext