add user-defined literals _uuid3, _uuid5

This commit is contained in:
bolero-MURAKAMI 2013-04-14 19:42:34 +09:00
parent 94b146b5cc
commit 35e651d144
10 changed files with 521 additions and 10 deletions

View file

@ -231,11 +231,11 @@ namespace sprout {
} \ } \
inline SPROUT_CONSTEXPR CHAR_TYPE \ inline SPROUT_CONSTEXPR CHAR_TYPE \
SPROUT_PP_CAT(to, SPROUT_PP_CAT(PREFIX, lower))(CHAR_TYPE c) { \ SPROUT_PP_CAT(to, SPROUT_PP_CAT(PREFIX, lower))(CHAR_TYPE c) { \
return sprout::ascii::detail::get_value(c) & sprout::ascii::detail::lower ? c + (0x61 - 0x41) : c; \ return sprout::ascii::detail::get_value(c) & sprout::ascii::detail::upper ? c + (0x61 - 0x41) : c; \
} \ } \
inline SPROUT_CONSTEXPR CHAR_TYPE \ inline SPROUT_CONSTEXPR CHAR_TYPE \
SPROUT_PP_CAT(to, SPROUT_PP_CAT(PREFIX, upper))(CHAR_TYPE c) { \ SPROUT_PP_CAT(to, SPROUT_PP_CAT(PREFIX, upper))(CHAR_TYPE c) { \
return sprout::ascii::detail::get_value(c) & sprout::ascii::detail::upper ? c - (0x61 - 0x41) : c; \ return sprout::ascii::detail::get_value(c) & sprout::ascii::detail::lower ? c - (0x61 - 0x41) : c; \
} \ } \
inline SPROUT_CONSTEXPR bool \ inline SPROUT_CONSTEXPR bool \
SPROUT_PP_CAT(is, SPROUT_PP_CAT(PREFIX, classified))(sprout::ctypes::mask_t m, CHAR_TYPE c) { \ SPROUT_PP_CAT(is, SPROUT_PP_CAT(PREFIX, classified))(sprout::ctypes::mask_t m, CHAR_TYPE c) { \

View file

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/ctype/mask.hpp> #include <sprout/ctype/mask.hpp>
#include <sprout/ctype/ascii.hpp> #include <sprout/ctype/ascii.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout { namespace sprout {
namespace ctypes { namespace ctypes {
@ -402,6 +403,58 @@ namespace sprout {
return sprout::ctypes::is_classified<T>(m_)(x); return sprout::ctypes::is_classified<T>(m_)(x);
} }
}; };
//
// nocase_equal_to
//
template<typename T = void>
struct nocase_equal_to {
public:
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
public:
SPROUT_CONSTEXPR bool operator()(T const& x, T const& y) const {
return sprout::tolower(x) == sprout::tolower(y);
}
};
template<>
struct nocase_equal_to<void> {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(sprout::tolower(std::declval<T>()) == sprout::tolower(std::declval<U>()))
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tolower(std::declval<T>()) == sprout::tolower(std::declval<U>())))
{
return sprout::tolower(sprout::forward<T>(x)) == sprout::tolower(sprout::forward<U>(y));
}
};
//
// nocase_not_equal_to
//
template<typename T = void>
struct nocase_not_equal_to {
public:
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
public:
SPROUT_CONSTEXPR bool operator()(T const& x, T const& y) const {
return sprout::tolower(x) != sprout::tolower(y);
}
};
template<>
struct nocase_not_equal_to<void> {
public:
template<typename T, typename U>
SPROUT_CONSTEXPR decltype(sprout::tolower(std::declval<T>()) != sprout::tolower(std::declval<U>()))
operator()(T&& x, U&& y)
const SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tolower(std::declval<T>()) != sprout::tolower(std::declval<U>())))
{
return sprout::tolower(sprout::forward<T>(x)) != sprout::tolower(sprout::forward<U>(y));
}
};
} // namespace ctypes } // namespace ctypes
} // namespace sprout } // namespace sprout

View file

