annotate DEPENDENCIES/generic/include/boost/log/attributes/attribute_name.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*
Chris@101 2 * Copyright Andrey Semashev 2007 - 2015.
Chris@16 3 * Distributed under the Boost Software License, Version 1.0.
Chris@16 4 * (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 5 * http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6 */
Chris@16 7 /*!
Chris@16 8 * \file attribute_name.hpp
Chris@16 9 * \author Andrey Semashev
Chris@16 10 * \date 28.06.2010
Chris@16 11 *
Chris@16 12 * The header contains attribute name interface definition.
Chris@16 13 */
Chris@16 14
Chris@16 15 #ifndef BOOST_LOG_ATTRIBUTE_NAME_HPP_INCLUDED_
Chris@16 16 #define BOOST_LOG_ATTRIBUTE_NAME_HPP_INCLUDED_
Chris@16 17
Chris@16 18 #include <iosfwd>
Chris@16 19 #include <string>
Chris@16 20 #include <boost/assert.hpp>
Chris@16 21 #include <boost/cstdint.hpp>
Chris@16 22 #include <boost/log/detail/config.hpp>
Chris@16 23 #include <boost/utility/explicit_operator_bool.hpp>
Chris@16 24 #include <boost/log/detail/header.hpp>
Chris@16 25
Chris@16 26 #ifdef BOOST_HAS_PRAGMA_ONCE
Chris@16 27 #pragma once
Chris@16 28 #endif
Chris@16 29
Chris@16 30 namespace boost {
Chris@16 31
Chris@16 32 BOOST_LOG_OPEN_NAMESPACE
Chris@16 33
Chris@16 34 /*!
Chris@16 35 * \brief The class represents an attribute name in containers used by the library
Chris@16 36 *
Chris@16 37 * The class mostly serves for optimization purposes. Each attribute name that is used
Chris@16 38 * with the library is automatically associated with a unique identifier, which is much
Chris@16 39 * lighter in terms of memory footprint and operations complexity. This is done
Chris@16 40 * transparently by this class, on object construction. Passing objects of this class
Chris@16 41 * to other library methods, such as attribute lookup functions, will not require
Chris@16 42 * this translation and/or string copying and thus will result in a more efficient code.
Chris@16 43 */
Chris@16 44 class attribute_name
Chris@16 45 {
Chris@16 46 public:
Chris@16 47 //! String type
Chris@16 48 typedef std::string string_type;
Chris@16 49 #ifdef BOOST_LOG_DOXYGEN_PASS
Chris@16 50 //! Associated identifier
Chris@16 51 typedef unspecified id_type;
Chris@16 52 #else
Chris@16 53 typedef uint32_t id_type;
Chris@16 54
Chris@16 55 private:
Chris@16 56 enum { uninitialized = 0xFFFFFFFFu };
Chris@16 57
Chris@16 58 class repository;
Chris@16 59 friend class repository;
Chris@16 60
Chris@16 61 private:
Chris@16 62 //! Associated identifier
Chris@16 63 id_type m_id;
Chris@16 64 #endif
Chris@16 65
Chris@16 66 public:
Chris@16 67 /*!
Chris@16 68 * Default constructor. Creates an object that does not refer to any attribute name.
Chris@16 69 */
Chris@16 70 BOOST_CONSTEXPR attribute_name() BOOST_NOEXCEPT : m_id(static_cast< id_type >(uninitialized))
Chris@16 71 {
Chris@16 72 }
Chris@16 73 /*!
Chris@16 74 * Constructs an attribute name from the specified string
Chris@16 75 *
Chris@16 76 * \param name An attribute name
Chris@16 77 * \pre \a name is not NULL and points to a zero-terminated string
Chris@16 78 */
Chris@16 79 attribute_name(const char* name) :
Chris@16 80 m_id(get_id_from_string(name))
Chris@16 81 {
Chris@16 82 }
Chris@16 83 /*!
Chris@16 84 * Constructs an attribute name from the specified string
Chris@16 85 *
Chris@16 86 * \param name An attribute name
Chris@16 87 */
Chris@16 88 attribute_name(string_type const& name) :
Chris@16 89 m_id(get_id_from_string(name.c_str()))
Chris@16 90 {
Chris@16 91 }
Chris@16 92
Chris@16 93 /*!
Chris@16 94 * Compares the attribute names
Chris@16 95 *
Chris@16 96 * \return \c true if <tt>*this</tt> and \c that refer to the same attribute name,
Chris@16 97 * and \c false otherwise.
Chris@16 98 */
Chris@16 99 bool operator== (attribute_name const& that) const BOOST_NOEXCEPT { return m_id == that.m_id; }
Chris@16 100 /*!
Chris@16 101 * Compares the attribute names
Chris@16 102 *
Chris@16 103 * \return \c true if <tt>*this</tt> and \c that refer to different attribute names,
Chris@16 104 * and \c false otherwise.
Chris@16 105 */
Chris@16 106 bool operator!= (attribute_name const& that) const BOOST_NOEXCEPT { return m_id != that.m_id; }
Chris@16 107
Chris@16 108 /*!
Chris@16 109 * Compares the attribute names
Chris@16 110 *
Chris@16 111 * \return \c true if <tt>*this</tt> and \c that refer to the same attribute name,
Chris@16 112 * and \c false otherwise.
Chris@16 113 */
Chris@16 114 bool operator== (const char* that) const { return (m_id != static_cast< id_type >(uninitialized)) && (this->string() == that); }
Chris@16 115 /*!
Chris@16 116 * Compares the attribute names
Chris@16 117 *
Chris@16 118 * \return \c true if <tt>*this</tt> and \c that refer to different attribute names,
Chris@16 119 * and \c false otherwise.
Chris@16 120 */
Chris@16 121 bool operator!= (const char* that) const { return !operator== (that); }
Chris@16 122
Chris@16 123 /*!
Chris@16 124 * Compares the attribute names
Chris@16 125 *
Chris@16 126 * \return \c true if <tt>*this</tt> and \c that refer to the same attribute name,
Chris@16 127 * and \c false otherwise.
Chris@16 128 */
Chris@16 129 bool operator== (string_type const& that) const { return (m_id != static_cast< id_type >(uninitialized)) && (this->string() == that); }
Chris@16 130 /*!
Chris@16 131 * Compares the attribute names
Chris@16 132 *
Chris@16 133 * \return \c true if <tt>*this</tt> and \c that refer to different attribute names,
Chris@16 134 * and \c false otherwise.
Chris@16 135 */
Chris@16 136 bool operator!= (string_type const& that) const { return !operator== (that); }
Chris@16 137
Chris@16 138 /*!
Chris@16 139 * Checks if the object was default-constructed
Chris@16 140 *
Chris@16 141 * \return \c true if <tt>*this</tt> was constructed with an attribute name, \c false otherwise
Chris@16 142 */
Chris@101 143 BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
Chris@16 144 /*!
Chris@16 145 * Checks if the object was default-constructed
Chris@16 146 *
Chris@16 147 * \return \c true if <tt>*this</tt> was default-constructed and does not refer to any attribute name,
Chris@16 148 * \c false otherwise
Chris@16 149 */
Chris@16 150 bool operator! () const BOOST_NOEXCEPT { return (m_id == static_cast< id_type >(uninitialized)); }
Chris@16 151
Chris@16 152 /*!
Chris@16 153 * \return The associated id value
Chris@16 154 * \pre <tt>(!*this) == false</tt>
Chris@16 155 */
Chris@16 156 id_type id() const BOOST_NOEXCEPT
Chris@16 157 {
Chris@16 158 BOOST_ASSERT(m_id != static_cast< id_type >(uninitialized));
Chris@16 159 return m_id;
Chris@16 160 }
Chris@16 161 /*!
Chris@16 162 * \return The attribute name string that was used during the object construction
Chris@16 163 * \pre <tt>(!*this) == false</tt>
Chris@16 164 */
Chris@16 165 string_type const& string() const { return get_string_from_id(m_id); }
Chris@16 166
Chris@16 167 private:
Chris@16 168 #ifndef BOOST_LOG_DOXYGEN_PASS
Chris@16 169 static BOOST_LOG_API id_type get_id_from_string(const char* name);
Chris@16 170 static BOOST_LOG_API string_type const& get_string_from_id(id_type id);
Chris@16 171 #endif
Chris@16 172 };
Chris@16 173
Chris@16 174 template< typename CharT, typename TraitsT >
Chris@16 175 BOOST_LOG_API std::basic_ostream< CharT, TraitsT >& operator<< (
Chris@16 176 std::basic_ostream< CharT, TraitsT >& strm,
Chris@16 177 attribute_name const& name);
Chris@16 178
Chris@16 179 BOOST_LOG_CLOSE_NAMESPACE // namespace log
Chris@16 180
Chris@16 181 } // namespace boost
Chris@16 182
Chris@16 183 #include <boost/log/detail/footer.hpp>
Chris@16 184
Chris@16 185 #endif // BOOST_LOG_ATTRIBUTE_NAME_HPP_INCLUDED_