...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::log::attribute_name — The class represents an attribute name in containers used by the library.
// In header: <boost/log/attributes/attribute_name.hpp> class attribute_name { public: // types typedef std::string string_type; // String type. typedef unspecified id_type; // Associated identifier. // construct/copy/destruct attribute_name() noexcept; attribute_name(const char *); attribute_name(string_type const &); // public member functions bool operator==(attribute_name const &) const noexcept; bool operator!=(attribute_name const &) const noexcept; bool operator==(const char *) const; bool operator!=(const char *) const; bool operator==(string_type const &) const; bool operator!=(string_type const &) const; explicit operator bool() const noexcept; bool operator!() const noexcept; id_type id() const noexcept; string_type const & string() const; };
The class mostly serves for optimization purposes. Each attribute name that is used with the library is automatically associated with a unique identifier, which is much lighter in terms of memory footprint and operations complexity. This is done transparently by this class, on object construction. Passing objects of this class to other library methods, such as attribute lookup functions, will not require this translation and/or string copying and thus will result in a more efficient code.
attribute_name
public
construct/copy/destructattribute_name() noexcept;
Default constructor. Creates an object that does not refer to any attribute name.
attribute_name(const char * name);
Constructs an attribute name from the specified string
Parameters: |
|
||
Requires: |
name is not NULL and points to a zero-terminated string |
attribute_name(string_type const & name);
Constructs an attribute name from the specified string
Parameters: |
|
attribute_name
public member functionsbool operator==(attribute_name const & that) const noexcept;
Compares the attribute names
Returns: |
|
bool operator!=(attribute_name const & that) const noexcept;
Compares the attribute names
Returns: |
|
bool operator==(const char * that) const;
Compares the attribute names
Returns: |
|
bool operator!=(const char * that) const;
Compares the attribute names
Returns: |
|
bool operator==(string_type const & that) const;
Compares the attribute names
Returns: |
|
bool operator!=(string_type const & that) const;
Compares the attribute names
Returns: |
|
explicit operator bool() const noexcept;
Checks if the object was default-constructed
Returns: |
|
bool operator!() const noexcept;
Checks if the object was default-constructed
Returns: |
|
id_type id() const noexcept;
Requires: |
|
Returns: |
The associated id value |
string_type const & string() const;
Requires: |
|
Returns: |
The attribute name string that was used during the object construction |