@ -7,6 +7,7 @@
#include <sprout/uuid/hash.hpp> #include <sprout/uuid/hash.hpp>
#include <sprout/uuid/tuple.hpp> #include <sprout/uuid/tuple.hpp>
#include <sprout/uuid/generators.hpp> #include <sprout/uuid/generators.hpp>
#include <sprout/uuid/namespaces.hpp>
#include <sprout/uuid/udl.hpp> #include <sprout/uuid/udl.hpp>
#endif // #ifndef SPROUT_UUID_HPP #endif // #ifndef SPROUT_UUID_HPP

View file

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/string.hpp> #include <sprout/string.hpp>
#include <sprout/uuid/uuid.hpp> #include <sprout/uuid/uuid.hpp>
#include <sprout/uuid/namespaces.hpp>
#include <sprout/checksum/md5.hpp> #include <sprout/checksum/md5.hpp>
namespace sprout { namespace sprout {
@ -66,6 +67,85 @@ namespace sprout {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char32_t>::length(name))); return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char32_t>::length(name)));
} }
}; };
//
// make_uuid3
//
template<typename Elem, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(sprout::basic_string<Elem, N, Traits> const& name) {
return sprout::uuids::md5_name_generator()(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(char const* name) {
return sprout::uuids::md5_name_generator()(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(wchar_t const* name) {
return sprout::uuids::md5_name_generator()(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(char16_t const* name) {
return sprout::uuids::md5_name_generator()(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(char32_t const* name) {
return sprout::uuids::md5_name_generator()(name);
}
template<typename Elem, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(sprout::uuids::uuid const& namespace_uuid, sprout::basic_string<Elem, N, Traits> const& name) {
return sprout::uuids::md5_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(sprout::uuids::uuid const& namespace_uuid, char const* name) {
return sprout::uuids::md5_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(sprout::uuids::uuid const& namespace_uuid, wchar_t const* name) {
return sprout::uuids::md5_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(sprout::uuids::uuid const& namespace_uuid, char16_t const* name) {
return sprout::uuids::md5_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid3(sprout::uuids::uuid const& namespace_uuid, char32_t const* name) {
return sprout::uuids::md5_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
make_uuid3() {
return sprout::uuids::md5_name_generator();
}
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
make_uuid3(sprout::uuids::uuid const& namespace_uuid) {
return sprout::uuids::md5_name_generator(namespace_uuid);
}
//
// make_uuid3_dns
// make_uuid3_url
// make_uuid3_oid
// make_uuid3_x500
//
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
make_uuid3_dns() {
return sprout::uuids::md5_name_generator(sprout::uuids::namespace_dns_uuid());
}
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
make_uuid3_url() {
return sprout::uuids::md5_name_generator(sprout::uuids::namespace_url_uuid());
}
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
make_uuid3_oid() {
return sprout::uuids::md5_name_generator(sprout::uuids::namespace_oid_uuid());
}
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
make_uuid3_x500() {
return sprout::uuids::md5_name_generator(sprout::uuids::namespace_x500_uuid());
}
} // namespace uuids } // namespace uuids
} // namespace sprout } // namespace sprout

View file

@ -0,0 +1,64 @@
#ifndef SPROUT_UUID_NAMESPACES_HPP
#define SPROUT_UUID_NAMESPACES_HPP
#include <sprout/config.hpp>
#include <sprout/uuid/uuid.hpp>
namespace sprout {
namespace uuids {
//
// namespace_dns_uuid
//
inline SPROUT_CONSTEXPR sprout::uuids::uuid
namespace_dns_uuid() {
return sprout::uuids::uuid{{
0x6b, 0xa7, 0xb8, 0x10,
0x9d, 0xad,
0x11, 0xd1,
0x80, 0xb4,
0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8
}};
}
//
// namespace_url_uuid
//
inline SPROUT_CONSTEXPR sprout::uuids::uuid
namespace_url_uuid() {
return sprout::uuids::uuid{{
0x6b, 0xa7, 0xb8, 0x11,
0x9d, 0xad,
0x11, 0xd1,
0x80, 0xb4,
0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8
}};
}
//
// namespace_oid_uuid
//
inline SPROUT_CONSTEXPR sprout::uuids::uuid
namespace_oid_uuid() {
return sprout::uuids::uuid{{
0x6b, 0xa7, 0xb8, 0x12,
0x9d, 0xad,
0x11, 0xd1,
0x80, 0xb4,
0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8
}};
}
//
// namespace_x500_uuid
//
inline SPROUT_CONSTEXPR sprout::uuids::uuid
namespace_x500_uuid() {
return sprout::uuids::uuid{{
0x6b, 0xa7, 0xb8, 0x14,
0x9d, 0xad,
0x11, 0xd1,
0x80, 0xb4,
0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8
}};
}
} // namespace uuids
} // namespace sprout
#endif // #ifndef SPROUT_UUID_NAMESPACES_HPP

View file

@ -17,6 +17,7 @@ namespace sprout {
return result_type{{0}}; return result_type{{0}};
} }
}; };
// //
// nil_uuid // nil_uuid
// //

View file

@ -15,7 +15,7 @@ namespace sprout {
// //
// basic_random_generator // basic_random_generator
// //
template<typename UniformRandomNumberGenerator> template<typename UniformRandomNumberGenerator = sprout::random::default_random_engine>
class basic_random_generator { class basic_random_generator {
public: public:
typedef sprout::uuids::uuid result_type; typedef sprout::uuids::uuid result_type;
@ -68,14 +68,16 @@ namespace sprout {
SPROUT_CONSTEXPR typename std::enable_if< SPROUT_CONSTEXPR typename std::enable_if<
std::is_integral<T>::value, std::is_integral<T>::value,
result_type result_type
>::type operator()(T const& seed) const { >::type
operator()(T const& seed) const {
return operator()(engine_type(seed)); return operator()(engine_type(seed));
} }
template<typename Engine> template<typename Engine>
SPROUT_CONSTEXPR typename std::enable_if< SPROUT_CONSTEXPR typename std::enable_if<
!std::is_integral<Engine>::value, !std::is_integral<Engine>::value,
result_type result_type
>::type operator()(Engine const& engine) const { >::type
operator()(Engine const& engine) const {
return random_to_uuid(sprout::random::combine(engine, distribution_)()); return random_to_uuid(sprout::random::combine(engine, distribution_)());
} }
}; };
@ -83,7 +85,27 @@ namespace sprout {
// //
// random_generator // random_generator
// //
typedef sprout::uuids::basic_random_generator<sprout::random::default_random_engine> random_generator; typedef sprout::uuids::basic_random_generator<> random_generator;
//
// make_uuid4
//
template<typename T>
SPROUT_CONSTEXPR typename std::enable_if<
std::is_integral<T>::value,
sprout::uuids::uuid
>::type
make_uuid4(T const& seed) {
return sprout::uuids::random_generator()(seed);
}
template<typename Engine>
SPROUT_CONSTEXPR typename std::enable_if<
!std::is_integral<Engine>::value,
sprout::uuids::uuid
>::type
make_uuid4(Engine const& engine) {
return sprout::uuids::random_generator()(engine);
}
} // namespace uuids } // namespace uuids
} // namespace sprout } // namespace sprout

View file

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/string.hpp> #include <sprout/string.hpp>
#include <sprout/uuid/uuid.hpp> #include <sprout/uuid/uuid.hpp>
#include <sprout/uuid/namespaces.hpp>
#include <sprout/checksum/sha1.hpp> #include <sprout/checksum/sha1.hpp>
namespace sprout { namespace sprout {
@ -66,6 +67,85 @@ namespace sprout {
return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char32_t>::length(name))); return sha_to_uuid(sum_.process_bytes(name, sprout::char_traits<char32_t>::length(name)));
} }
}; };
//
// make_uuid5
//
template<typename Elem, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(sprout::basic_string<Elem, N, Traits> const& name) {
return sprout::uuids::sha1_name_generator()(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(char const* name) {
return sprout::uuids::sha1_name_generator()(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(wchar_t const* name) {
return sprout::uuids::sha1_name_generator()(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(char16_t const* name) {
return sprout::uuids::sha1_name_generator()(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(char32_t const* name) {
return sprout::uuids::sha1_name_generator()(name);
}
template<typename Elem, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(sprout::uuids::uuid const& namespace_uuid, sprout::basic_string<Elem, N, Traits> const& name) {
return sprout::uuids::sha1_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(sprout::uuids::uuid const& namespace_uuid, char const* name) {
return sprout::uuids::sha1_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(sprout::uuids::uuid const& namespace_uuid, wchar_t const* name) {
return sprout::uuids::sha1_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(sprout::uuids::uuid const& namespace_uuid, char16_t const* name) {
return sprout::uuids::sha1_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid5(sprout::uuids::uuid const& namespace_uuid, char32_t const* name) {
return sprout::uuids::sha1_name_generator(namespace_uuid)(name);
}
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
make_uuid5() {
return sprout::uuids::sha1_name_generator();
}
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
make_uuid5(sprout::uuids::uuid const& namespace_uuid) {
return sprout::uuids::sha1_name_generator(namespace_uuid);
}
//
// make_uuid5_dns
// make_uuid5_url
// make_uuid5_oid
// make_uuid5_x500
//
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
make_uuid5_dns() {
return sprout::uuids::sha1_name_generator(sprout::uuids::namespace_dns_uuid());
}
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
make_uuid5_url() {
return sprout::uuids::sha1_name_generator(sprout::uuids::namespace_url_uuid());
}
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
make_uuid5_oid() {
return sprout::uuids::sha1_name_generator(sprout::uuids::namespace_oid_uuid());
}
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
make_uuid5_x500() {
return sprout::uuids::sha1_name_generator(sprout::uuids::namespace_x500_uuid());
}
} // namespace uuids } // namespace uuids
} // namespace sprout } // namespace sprout

View file

@ -197,6 +197,36 @@ namespace sprout {
return operator()(s, s + sprout::char_traits<char32_t>::length(s)); return operator()(s, s + sprout::char_traits<char32_t>::length(s));
} }
}; };
//
// make_uuid
//
template<typename Iterator>
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid(Iterator first, Iterator last) {
return sprout::uuids::string_generator()(first, last);
}
template<typename Elem, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid(sprout::basic_string<Elem, N, Traits> const& s) {
return sprout::uuids::string_generator()(s);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid(char const* s) {
return sprout::uuids::string_generator()(s);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid(wchar_t const* s) {
return sprout::uuids::string_generator()(s);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid(char16_t const* s) {
return sprout::uuids::string_generator()(s);
}
inline SPROUT_CONSTEXPR sprout::uuids::uuid
make_uuid(char32_t const* s) {
return sprout::uuids::string_generator()(s);
}
} // namespace uuids } // namespace uuids
} // namespace sprout } // namespace sprout

View file

@ -7,44 +7,224 @@
#if SPROUT_USE_USER_DEFINED_LITERALS #if SPROUT_USE_USER_DEFINED_LITERALS
#include <cstddef> #include <cstddef>
#include <type_traits>
#include <sprout/string.hpp>
#include <sprout/uuid/string_generator.hpp> #include <sprout/uuid/string_generator.hpp>
#include <sprout/uuid/name_generator.hpp>
#include <sprout/ctype/functor.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/container/metafunctions.hpp>
#include <sprout/range/algorithm/equal.hpp>
#include <sprout/range/ptr_range.hpp>
namespace sprout { namespace sprout {
namespace uuids { namespace uuids {
namespace detail {
template<typename T>
inline SPROUT_CONSTEXPR sprout::basic_string<T, 3>
dns_token();
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char, 3>
dns_token<char>() {
return sprout::to_string("dns");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, 3>
dns_token<wchar_t>() {
return sprout::to_string(L"dns");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, 3>
dns_token<char16_t>() {
return sprout::to_string(u"dns");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, 3>
dns_token<char32_t>() {
return sprout::to_string(U"dns");
}
template<typename T>
inline SPROUT_CONSTEXPR sprout::basic_string<T, 3>
url_token();
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char, 3>
url_token<char>() {
return sprout::to_string("url");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, 3>
url_token<wchar_t>() {
return sprout::to_string(L"url");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, 3>
url_token<char16_t>() {
return sprout::to_string(u"url");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, 3>
url_token<char32_t>() {
return sprout::to_string(U"url");
}
template<typename T>
inline SPROUT_CONSTEXPR sprout::basic_string<T, 3>
oid_token();
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char, 3>
oid_token<char>() {
return sprout::to_string("oid");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, 3>
oid_token<wchar_t>() {
return sprout::to_string(L"oid");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, 3>
oid_token<char16_t>() {
return sprout::to_string(u"oid");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, 3>
oid_token<char32_t>() {
return sprout::to_string(U"oid");
}
template<typename T>
inline SPROUT_CONSTEXPR sprout::basic_string<T, 4>
x500_token();
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char, 4>
x500_token<char>() {
return sprout::to_string("x500");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<wchar_t, 4>
x500_token<wchar_t>() {
return sprout::to_string(L"x500");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char16_t, 4>
x500_token<char16_t>() {
return sprout::to_string(u"x500");
}
template<>
inline SPROUT_CONSTEXPR sprout::basic_string<char32_t, 4>
x500_token<char32_t>() {
return sprout::to_string(U"x500");
}
template<typename Range>
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
uuid3_impl(Range const& rng) {
typedef typename std::decay<typename sprout::containers::value_type<Range>::type>::type value_type;
typedef sprout::ctypes::nocase_equal_to<value_type> predicate_type;
return sprout::range::equal(rng, sprout::uuids::detail::dns_token<value_type>(), predicate_type()) ? sprout::uuids::make_uuid3_dns()
: sprout::range::equal(rng, sprout::uuids::detail::url_token<value_type>(), predicate_type()) ? sprout::uuids::make_uuid3_url()
: sprout::range::equal(rng, sprout::uuids::detail::oid_token<value_type>(), predicate_type()) ? sprout::uuids::make_uuid3_oid()
: sprout::range::equal(rng, sprout::uuids::detail::x500_token<value_type>(), predicate_type()) ? sprout::uuids::make_uuid3_x500()
: sprout::uuids::make_uuid3(sprout::uuids::make_uuid(sprout::begin(rng), sprout::end(rng)))
;
}
template<typename Range>
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
uuid5_impl(Range const& rng) {
typedef typename std::decay<typename sprout::containers::value_type<Range>::type>::type value_type;
typedef sprout::ctypes::nocase_equal_to<value_type> predicate_type;
return sprout::range::equal(rng, sprout::uuids::detail::dns_token<value_type>(), predicate_type()) ? sprout::uuids::make_uuid5_dns()
: sprout::range::equal(rng, sprout::uuids::detail::url_token<value_type>(), predicate_type()) ? sprout::uuids::make_uuid5_url()
: sprout::range::equal(rng, sprout::uuids::detail::oid_token<value_type>(), predicate_type()) ? sprout::uuids::make_uuid5_oid()
: sprout::range::equal(rng, sprout::uuids::detail::x500_token<value_type>(), predicate_type()) ? sprout::uuids::make_uuid5_x500()
: sprout::uuids::make_uuid5(sprout::uuids::make_uuid(sprout::begin(rng), sprout::end(rng)))
;
}
} // namespace detail
namespace udl { namespace udl {
// //
// _uuid // _uuid
// //
inline SPROUT_CONSTEXPR sprout::uuids::uuid inline SPROUT_CONSTEXPR sprout::uuids::uuid
operator"" _uuid(char const* s, std::size_t size) { operator"" _uuid(char const* s, std::size_t size) {
return sprout::uuids::string_generator()(s, s + size); return sprout::uuids::make_uuid(s, s + size);
} }
inline SPROUT_CONSTEXPR sprout::uuids::uuid inline SPROUT_CONSTEXPR sprout::uuids::uuid
operator"" _uuid(wchar_t const* s, std::size_t size) { operator"" _uuid(wchar_t const* s, std::size_t size) {
return sprout::uuids::string_generator()(s, s + size); return sprout::uuids::make_uuid(s, s + size);
} }
inline SPROUT_CONSTEXPR sprout::uuids::uuid inline SPROUT_CONSTEXPR sprout::uuids::uuid
operator"" _uuid(char16_t const* s, std::size_t size) { operator"" _uuid(char16_t const* s, std::size_t size) {
return sprout::uuids::string_generator()(s, s + size); return sprout::uuids::make_uuid(s, s + size);
} }
inline SPROUT_CONSTEXPR sprout::uuids::uuid inline SPROUT_CONSTEXPR sprout::uuids::uuid
operator"" _uuid(char32_t const* s, std::size_t size) { operator"" _uuid(char32_t const* s, std::size_t size) {
return sprout::uuids::string_generator()(s, s + size); return sprout::uuids::make_uuid(s, s + size);
}
//
// _uuid3
//
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
operator"" _uuid3(char const* s, std::size_t size) {
return sprout::uuids::detail::uuid3_impl(sprout::range::make_ptr_range(s, size));
}
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
operator"" _uuid3(wchar_t const* s, std::size_t size) {
return sprout::uuids::detail::uuid3_impl(sprout::range::make_ptr_range(s, size));
}
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
operator"" _uuid3(char16_t const* s, std::size_t size) {
return sprout::uuids::detail::uuid3_impl(sprout::range::make_ptr_range(s, size));
}
inline SPROUT_CONSTEXPR sprout::uuids::md5_name_generator
operator"" _uuid3(char32_t const* s, std::size_t size) {
return sprout::uuids::detail::uuid3_impl(sprout::range::make_ptr_range(s, size));
}
//
// _uuid5
//
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
operator"" _uuid5(char const* s, std::size_t size) {
return sprout::uuids::detail::uuid5_impl(sprout::range::make_ptr_range(s, size));
}
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
operator"" _uuid5(wchar_t const* s, std::size_t size) {
return sprout::uuids::detail::uuid5_impl(sprout::range::make_ptr_range(s, size));
}
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
operator"" _uuid5(char16_t const* s, std::size_t size) {
return sprout::uuids::detail::uuid5_impl(sprout::range::make_ptr_range(s, size));
}
inline SPROUT_CONSTEXPR sprout::uuids::sha1_name_generator
operator"" _uuid5(char32_t const* s, std::size_t size) {
return sprout::uuids::detail::uuid5_impl(sprout::range::make_ptr_range(s, size));
} }
} // namespace udl } // namespace udl
using sprout::uuids::udl::operator"" _uuid; using sprout::uuids::udl::operator"" _uuid;
using sprout::uuids::udl::operator"" _uuid3;
using sprout::uuids::udl::operator"" _uuid5;
} // namespace uuids } // namespace uuids
namespace udl { namespace udl {
namespace uuids { namespace uuids {
using sprout::uuids::udl::operator"" _uuid; using sprout::uuids::udl::operator"" _uuid;
using sprout::uuids::udl::operator"" _uuid3;
using sprout::uuids::udl::operator"" _uuid5;
} // namespace uuids } // namespace uuids
using sprout::uuids::udl::operator"" _uuid; using sprout::uuids::udl::operator"" _uuid;
using sprout::uuids::udl::operator"" _uuid3;
using sprout::uuids::udl::operator"" _uuid5;
} // namespace udl } // namespace udl
using sprout::uuids::udl::operator"" _uuid; using sprout::uuids::udl::operator"" _uuid;
using sprout::uuids::udl::operator"" _uuid3;
using sprout::uuids::udl::operator"" _uuid5;
} // namespace sprout } // namespace sprout
#endif // #if SPROUT_USE_USER_DEFINED_LITERALS #endif // #if SPROUT_USE_USER_DEFINED_LITERALS