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FF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
27 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
28 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
29 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
30 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
31 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
39 static constexpr std::size_t
48 static constexpr char r[] =
"128";
55 static constexpr char r[] =
"127";
61 static constexpr char r[] =
"int8_t";
70 static constexpr std::size_t
79 static constexpr char r[] =
"0";
86 static constexpr char r[] =
"255";
92 static constexpr char r[] =
"uint8_t";
101 static constexpr std::size_t
110 static constexpr char r[] =
"32768";
117 static constexpr char r[] =
"32767";
123 static constexpr char r[] =
"int16_t";
132 static constexpr std::size_t
141 static constexpr char r[] =
"0";
148 static constexpr char r[] =
"65535";
154 static constexpr char r[] =
"uint16_t";
163 static constexpr std::size_t
172 static constexpr char r[] =
"2147483648";
179 static constexpr char r[] =
"2147483647";
185 static constexpr char r[] =
"int32_t";
194 static constexpr std::size_t
203 static constexpr char r[] =
"0";
210 static constexpr char r[] =
"4294967295";
216 static constexpr char r[] =
"uint32_t";
225 static constexpr std::size_t
234 static constexpr char r[] =
"9223372036854775808";
241 static constexpr char r[] =
"9223372036854775807";
247 static constexpr char r[] =
"int64_t";
256 static constexpr std::size_t
265 static constexpr char r[] =
"0";
272 static constexpr char r[] =
"18446744073709551615";
278 static constexpr char r[] =
"uint64_t";
283template <
typename Integer >
286 const std::uint8_t *
const mapping_table,
287 const char * data_begin,
288 const char * data_end,
289 bool apply_minus_sign,
294 if( apply_minus_sign )
295 while( data_begin != data_end )
297 result = result*10 -
static_cast<Integer
>(
298 mapping_table[
static_cast< std::size_t
>( *data_begin++ ) ] );
301 while( data_begin != data_end )
303 result = result*10 +
static_cast<Integer
>(
304 mapping_table[
static_cast< std::size_t
>( *data_begin++ ) ] );
310template <
typename Integer >
313 const std::uint8_t *
const mapping_table,
314 const char * data_begin,
315 const char * data_end,
321 while( data_begin != data_end )
323 result = result * 10 +
static_cast<Integer
>(
324 mapping_table[
static_cast< std::size_t
>( *data_begin++ ) ] );
330template <
typename Traits >
331typename Traits::type_t
334 bool apply_minus_sign =
false;
335 if(
'-' == *data_begin )
337 if( !std::is_signed< typename Traits::type_t >::value )
342 "invalid {} value: unsigned starts with minus" ),
343 Traits::type_name() ) };
347 apply_minus_sign =
true;
350 else if(
'+' == *data_begin )
355 const auto representation_size =
static_cast< std::size_t
>( data_end - data_begin );
357 if( 0 == representation_size )
361 Traits::type_name() )
364 if( Traits::digits_representation_max_size() < representation_size )
368 "invalid {} value: max digits for type is {}" ),
370 Traits::digits_representation_max_size() )
373 const std::uint8_t *
const mapping_table = digits_mapping< std::uint8_t >();
378 [&](
auto d ){
return 0xFF == mapping_table[
static_cast< std::size_t
>( d ) ]; } ) )
383 Traits::type_name() )
387 if( Traits::digits_representation_max_size() == representation_size )
389 const char *
const posssible_max = apply_minus_sign ?
390 Traits::min_representation() : Traits::max_representation();
392 if( 0 < std::memcmp( data_begin, posssible_max, representation_size ) )
393 throw std::out_of_range{
396 Traits::type_name() )
400 using is_signed_t =
typename std::is_signed< typename Traits::type_t >::type;
403 parse_integer_no_checks< typename Traits::type_t >(
Exception class for all exceptions thrown by RESTinio.
#define RESTINIO_FMT_FORMAT_STRING(s)
Integer parse_integer_no_checks(const std::uint8_t *const mapping_table, const char *data_begin, const char *data_end, bool apply_minus_sign, std::true_type)
Traits::type_t parse_integer(const char *data_begin, const char *data_end)
const C * digits_mapping()
static const char * min_representation()
static const char * type_name()
static const char * max_representation()
static constexpr std::size_t digits_representation_max_size()
static const char * max_representation()
static const char * type_name()
static constexpr std::size_t digits_representation_max_size()
static const char * min_representation()
static const char * type_name()
static const char * min_representation()
static constexpr std::size_t digits_representation_max_size()
static const char * max_representation()
static const char * max_representation()
static const char * type_name()
static const char * min_representation()
static constexpr std::size_t digits_representation_max_size()
static constexpr std::size_t digits_representation_max_size()
static const char * min_representation()
static const char * type_name()
static const char * max_representation()
static const char * min_representation()
static constexpr std::size_t digits_representation_max_size()
static const char * max_representation()
static const char * type_name()
static constexpr std::size_t digits_representation_max_size()
static const char * type_name()
static const char * min_representation()
static const char * max_representation()
static constexpr std::size_t digits_representation_max_size()
static const char * min_representation()
static const char * type_name()
static const char * max_representation()