diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-11-24 20:33:19 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-11-24 20:35:17 (GMT) |
commit | 332d60c56dfaa11fdd135088279d15cd5983b3d4 (patch) | |
tree | dd77717a4e1732da929d5ff8a0471fa3f005e201 /3rdParty/Boost/src/boost/uuid | |
parent | 90c44a10fec26d2a0935b2d62e82b6a5be028373 (diff) | |
download | swift-contrib-332d60c56dfaa11fdd135088279d15cd5983b3d4.zip swift-contrib-332d60c56dfaa11fdd135088279d15cd5983b3d4.tar.bz2 |
Upgraded Boost to 1.45.0.
Diffstat (limited to '3rdParty/Boost/src/boost/uuid')
-rw-r--r-- | 3rdParty/Boost/src/boost/uuid/uuid.hpp | 9 | ||||
-rw-r--r-- | 3rdParty/Boost/src/boost/uuid/uuid_io.hpp | 81 |
2 files changed, 86 insertions, 4 deletions
diff --git a/3rdParty/Boost/src/boost/uuid/uuid.hpp b/3rdParty/Boost/src/boost/uuid/uuid.hpp index ceebd4d..2678d85 100644 --- a/3rdParty/Boost/src/boost/uuid/uuid.hpp +++ b/3rdParty/Boost/src/boost/uuid/uuid.hpp @@ -37,8 +37,10 @@ #include <boost/cstdint.hpp> #include <algorithm> #include <boost/config.hpp> // for static assert -#include <boost/mpl/bool.hpp> +#ifndef BOOST_UUID_NO_TYPE_TRAITS #include <boost/type_traits/is_pod.hpp> +#include <boost/type_traits/integral_constant.hpp> +#endif #if defined(_MSC_VER) #pragma warning(push) // Save warning settings. @@ -202,14 +204,15 @@ inline std::size_t hash_value(uuid const& u) /* throw() */ }} //namespace boost::uuids +#ifndef BOOST_UUID_NO_TYPE_TRAITS // type traits specializations namespace boost { template <> -struct is_pod<uuids::uuid> : mpl::true_ -{}; +struct is_pod<uuids::uuid> : true_type {}; } // namespace boost +#endif #if defined(_MSC_VER) #pragma warning(pop) // Restore warnings to previous state. diff --git a/3rdParty/Boost/src/boost/uuid/uuid_io.hpp b/3rdParty/Boost/src/boost/uuid/uuid_io.hpp index c2b050f..592a509 100644 --- a/3rdParty/Boost/src/boost/uuid/uuid_io.hpp +++ b/3rdParty/Boost/src/boost/uuid/uuid_io.hpp @@ -32,11 +32,20 @@ template <typename ch, typename char_traits> std::basic_ostream<ch, char_traits>& operator<<(std::basic_ostream<ch, char_traits> &os, uuid const& u) { io::ios_flags_saver flags_saver(os); - io::ios_width_saver width_saver(os); io::basic_ios_fill_saver<ch, char_traits> fill_saver(os); const typename std::basic_ostream<ch, char_traits>::sentry ok(os); if (ok) { + const std::streamsize width = os.width(0); + const std::streamsize uuid_width = 36; + const std::ios_base::fmtflags flags = os.flags(); + const typename std::basic_ios<ch, char_traits>::char_type fill = os.fill(); + if (flags & (std::ios_base::right | std::ios_base::internal)) { + for (std::streamsize i=uuid_width; i<width; i++) { + os << fill; + } + } + os << std::hex; os.fill(os.widen('0')); @@ -48,6 +57,14 @@ template <typename ch, typename char_traits> os << os.widen('-'); } } + + if (flags & std::ios_base::left) { + for (std::streamsize i=uuid_width; i<width; i++) { + os << fill; + } + } + + os.width(0); //used the width so reset it } return os; } @@ -110,6 +127,68 @@ template <typename ch, typename char_traits> return is; } +namespace detail { +inline char to_char(size_t i) { + if (i <= 9) { + return static_cast<char>('0' + i); + } else { + return static_cast<char>('a' + (i-10)); + } +} + +inline wchar_t to_wchar(size_t i) { + if (i <= 9) { + return static_cast<wchar_t>(L'0' + i); + } else { + return static_cast<wchar_t>(L'a' + (i-10)); + } +} + +} // namespace detail + +inline std::string to_string(uuid const& u) +{ + std::string result; + result.reserve(36); + + std::size_t i=0; + for (uuid::const_iterator it_data = u.begin(); it_data!=u.end(); ++it_data, ++i) { + const size_t hi = ((*it_data) >> 4) & 0x0F; + result += detail::to_char(hi); + + const size_t lo = (*it_data) & 0x0F; + result += detail::to_char(lo); + + if (i == 3 || i == 5 || i == 7 || i == 9) { + result += '-'; + } + } + return result; +} + +#ifndef BOOST_NO_STD_WSTRING +inline std::wstring to_wstring(uuid const& u) +{ + std::wstring result; + result.reserve(36); + + std::size_t i=0; + for (uuid::const_iterator it_data = u.begin(); it_data!=u.end(); ++it_data, ++i) { + const size_t hi = ((*it_data) >> 4) & 0x0F; + result += detail::to_wchar(hi); + + const size_t lo = (*it_data) & 0x0F; + result += detail::to_wchar(lo); + + if (i == 3 || i == 5 || i == 7 || i == 9) { + result += L'-'; + } + } + return result; +} + +#endif + }} //namespace boost::uuids #if defined(_MSC_VER) |