File indexing completed on 2025-01-18 09:53:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #ifndef BOOST_UUID_HPP
0034 #define BOOST_UUID_HPP
0035
0036 #include <cstddef>
0037 #include <boost/cstdint.hpp>
0038 #include <boost/uuid/detail/config.hpp>
0039 #ifndef BOOST_UUID_NO_TYPE_TRAITS
0040 #include <boost/type_traits/is_pod.hpp>
0041 #include <boost/type_traits/integral_constant.hpp>
0042 #endif
0043
0044 #ifdef BOOST_HAS_PRAGMA_ONCE
0045 #pragma once
0046 #endif
0047
0048 #if defined(_MSC_VER)
0049 #pragma warning(push)
0050 #pragma warning(disable : 4996)
0051 #endif
0052
0053 #ifdef BOOST_NO_STDC_NAMESPACE
0054 namespace std {
0055 using ::size_t;
0056 using ::ptrdiff_t;
0057 }
0058 #endif
0059
0060 namespace boost {
0061 namespace uuids {
0062
0063 struct uuid
0064 {
0065 public:
0066 typedef uint8_t value_type;
0067 typedef uint8_t& reference;
0068 typedef uint8_t const& const_reference;
0069 typedef uint8_t* iterator;
0070 typedef uint8_t const* const_iterator;
0071 typedef std::size_t size_type;
0072 typedef std::ptrdiff_t difference_type;
0073
0074
0075
0076
0077
0078 static BOOST_CONSTEXPR size_type static_size() BOOST_NOEXCEPT { return 16; }
0079
0080 public:
0081 iterator begin() BOOST_NOEXCEPT { return data; }
0082 const_iterator begin() const BOOST_NOEXCEPT { return data; }
0083 iterator end() BOOST_NOEXCEPT { return data+size(); }
0084 const_iterator end() const BOOST_NOEXCEPT { return data+size(); }
0085
0086 BOOST_CONSTEXPR size_type size() const BOOST_NOEXCEPT { return static_size(); }
0087
0088 bool is_nil() const BOOST_NOEXCEPT;
0089
0090 enum variant_type
0091 {
0092 variant_ncs,
0093 variant_rfc_4122,
0094 variant_microsoft,
0095 variant_future
0096 };
0097 variant_type variant() const BOOST_NOEXCEPT
0098 {
0099
0100
0101 unsigned char octet7 = data[8];
0102 if ( (octet7 & 0x80) == 0x00 ) {
0103 return variant_ncs;
0104 } else if ( (octet7 & 0xC0) == 0x80 ) {
0105 return variant_rfc_4122;
0106 } else if ( (octet7 & 0xE0) == 0xC0 ) {
0107 return variant_microsoft;
0108 } else {
0109
0110 return variant_future;
0111 }
0112 }
0113
0114 enum version_type
0115 {
0116 version_unknown = -1,
0117 version_time_based = 1,
0118 version_dce_security = 2,
0119 version_name_based_md5 = 3,
0120 version_random_number_based = 4,
0121 version_name_based_sha1 = 5
0122 };
0123 version_type version() const BOOST_NOEXCEPT
0124 {
0125
0126
0127 uint8_t octet9 = data[6];
0128 if ( (octet9 & 0xF0) == 0x10 ) {
0129 return version_time_based;
0130 } else if ( (octet9 & 0xF0) == 0x20 ) {
0131 return version_dce_security;
0132 } else if ( (octet9 & 0xF0) == 0x30 ) {
0133 return version_name_based_md5;
0134 } else if ( (octet9 & 0xF0) == 0x40 ) {
0135 return version_random_number_based;
0136 } else if ( (octet9 & 0xF0) == 0x50 ) {
0137 return version_name_based_sha1;
0138 } else {
0139 return version_unknown;
0140 }
0141 }
0142
0143
0144 void swap(uuid& rhs) BOOST_NOEXCEPT;
0145
0146 public:
0147
0148 uint8_t data[16];
0149 };
0150
0151 bool operator== (uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT;
0152 bool operator< (uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT;
0153
0154 inline bool operator!=(uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT
0155 {
0156 return !(lhs == rhs);
0157 }
0158
0159 inline bool operator>(uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT
0160 {
0161 return rhs < lhs;
0162 }
0163 inline bool operator<=(uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT
0164 {
0165 return !(rhs < lhs);
0166 }
0167
0168 inline bool operator>=(uuid const& lhs, uuid const& rhs) BOOST_NOEXCEPT
0169 {
0170 return !(lhs < rhs);
0171 }
0172
0173 inline void swap(uuid& lhs, uuid& rhs) BOOST_NOEXCEPT
0174 {
0175 lhs.swap(rhs);
0176 }
0177
0178
0179 inline std::size_t hash_value(uuid const& u) BOOST_NOEXCEPT
0180 {
0181 std::size_t seed = 0;
0182 for(uuid::const_iterator i=u.begin(), e=u.end(); i != e; ++i)
0183 {
0184 seed ^= static_cast<std::size_t>(*i) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
0185 }
0186
0187 return seed;
0188 }
0189
0190 }}
0191
0192 #ifndef BOOST_UUID_NO_TYPE_TRAITS
0193
0194 namespace boost {
0195
0196 template <>
0197 struct is_pod<uuids::uuid> : true_type {};
0198
0199 }
0200 #endif
0201
0202 #if defined(BOOST_UUID_USE_SSE2)
0203 #include <boost/uuid/detail/uuid_x86.ipp>
0204 #else
0205 #include <boost/uuid/detail/uuid_generic.ipp>
0206 #endif
0207
0208 #if defined(_MSC_VER)
0209 #pragma warning(pop)
0210 #endif
0211
0212 #endif