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>(
79 num, first, last, [limit_value, limit_digit](Int& value, Int digit) {
80 assert((digit >= 0) && (digit <= 9));
81 if (value < limit_value ||
82 (value == limit_value && digit > limit_digit))
84 value = (value * 10) - digit;
89 template <
class Int,
class FwdIt>
96 return parse_integral<Int>(
97 num, first, last, [limit_value, limit_digit](Int& value, Int digit) {
98 assert((digit >= 0) && (digit <= 9));
99 if (value > limit_value ||
100 (value == limit_value && digit > limit_digit))
102 value = (value * 10) + digit;
107 template <
class IntType,
class FwdIt>
113 "You may only call parseSigned with a signed integral type.");
115 if (first != last && *first ==
'-')
118 if (first != last && *first ==
'+')
124 template <
class UIntType,
class FwdIt>
130 "You may only call parseUnsigned with an unsigned integral type.");
132 if (first != last && *first ==
'+')
141 template <
class Out,
class In>
150 template <
class Arithmetic = In>
158 template <
class Enumeration = In>
176 "beast::LexicalCast can only be used with integral types");
178 template <
class Integral = Out>
185 template <
class Integral = Out>
197 return std::tolower(static_cast<unsigned char>(c));
200 if (in ==
"1" || in ==
"true")
206 if (in ==
"0" || in ==
"false")
264 template <
class Out,
class In>
277 template <
class Out,
class In>
294 template <
class Out,
class In>