20 #ifndef BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED
21 #define BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED
35 #include <boost/predef.h>
43 #pragma warning(disable: 4800)
44 #pragma warning(disable: 4804)
47 template <
class Int,
class FwdIt,
class Accumulator>
58 auto const c = *first++;
59 if (c < '0' || c >
'9')
61 if (!accumulator(num, Int(c -
'0')))
68 template <
class Int,
class FwdIt>
76 limit_digit = -limit_digit;
78 return parse_integral<Int> (num, first, last,
79 [limit_value, limit_digit](Int& value, Int digit)
81 assert ((digit >= 0) && (digit <= 9));
82 if (value < limit_value || (value == limit_value && digit > limit_digit))
84 value = (value * 10) - digit;
89 template <
class Int,
class FwdIt>
96 return parse_integral<Int> (num, first, last,
97 [limit_value, limit_digit](Int& value, Int digit)
99 assert ((digit >= 0) && (digit <= 9));
100 if (value > limit_value || (value == limit_value && digit > limit_digit))
102 value = (value * 10) + digit;
107 template <
class IntType,
class FwdIt>
112 "You may only call parseSigned with a signed integral type.");
114 if (first != last && *first ==
'-')
117 if (first != last && *first ==
'+')
123 template <
class UIntType,
class FwdIt>
128 "You may only call parseUnsigned with an unsigned integral type.");
130 if (first != last && *first ==
'+')
139 template <
class Out,
class In>
148 template <
class Arithmetic = In>
156 template <
class Enumeration = In>
173 "beast::LexicalCast can only be used with integral types");
175 template <
class Integral = Out>
182 template <
class Integral = Out>
196 return std::tolower(static_cast<unsigned char>(c));
199 if (in ==
"1" || in ==
"true")
205 if (in ==
"0" || in ==
"false")
223 bool operator() (Out& out,
char const* in)
const
236 bool operator() (Out& out,
char* in)
const
261 template <
class Out,
class In>
273 template <
class Out,
class In>
289 template <
class Out,
class In>