updated boost on windows
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <algorithm> // for find
|
||||
#include <stdexcept>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#ifdef BOOST_NO_STDC_NAMESPACE
|
||||
namespace std {
|
||||
@@ -32,8 +33,8 @@ namespace uuids {
|
||||
// and be more efficient
|
||||
// would like to accept the following forms:
|
||||
// 0123456789abcdef0123456789abcdef
|
||||
// 01234567-89ab-cdef-0123456789abcdef
|
||||
// {01234567-89ab-cdef-0123456789abcdef}
|
||||
// 01234567-89ab-cdef-0123-456789abcdef
|
||||
// {01234567-89ab-cdef-0123-456789abcdef}
|
||||
// {0123456789abcdef0123456789abcdef}
|
||||
// others?
|
||||
struct string_generator {
|
||||
@@ -81,8 +82,9 @@ struct string_generator {
|
||||
}
|
||||
}
|
||||
|
||||
if (has_dashes) {
|
||||
if (i == 6 || i == 8 || i == 10) {
|
||||
// if there are dashes, they must be in every slot
|
||||
else if (i == 6 || i == 8 || i == 10) {
|
||||
if (has_dashes == true) {
|
||||
if (is_dash(c)) {
|
||||
c = get_next_char(begin, end);
|
||||
} else {
|
||||
@@ -90,6 +92,7 @@ struct string_generator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*it_byte = get_value(c);
|
||||
|
||||
@@ -103,6 +106,11 @@ struct string_generator {
|
||||
c = get_next_char(begin, end);
|
||||
check_close_brace(c, open_brace_char);
|
||||
}
|
||||
|
||||
// check end of string - any additional data is an invalid uuid
|
||||
if (begin != end) {
|
||||
throw_invalid();
|
||||
}
|
||||
|
||||
return u;
|
||||
}
|
||||
@@ -118,27 +126,33 @@ private:
|
||||
}
|
||||
|
||||
unsigned char get_value(char c) const {
|
||||
static char const*const digits_begin = "0123456789abcdefABCDEF";
|
||||
static char const*const digits_end = digits_begin + 22;
|
||||
static char const digits_begin[] = "0123456789abcdefABCDEF";
|
||||
static size_t digits_len = (sizeof(digits_begin) / sizeof(char)) - 1;
|
||||
static char const*const digits_end = digits_begin + digits_len;
|
||||
|
||||
static unsigned char const values[] =
|
||||
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15
|
||||
, static_cast<unsigned char>(-1) };
|
||||
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15 };
|
||||
|
||||
char const* d = std::find(digits_begin, digits_end, c);
|
||||
return values[d - digits_begin];
|
||||
size_t pos = std::find(digits_begin, digits_end, c) - digits_begin;
|
||||
if (pos >= digits_len) {
|
||||
throw_invalid();
|
||||
}
|
||||
return values[pos];
|
||||
}
|
||||
|
||||
unsigned char get_value(wchar_t c) const {
|
||||
static wchar_t const*const digits_begin = L"0123456789abcdefABCDEF";
|
||||
static wchar_t const*const digits_end = digits_begin + 22;
|
||||
static wchar_t const digits_begin[] = L"0123456789abcdefABCDEF";
|
||||
static size_t digits_len = (sizeof(digits_begin) / sizeof(wchar_t)) - 1;
|
||||
static wchar_t const*const digits_end = digits_begin + digits_len;
|
||||
|
||||
static unsigned char const values[] =
|
||||
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15
|
||||
, static_cast<unsigned char>(-1) };
|
||||
{ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,10,11,12,13,14,15 };
|
||||
|
||||
wchar_t const* d = std::find(digits_begin, digits_end, c);
|
||||
return values[d - digits_begin];
|
||||
size_t pos = std::find(digits_begin, digits_end, c) - digits_begin;
|
||||
if (pos >= digits_len) {
|
||||
throw_invalid();
|
||||
}
|
||||
return values[pos];
|
||||
}
|
||||
|
||||
bool is_dash(char c) const {
|
||||
@@ -174,7 +188,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void throw_invalid() const {
|
||||
BOOST_NORETURN void throw_invalid() const {
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("invalid uuid string"));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user