Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/uuid/detail/to_chars.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef BOOST_UUID_DETAIL_TO_CHARS_HPP_INCLUDED
0002 #define BOOST_UUID_DETAIL_TO_CHARS_HPP_INCLUDED
0003 
0004 // Copyright 2009 Andy Tompkins
0005 // Copyright 2024 Peter Dimov
0006 // Distributed under the Boost Software License, Version 1.0.
0007 // https://www.boost.org/LICENSE_1_0.txt
0008 
0009 #include <boost/uuid/uuid.hpp>
0010 
0011 namespace boost {
0012 namespace uuids {
0013 namespace detail {
0014 
0015 constexpr char const* digits( char const* ) noexcept
0016 {
0017     return "0123456789abcdef-";
0018 }
0019 
0020 constexpr wchar_t const* digits( wchar_t const* ) noexcept
0021 {
0022     return L"0123456789abcdef-";
0023 }
0024 
0025 constexpr char16_t const* digits( char16_t const* ) noexcept
0026 {
0027     return u"0123456789abcdef-";
0028 }
0029 
0030 constexpr char32_t const* digits( char32_t const* ) noexcept
0031 {
0032     return U"0123456789abcdef-";
0033 }
0034 
0035 #if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
0036 
0037 constexpr char8_t const* digits( char8_t const* ) noexcept
0038 {
0039     return u8"0123456789abcdef-";
0040 }
0041 
0042 #endif
0043 
0044 template<class Ch> inline Ch* to_chars( uuid const& u, Ch* out ) noexcept
0045 {
0046     constexpr Ch const* p = digits( static_cast<Ch const*>( nullptr ) );
0047 
0048     for( std::size_t i = 0; i < 16; ++i )
0049     {
0050         std::uint8_t ch = u.data[ i ];
0051 
0052         *out++ = p[ (ch >> 4) & 0x0F ];
0053         *out++ = p[ ch & 0x0F ];
0054 
0055         if( i == 3 || i == 5 || i == 7 || i == 9 )
0056         {
0057             *out++ = p[ 16 ];
0058         }
0059     }
0060 
0061     return out;
0062 }
0063 
0064 } // namespace detail
0065 }} //namespace boost::uuids
0066 
0067 #endif // BOOST_UUID_DETAIL_TO_CHARS_HPP_INCLUDED