File indexing completed on 2025-01-18 09:39:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_LOG_ATTRIBUTE_NAME_HPP_INCLUDED_
0016 #define BOOST_LOG_ATTRIBUTE_NAME_HPP_INCLUDED_
0017
0018 #include <iosfwd>
0019 #include <string>
0020 #include <boost/assert.hpp>
0021 #include <boost/cstdint.hpp>
0022 #include <boost/core/explicit_operator_bool.hpp>
0023 #include <boost/log/detail/config.hpp>
0024 #include <boost/log/detail/header.hpp>
0025
0026 #ifdef BOOST_HAS_PRAGMA_ONCE
0027 #pragma once
0028 #endif
0029
0030 namespace boost {
0031
0032 BOOST_LOG_OPEN_NAMESPACE
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 class attribute_name
0045 {
0046 public:
0047
0048 typedef std::string string_type;
0049 #ifdef BOOST_LOG_DOXYGEN_PASS
0050
0051 typedef unspecified id_type;
0052 #else
0053 typedef uint32_t id_type;
0054
0055 private:
0056 class repository;
0057 friend class repository;
0058
0059 private:
0060
0061 id_type m_id;
0062
0063 static BOOST_CONSTEXPR_OR_CONST id_type uninitialized = ~static_cast< id_type >(0u);
0064 #endif
0065
0066 public:
0067
0068
0069
0070 BOOST_CONSTEXPR attribute_name() BOOST_NOEXCEPT : m_id(uninitialized)
0071 {
0072 }
0073
0074
0075
0076
0077
0078
0079 attribute_name(const char* name) :
0080 m_id(get_id_from_string(name))
0081 {
0082 }
0083
0084
0085
0086
0087
0088 attribute_name(string_type const& name) :
0089 m_id(get_id_from_string(name.c_str()))
0090 {
0091 }
0092
0093
0094
0095
0096
0097
0098
0099 bool operator== (attribute_name const& that) const BOOST_NOEXCEPT { return m_id == that.m_id; }
0100
0101
0102
0103
0104
0105
0106 bool operator!= (attribute_name const& that) const BOOST_NOEXCEPT { return m_id != that.m_id; }
0107
0108
0109
0110
0111
0112
0113
0114 bool operator== (const char* that) const { return (m_id != uninitialized) && (this->string() == that); }
0115
0116
0117
0118
0119
0120
0121 bool operator!= (const char* that) const { return !operator== (that); }
0122
0123
0124
0125
0126
0127
0128
0129 bool operator== (string_type const& that) const { return (m_id != uninitialized) && (this->string() == that); }
0130
0131
0132
0133
0134
0135
0136 bool operator!= (string_type const& that) const { return !operator== (that); }
0137
0138
0139
0140
0141
0142
0143 BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
0144
0145
0146
0147
0148
0149
0150 bool operator! () const BOOST_NOEXCEPT { return (m_id == uninitialized); }
0151
0152
0153
0154
0155
0156 id_type id() const BOOST_NOEXCEPT
0157 {
0158 BOOST_ASSERT(m_id != uninitialized);
0159 return m_id;
0160 }
0161
0162
0163
0164
0165 string_type const& string() const { return get_string_from_id(m_id); }
0166
0167 private:
0168 #ifndef BOOST_LOG_DOXYGEN_PASS
0169 static BOOST_LOG_API id_type get_id_from_string(const char* name);
0170 static BOOST_LOG_API string_type const& get_string_from_id(id_type id);
0171 #endif
0172 };
0173
0174 template< typename CharT, typename TraitsT >
0175 BOOST_LOG_API std::basic_ostream< CharT, TraitsT >& operator<< (
0176 std::basic_ostream< CharT, TraitsT >& strm,
0177 attribute_name const& name);
0178
0179 BOOST_LOG_CLOSE_NAMESPACE
0180
0181 }
0182
0183 #include <boost/log/detail/footer.hpp>
0184
0185 #endif