File indexing completed on 2025-04-26 08:55:46
0001 #ifndef BOOST_UUID_TIME_GENERATOR_V6_HPP_INCLUDED
0002 #define BOOST_UUID_TIME_GENERATOR_V6_HPP_INCLUDED
0003
0004
0005
0006
0007
0008 #include <boost/uuid/time_generator_v1.hpp>
0009 #include <boost/uuid/uuid.hpp>
0010 #include <boost/uuid/detail/endian.hpp>
0011
0012 namespace boost {
0013 namespace uuids {
0014
0015
0016
0017 class time_generator_v6: public time_generator_v1
0018 {
0019 public:
0020
0021 using result_type = uuid;
0022
0023 using time_generator_v1::time_generator_v1;
0024
0025 result_type operator()() noexcept;
0026 };
0027
0028
0029
0030 inline time_generator_v6::result_type time_generator_v6::operator()() noexcept
0031 {
0032 uuid result = time_generator_v1::operator()();
0033
0034 std::uint64_t timestamp = result.timestamp_v1();
0035
0036 std::uint32_t time_high = static_cast< std::uint32_t >( timestamp >> 28 );
0037
0038 detail::store_big_u32( result.data + 0, time_high );
0039
0040 std::uint16_t time_mid = static_cast< std::uint16_t >( timestamp >> 12 );
0041
0042 detail::store_big_u16( result.data + 4, time_mid );
0043
0044 std::uint16_t time_low_and_version = static_cast< std::uint16_t >( timestamp & 0xFFF ) | 0x6000;
0045
0046 detail::store_big_u16( result.data + 6, time_low_and_version );
0047
0048 return result;
0049 }
0050
0051 }}
0052
0053 #endif