2
3
6
7
8
9
10
11
15#include <restinio/impl/to_lower_lut.hpp>
16#include <restinio/impl/overflow_controlled_integer_accumulator.hpp>
18#include <restinio/utils/tuple_algorithms.hpp>
19#include <restinio/utils/metaprogramming.hpp>
21#include <restinio/string_view.hpp>
22#include <restinio/compiler_features.hpp>
24#include <restinio/exception.hpp>
25#include <restinio/expected.hpp>
48
49
50
51
67
68
73
74
75
76
77
78
79
80
81
89
90
91
92
103 std::size_t position,
124
125
126
127
128
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179template<
typename T >
188 to = std::move(what);
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244template<
typename T >
250template<
typename T >
253template<
typename T,
typename... Args >
263 to = std::move(what);
269 to.push_back( std::move(what) );
287
288
289
290
291
292
293
294
295
296
297
298template<
typename T, std::size_t S >
307template<
typename T, std::size_t S >
308struct result_value_wrapper< std::array< T, S > >
310 using result_type = std::array< T, S >;
311 using value_type =
typename result_type::value_type;
315 as_result( wrapped_type & to, result_type && what )
317 to.m_array = std::move(what);
322 to_container( wrapped_type & to, value_type && what )
324 if( to.m_index >= S )
326 "index in the result std::array is out of range, "
327 "index=" + std::to_string(to.m_index) +
328 ", size={}" + std::to_string(S) );
330 to.m_array[ to.m_index ] = std::move(what);
335 static result_type &&
336 unwrap_value( wrapped_type & v )
338 return std::move(v.m_array);
343
344
345
346
347
348template<
typename T, std::size_t S >
354template<
typename Char,
typename... Args >
364 to = std::move(what);
370 to.push_back( what );
374
375
376
377
378
379
380
381
382
383
384
385
400template<
typename K,
typename V,
typename... Args >
413 to = std::move(what);
419 to.emplace( std::move(what) );
452
453
454
455
456constexpr std::size_t
N = std::numeric_limits<std::size_t>::max();
462
463
464
465
466
474
475
476
477
484
485
486
494
495
496
499 underlying_int_t min,
500 underlying_int_t max )
noexcept
508 min()
const noexcept {
return m_min; }
513 max()
const noexcept {
return m_max; }
517 constexpr static auto
520 return std::numeric_limits<underlying_int_t>::max();
524
525
527 constexpr static auto
535
536
537
538
539
540
541
542
543
544
545
546
547
556
557
558
559
560
561
562
563
564
565
566
567
568
572 digits_to_consume_t::underlying_int_t min,
573 digits_to_consume_t::underlying_int_t max )
noexcept
585
586
587
588
589
590
591
592
614
615
616
617
618constexpr char SP =
' ';
620
621
622
623
630
631
632
633
638 return ch ==
SP || ch ==
HTAB;
645
646
647
648
649
664
665
666
667
672 return (ch >=
'0' && ch <=
'9');
679
680
681
682
697
698
699
700
705 return (ch >=
'0' && ch <=
'9') ||
706 (ch >=
'A' && ch <=
'F') ||
707 (ch >=
'a' && ch <=
'f');
714
715
716
717
718
733
734
735
736
737
738
739
746
747
748
749
761
762
763
768 if( m_index < m_data.size() )
770 return {
false, m_data[ m_index++ ]};
797 if( pos <= m_data.size() )
806 return m_index >= m_data.size();
811
812
813
814
819 string_view_t::size_type from,
825 return m_data.substr( from, length );
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
870 m_from.backto( m_started_at );
881
882
883
884
897
898
899
900
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944template<
typename Result_Type >
951template<
typename T,
typename =
meta::
void_t<> >
954template<
typename T >
961
962
963
964
965
966
967
968
969
970template<
typename T >
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998template<
typename Result_Type >
1005template<
typename T,
typename =
meta::
void_t<> >
1008template<
typename T >
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024template<
typename T >
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047template<
typename Result_Type >
1050 template<
typename Transformer,
typename Input_Type >
1055 Transformer & transformer,
1056 expected_t< Input_Type, parse_error_t > && input )
1058 return transformer.transform( std::move(*input) );
1063
1064
1065
1066
1067
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110template<
typename Result_Type >
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144template<
typename Producer,
typename Transformer >
1147 static_assert( is_producer_v<Producer>,
1148 "Producer should be a producer type" );
1149 static_assert( is_transformer_v<Transformer>,
1150 "Transformer should be a transformer type" );
1171
1172
1173
1174
1175
1176
1177
1178
1179template<
typename Producer,
typename Transformer >
1184 Producer, Transformer >;
1188 "transformation result should be either T or "
1189 "expected_t<T, error_reson_t>, not expected_t<T, parse_error_t>" );
1198 Producer && producer,
1199 Transformer && transformer )
1208 auto producer_result =
m_producer.try_parse( source );
1209 if( producer_result )
1211 using transformation_result_t =
1217 std::move(producer_result) );
1220 return make_unexpected( producer_result.error() );
1225
1226
1227
1228
1229template<
typename P,
typename T >
1240 return transformator_type{ std::move(producer), std::move(transformer) };
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1272template<
typename T,
typename =
meta::
void_t<> >
1275template<
typename T >
1282
1283
1284
1285
1286
1287
1288
1289
1290template<
typename T >
1294
1295
1296
1297
1298
1309 T transformer_proxy )
1311 auto real_transformer = transformer_proxy.
template make_transformer<
1312 typename P::result_type >();
1314 using transformator_type = std::decay_t<
decltype(real_transformer) >;
1316 using producer_type = transformed_value_producer_t< P, transformator_type >;
1318 return producer_type{ std::move(producer), std::move(real_transformer) };
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1348template<
typename T,
typename =
meta::
void_t<> >
1351template<
typename T >
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367template<
typename T >
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1398template<
typename T,
typename =
meta::
void_t<> >
1401template<
typename T >
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420template<
typename T >
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1465
1466
1467
1468
1469
1470
1471
1472
1473template<
typename P,
typename C >
1476 static_assert( is_producer_v<P>,
"P should be a producer type" );
1477 static_assert( is_consumer_v<C>,
"C should be a consumer type" );
1488 template<
typename Target_Type >
1493 auto parse_result =
m_producer.try_parse( from );
1496 m_consumer.consume( target, std::move(*parse_result) );
1497 return std::nullopt;
1500 return parse_result.error();
1505
1506
1507
1508
1509template<
typename P,
typename C >
1516 return { std::move(producer), std::move(consumer) };
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532template<
typename Producer >
1535 static_assert( is_producer_v<Producer>,
1536 "Producer should be a producer type" );
1557
1558
1559
1560
1561
1562
1563
1564
1576 from.current_position(),
1582 return std::nullopt;
1589
1590
1591
1592
1597 auto s = from.size();
1598 for(; s && is_space( from[ (s-1u) ] ); --s) {}
1600 return from.substr( 0u, s );
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1635 typename Subitems_Tuple >
1642 Subitems_Tuple && subitems )
1646 template<
typename Target_Type >
1651 const auto starting_pos = from.current_position();
1656 [&from, &target, &actual_parse_error](
auto && one_producer ) {
1658 Target_Type tmp_value{ target };
1660 actual_parse_error = one_producer.try_process( from, tmp_value );
1661 if( !actual_parse_error )
1663 target = std::move(tmp_value);
1674 actual_parse_error->reason();
1678 if( !success || actual_parse_error )
1684 return std::nullopt;
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1716 typename Subitems_Tuple >
1723 Subitems_Tuple && subitems )
1727 template<
typename Target_Type >
1733 Target_Type tmp_value{ target };
1737 [&from, &tmp_value](
auto && one_producer ) {
1738 return !one_producer.try_process( from, tmp_value );
1743 target = std::move(tmp_value);
1748 return std::nullopt;
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1779 typename Subitems_Tuple >
1786 Subitems_Tuple && subitems )
1790 template<
typename Target_Type >
1798 Target_Type dummy_value;
1802 [&from, &dummy_value](
auto && one_producer ) {
1803 return !one_producer.try_process( from, dummy_value );
1810 consumer.started_at(),
1816 return std::nullopt;
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1847 typename Subitems_Tuple >
1854 Subitems_Tuple && subitems )
1858 template<
typename Target_Type >
1866 Target_Type dummy_value;
1870 [&from, &dummy_value](
auto && one_producer ) {
1871 return !one_producer.try_process( from, dummy_value );
1876 consumer.started_at(),
1880 return std::nullopt;
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1908 typename Subitems_Tuple >
1915 Subitems_Tuple && subitems )
1919 template<
typename Target_Type >
1925 Target_Type tmp_value{ target };
1932 [&from, &tmp_value, &result](
auto && one_producer ) {
1933 result = one_producer.try_process( from, tmp_value );
1939 target = std::move(tmp_value);
1951
1952
1953
1954
1955
1956
1957
1958
1959
1961 typename Subitems_Tuple >
1969 template<
typename Target_Type >
1974 const auto starting_pos = from.current_position();
1986 return std::nullopt;
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2008 typename Target_Type,
2009 typename Subitems_Tuple >
2018 Subitems_Tuple && subitems )
2031 [&from, &tmp_value, &error](
auto && one_clause ) {
2032 error = one_clause.try_process( from, tmp_value );
2039 return make_unexpected( *error );
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2060 typename Subitems_Tuple >
2070 std::size_t min_occurences,
2071 std::size_t max_occurences,
2072 Subitems_Tuple && subitems )
2078 template<
typename Target_Type >
2085 std::size_t count{};
2086 bool failure_detected{
false };
2093 [&from, &dest](
auto && one_clause ) {
2094 return !one_clause.try_process( from, dest );
2097 if( !failure_detected )
2108 return std::nullopt;
2112 from.current_position(),
2122
2123
2124
2125
2126
2127
2128
2129
2130template<
typename Predicate >
2133 ,
protected Predicate
2136 template<
typename... Args >
2138 : Predicate{ std::forward<Args>(args)... }
2149 if( (*
this)(ch
.m_ch) )
2155 from.current_position(),
2162 from.current_position(),
2172
2173
2174
2175
2176
2177
2178
2193
2194
2195
2196
2197
2214
2215
2216
2217
2218
2235
2236
2237
2238
2239
2260
2261
2262
2263
2264
2265
2266
2284
2285
2286
2287
2288
2289
2290
2307
2308
2309
2310
2311
2312
2313
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2356
2357
2358
2359
2360
2361
2362
2379
2380
2381
2382
2383
2384
2385
2397
2398
2399
2400
2401
2402
2403
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435template<
typename T,
typename Value_Accumulator >
2441 Value_Accumulator acc )
noexcept
2445 digits_to_consume_t::underlying_int_t symbols_processed{};
2451 acc.next_digit(
static_cast<T>(ch
.m_ch -
'0') );
2453 if( acc.overflow_detected() )
2455 consumer.started_at(),
2459 ++symbols_processed;
2460 if( symbols_processed == digits_limit
.max() )
2470 if( symbols_processed < digits_limit
.min() )
2473 from.current_position(),
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499template<
typename T,
typename Value_Accumulator >
2505 Value_Accumulator acc )
noexcept
2507 const auto ch_to_digit = [](
char ch ) -> std::pair<
bool, T> {
2508 if( ch >=
'0' && ch <=
'9' )
2509 return std::make_pair(
true,
static_cast<T>(ch -
'0') );
2510 else if( ch >=
'A' && ch <=
'F' )
2511 return std::make_pair(
true,
static_cast<T>(10 + (ch -
'A')) );
2512 else if( ch >=
'a' && ch <=
'f' )
2513 return std::make_pair(
true,
static_cast<T>(10 + (ch -
'a')) );
2515 return std::make_pair(
false,
static_cast<T>(0) );
2520 digits_to_consume_t::underlying_int_t symbols_processed{};
2524 const auto d = ch_to_digit( ch
.m_ch );
2527 acc.next_digit( d.second );
2529 if( acc.overflow_detected() )
2531 consumer.started_at(),
2535 ++symbols_processed;
2536 if( symbols_processed == digits_limit
.max() )
2546 if( symbols_processed < digits_limit
.min() )
2549 from.current_position(),
2563
2564
2565
2566
2567
2568
2569
2570template<
typename T >
2578 return try_parse_digits_with_digits_limit< T >(
2580 digits_to_consume_t::from_one_to_max(),
2581 restinio::impl::overflow_controlled_integer_accumulator_t<T, 10>{} );
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598template<
typename T >
2614 return try_parse_digits_with_digits_limit< T >(
2617 restinio::impl::overflow_controlled_integer_accumulator_t<T, 10>{} );
2625
2626
2627
2628
2629
2630
2631
2632template<
typename T >
2635 static_assert( std::is_unsigned<T>::value,
2636 "T is expected to be unsigned type" );
2643 return try_parse_hexdigits_with_digits_limit< T >(
2645 digits_to_consume_t::from_one_to_max(),
2646 restinio::impl::overflow_controlled_integer_accumulator_t<T, 16>{} );
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663template<
typename T >
2679 return try_parse_hexdigits_with_digits_limit< T >(
2682 restinio::impl::overflow_controlled_integer_accumulator_t<T, 16>{} );
2690
2691
2692
2693
2694
2695
2696
2697template<
typename T >
2700 static_assert( std::is_signed<T>::value,
2701 "decimal_number_producer_t can be used only for signed types" );
2710 return try_parse_impl( from,
2712 return digits_to_consume_t::from_one_to_max();
2717 template<
typename Digits_Limit_Maker >
2722 Digits_Limit_Maker && digits_limit_maker )
const noexcept
2729 const auto r = try_parse_with_this_first_symbol(
2732 std::forward<Digits_Limit_Maker>(digits_limit_maker) );
2741 from.current_position(),
2747 template<
typename Digits_Limit_Maker >
2753 Digits_Limit_Maker && digits_limit_maker )
noexcept
2755 using restinio::
impl::overflow_controlled_integer_accumulator_t;
2758 if(
'-' == first_symbol )
2760 const auto r = try_parse_digits_with_digits_limit< T >(
2762 digits_limit_maker(),
2768 return static_cast< T >( -(*r) );
2774 else if(
'+' == first_symbol )
2776 return try_parse_digits_with_digits_limit< T >(
2778 digits_limit_maker(),
2779 overflow_controlled_integer_accumulator_t< T, 10 >{} );
2784 return try_parse_digits_with_digits_limit< T >(
2786 digits_limit_maker(),
2787 overflow_controlled_integer_accumulator_t< T, 10 >{} );
2791 from.current_position(),
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810template<
typename T >
2826 return this->try_parse_impl(
2828 [
this]()
noexcept {
return m_digits_limit; } );
2836
2837
2838
2839
2840
2841
2842
2845 template<
typename Target_Type,
typename Value >
2847 consume( Target_Type &, Value && )
const noexcept {}
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2872 template<
typename Target_Type,
typename Value >
2876 result_wrapper_for_t<Target_Type>::as_result(
2877 dest, std::forward<Value>(src) );
2885
2886
2887
2888
2889
2890
2891template<
typename Result_Type >
2910 template<
typename Result_Arg >
2913 :
m_result{ std::forward<Result_Arg>(result) }
2916 template<
typename Target_Type,
typename Value >
2920 result_wrapper_for_t<Target_Type>::as_result(
2923 make_copy_of_result() );
2931
2932
2933
2934
2935
2936
2937
2938
2939template<
typename C >
2947 template<
typename Target_Type,
typename Value >
2960
2961
2962
2963
2964
2965
2966
2967
2968template<
typename F,
typename C >
2988 to.*
m_ptr = std::move(value);
2993
2994
2995
2996
2997
2998template<
typename P,
typename F,
typename C >
3006 std::move(producer),
3015
3016
3017
3018
3019
3020template< std::size_t Index >
3029 template<
typename Target_Type,
typename Value >
3033 std::get<Index>(std::forward<Target_Type>(to)) =
3034 std::forward<Value>(value);
3041template<
typename Input_Type >
3045
3046
3047
3048
3049
3060 result_type result{ std::move(input) };
3061 std::transform( result.begin(), result.end(), result.begin(),
3062 [](
unsigned char ch ) ->
char {
3071
3072
3073
3074
3075
3091
3092
3093
3094
3095
3096template< std::size_t S >
3108 std::transform( input.begin(), input.end(), result.begin(),
3109 [](
unsigned char ch ) ->
char {
3121
3122
3123
3124
3127 template<
typename Input_Type >
3140
3141
3142
3143
3144
3145template<
typename T >
3155 template<
typename Input >
3168
3169
3170
3171
3172
3173template<
typename Output_Type,
typename Converter >
3179 template<
typename Convert_Arg >
3182 :
m_converter{ std::forward<Convert_Arg>(converter) }
3186
3187
3188
3189
3190
3191
3192
3193 template<
typename Input >
3199 using actual_result_t = std::decay_t<
decltype(
3200 m_converter(std::forward<Input>(input))
3204 is_appropriate_transformer_result_type<actual_result_t>::value,
3205 "the return value of converter should be either Output_Type or "
3206 "expected_t<Output_Type, error_reason_t>" );
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225template<
typename Result_Type >
3238
3239
3240
3241
3242template<
typename Result_Type >
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262template<
typename Converter >
3275 template<
typename Convert_Arg >
3278 :
m_converter{ std::forward<Convert_Arg>(converter) }
3281 template<
typename Input_Type >
3287 using output_t = output<Input_Type>;
3289 return convert_transformer_t< output_t, Converter >{ m_converter };
3292 template<
typename Input_Type >
3298 using output_t = output<Input_Type>;
3300 return convert_transformer_t< output_t, Converter >{
3301 std::move(m_converter)
3311template<
typename It >
3316 assert( begin != end );
3322 if( ch
.m_ch != *begin )
3324 consumer.started_at(),
3327 if( ++begin == end )
3333 consumer.started_at(),
3346
3347
3348
3349
3350
3351
3352
3353
3354template< std::size_t Size >
3358 static_assert( 1u < Size,
"Size is expected to greater that 1" );
3374 return try_parse_exact_fragment( from,
3383
3384
3385
3386
3387
3398 throw exception_t( "'fragment' value for exact_fragment_producer_t "
3399 "can't be empty!" );
3406 return try_parse_exact_fragment( from,
3417template<
typename It >
3422 assert( begin != end );
3430 consumer.started_at(),
3433 if( ++begin == end )
3439 consumer.started_at(),
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462template< std::size_t Size >
3466 static_assert( 1u < Size,
"Size is expected to greater that 1" );
3479 [](
const char src ) {
3488 return try_parse_caseless_exact_fragment( from,
3497
3498
3499
3500
3501
3502
3503
3514 throw exception_t( "'fragment' value for exact_fragment_producer_t "
3515 "can't be empty!" );
3518 for(
auto & ch : m_fragment )
3519 ch = restinio::impl::to_lower_case( ch );
3526 return try_parse_caseless_exact_fragment( from,
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3551 typename Target_Type,
3552 typename... Clauses >
3557 static_assert( 0 !=
sizeof...(clauses),
3558 "list of clauses can't be empty" );
3559 static_assert( meta::all_of_v< impl::is_clause, Clauses... >,
3560 "all arguments for produce() should be clauses" );
3562 using producer_type_t = impl::produce_t<
3564 impl::tuple_of_entities_t<Clauses...> >;
3566 return producer_type_t{
3567 std::make_tuple(std::forward<Clauses>(clauses)...)
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593template<
typename... Clauses >
3598 static_assert( 0 !=
sizeof...(clauses),
3599 "list of clauses can't be empty" );
3600 static_assert( meta::all_of_v< impl::is_clause, Clauses... >,
3601 "all arguments for alternatives() should be clauses" );
3603 using clause_type_t = impl::alternatives_clause_t<
3604 impl::tuple_of_entities_t< Clauses... > >;
3606 return clause_type_t{
3607 std::make_tuple(std::forward<Clauses>(clauses)...)
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632template<
typename... Clauses >
3637 static_assert( 0 !=
sizeof...(clauses),
3638 "list of clauses can't be empty" );
3639 static_assert( meta::all_of_v< impl::is_clause, Clauses... >,
3640 "all arguments for maybe() should be clauses" );
3642 using clause_type_t = impl::maybe_clause_t<
3643 impl::tuple_of_entities_t<Clauses...> >;
3645 return clause_type_t{
3646 std::make_tuple(std::forward<Clauses>(clauses)...)
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674template<
typename... Clauses >
3679 static_assert( 0 !=
sizeof...(clauses),
3680 "list of clauses can't be empty" );
3681 static_assert( meta::all_of_v< impl::is_clause, Clauses... >,
3682 "all arguments for not_clause() should be clauses" );
3684 using clause_type_t = impl::not_clause_t<
3685 impl::tuple_of_entities_t<Clauses...> >;
3687 return clause_type_t{
3688 std::make_tuple(std::forward<Clauses>(clauses)...)
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716template<
typename... Clauses >
3721 static_assert( 0 !=
sizeof...(clauses),
3722 "list of clauses can't be empty" );
3723 static_assert( meta::all_of_v< impl::is_clause, Clauses... >,
3724 "all arguments for sequence() should be clauses" );
3726 using clause_type_t = impl::and_clause_t<
3727 impl::tuple_of_entities_t<Clauses...> >;
3729 return clause_type_t{
3730 std::make_tuple(std::forward<Clauses>(clauses)...)
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756template<
typename... Clauses >
3761 static_assert( 0 !=
sizeof...(clauses),
3762 "list of clauses can't be empty" );
3763 static_assert( meta::all_of_v< impl::is_clause, Clauses... >,
3764 "all arguments for sequence() should be clauses" );
3766 using clause_type_t = impl::sequence_clause_t<
3767 impl::tuple_of_entities_t< Clauses... > >;
3769 return clause_type_t{
3770 std::make_tuple(std::forward<Clauses>(clauses)...)
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819template<
typename... Clauses >
3824 static_assert( 0 !=
sizeof...(clauses),
3825 "list of clauses can't be empty" );
3826 static_assert( meta::all_of_v< impl::is_clause, Clauses... >,
3827 "all arguments for force_only_this_alternative() should "
3830 using clause_type_t = impl::forced_alternative_clause_t<
3831 impl::tuple_of_entities_t< Clauses... > >;
3833 return clause_type_t{
3834 std::make_tuple(std::forward<Clauses>(clauses)...)
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3874 typename... Clauses >
3879 std::size_t min_occurences,
3882
3883
3884
3885
3886 std::size_t max_occurences,
3888 Clauses &&... clauses )
3890 static_assert( 0 !=
sizeof...(clauses),
3891 "list of clauses can't be empty" );
3892 static_assert( meta::all_of_v< impl::is_clause, Clauses... >,
3893 "all arguments for repeat() should be clauses" );
3895 using producer_type_t = impl::repeat_clause_t<
3896 impl::tuple_of_entities_t<Clauses...> >;
3898 return producer_type_t{
3901 std::make_tuple(std::forward<Clauses>(clauses)...)
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3929
3930
3931
3932
3933
3934
3935
3940 return impl::symbol_producer_template_t<impl::any_symbol_predicate_t>{};
3947
3948
3949
3950
3951
3952
3953
3965
3966
3967
3968
3969
3970
3971
3983
3984
3985
3986
3987
3988
3989
3990
3991
4003
4004
4005
4006
4007
4008
4009
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4086
4087
4088
4089
4090
4091
4092
4097 return impl::symbol_producer_template_t< impl::is_space_predicate_t >{};
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4118 return space_p() >> skip();
4125
4126
4127
4128
4129
4130
4131
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4164
4165
4166
4167
4168
4169
4170
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216template<
typename T >
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255template<
typename T >
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285template<
typename T >
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327template<
typename T >
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365template<
typename T >
4370 static_assert( std::is_signed<T>::value,
4371 "decimal_number_p() can be used only for signed numeric types" );
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418template<
typename T >
4423 static_assert( std::is_signed<T>::value,
4424 "decimal_number_p() can be used only for signed numeric types" );
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494template<
typename F >
4501 return actual_consumer_t{ std::move(consumer) };
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4523 template<
typename Container,
typename Item >
4527 using container_adaptor_type = result_wrapper_for_t<Container>;
4528 container_adaptor_type::to_container( to, std::move(item) );
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613template<
typename T >
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642template<
typename T >
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715template<
typename Converter >
4720 using converter_type = std::decay_t<Converter>;
4722 using transformer_proxy_type = impl::convert_transformer_proxy_t<
4725 return transformer_proxy_type{ std::forward<Converter>(converter) };
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4752 std::string{ fragment.data(), fragment.size() }
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790template< std::size_t Size >
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4817 std::string{ fragment.data(), fragment.size() }
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849template< std::size_t Size >
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4881 std::string{ fragment.data(), fragment.size() }
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919template< std::size_t Size >
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4946 std::string{ fragment.data(), fragment.size() }
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978template< std::size_t Size >
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020template<
typename Producer >
5027 static_assert(
impl::is_producer_v<Producer>,
5028 "Producer should be a value producer type" );
5030 from = impl::remove_trailing_spaces( from );
5034 .try_process( source );
5039 const auto all_content_check =
5040 impl::ensure_no_remaining_content( source );
5041 if( all_content_check )
5042 return make_unexpected( *all_content_check );
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5086 string_view_t from )
5088 const auto append_quote = [&]( std::string & dest ) {
5089 constexpr std::size_t max_quote_size = 16u;
5093 const auto prefix_size = error
.position() > max_quote_size ?
5096 dest.append( 1u,
'"' );
5100 dest.append(
"\" >>> " );
5103 const char problematic_symbol = error
.position() < from.size() ?
5105 dest.append( 1u,
'\'' );
5106 if( problematic_symbol >=
'\x00' && problematic_symbol <
' ' )
5108 constexpr char hex_digits[] =
"0123456789abcdef";
5110 dest.append(
"\\x" );
5111 dest.append( 1u, hex_digits[
5112 static_cast<
unsigned char>(problematic_symbol) >> 4 ] );
5113 dest.append( 1u, hex_digits[
5114 static_cast<
unsigned char>(problematic_symbol) & 0xfu ] );
5117 dest.append( 1u, problematic_symbol );
5119 dest.append( 1u,
'\'' );
5124 const auto suffix_size =
5125 error
.position() + 1u + max_quote_size < from.size() ?
5126 max_quote_size : from.size() - error
.position() - 1u;
5128 dest.append(
" <<< \"" );
5129 dest.append( &from[ error
.position() + 1u ], suffix_size );
5130 dest.append( 1u,
'"' );
5136 const auto basic_reaction = [&](
const char * msg) {
5141 append_quote( result );
5147 basic_reaction(
"unexpected character" );
5151 result +=
"unexpected EOF at ";
5156 basic_reaction(
"appropriate alternative can't found" );
5160 basic_reaction(
"expected pattern is not found" );
5164 basic_reaction(
"unconsumed input found" );
5168 basic_reaction(
"some illegal value found" );
5172 basic_reaction(
"forced selection alternative failed" );
Limits for number of digits to be extracted during parsing of decimal numbers.
static constexpr auto unlimited_max() noexcept
Get the value that means that maximum is not limited.
constexpr digits_to_consume_t(underlying_int_t total) noexcept
constexpr auto max() const noexcept
Get the maximum value.
constexpr digits_to_consume_t(underlying_int_t min, underlying_int_t max) noexcept
underlying_int_t m_max
Maximal number of digits to consume.
constexpr auto min() const noexcept
Get the minimal value.
static constexpr auto from_one_to_max() noexcept
underlying_int_t m_min
Minimal number of digits to consume.
A template for implementation of clause that selects one of alternative clauses.
Subitems_Tuple m_subitems
std::optional< parse_error_t > try_process(source_t &from, Target_Type &target)
alternatives_clause_t(Subitems_Tuple &&subitems)
A template for implementation of clause that checks the presence of some entity in the input stream.
std::optional< parse_error_t > try_process(source_t &from, Target_Type &)
Subitems_Tuple m_subitems
and_clause_t(Subitems_Tuple &&subitems)
A producer for the case when any character except the specific sentinel character is expected in the ...
any_symbol_if_not_producer_t(char sentinel)
symbol_producer_template_t< not_particular_symbol_predicate_t > base_type_t
A producer that expects a fragment in the input and produces boolean value if that fragment is found.
expected_t< bool, parse_error_t > try_parse(source_t &from)
caseless_exact_fixed_size_fragment_producer_t(const char(&f)[Size])
std::array< char, Size-1u > m_fragment
A producer that expects a fragment in the input and produces boolean value if that fragment is found.
caseless_exact_fragment_producer_t(std::string fragment)
expected_t< bool, parse_error_t > try_parse(source_t &from)
A producer for the case when a particual character is expected in the input stream.
caseless_symbol_producer_t(char expected)
symbol_producer_template_t< caseless_particular_symbol_predicate_t > base_type_t
A template for a clause that binds a value producer with value consumer.
std::optional< parse_error_t > try_process(source_t &from, Target_Type &target)
consume_value_clause_t(P &&producer, C &&consumer)
A template for consumers that are released by lambda/functional objects.
void consume(Target_Type &dest, Value &&src) const noexcept(noexcept(m_consumer(dest, std::forward< Value >(src))))
custom_consumer_t(C &&consumer)
A producer for the case when a signed decimal number is expected in the input stream.
static try_parse_result_type try_parse_with_this_first_symbol(source_t &from, char first_symbol, Digits_Limit_Maker &&digits_limit_maker) noexcept
try_parse_result_type try_parse(source_t &from) const noexcept
try_parse_result_type try_parse_impl(source_t &from, Digits_Limit_Maker &&digits_limit_maker) const noexcept
A producer for the case when a signed decimal number is expected in the input stream.
auto try_parse(source_t &from) const noexcept
decimal_number_producer_with_digits_limit_t(digits_to_consume_t digits_limit)
digits_to_consume_t m_digits_limit
A producer for the case when a decimal digit is expected in the input stream.
A producer that expects a fragment in the input and produces boolean value if that fragment is found.
exact_fixed_size_fragment_producer_t(const char(&f)[Size])
std::array< char, Size-1u > m_fragment
expected_t< bool, parse_error_t > try_parse(source_t &from)
A producer that expects a fragment in the input and produces boolean value if that fragment is found.
exact_fragment_producer_t(std::string fragment)
expected_t< bool, parse_error_t > try_parse(source_t &from)
A template for consumers that store a value to the specified field of a target object.
void consume(C &to, F &&value) const noexcept(noexcept(to.*m_ptr=std::move(value)))
field_setter_consumer_t(pointer_t ptr) noexcept
An alternative that should be parsed correctly or the parsing of the whole alternatives clause should...
sequence_clause_t< Subitems_Tuple > base_type_t
std::optional< parse_error_t > try_process(source_t &from, Target_Type &target)
A producer for the case when a number in hexadecimal form is expected in the input stream.
expected_t< T, parse_error_t > try_parse(source_t &from) const noexcept
A producer for the case when a number in hexadecimal form is expected in the input stream.
digits_to_consume_t m_digits_limit
expected_t< T, parse_error_t > try_parse(source_t &from) const noexcept
hexadecimal_number_producer_with_digits_limit_t(digits_to_consume_t digits_limit)
A producer for the case when a hexadecimal digit is expected in the input stream.
A consumer for the case when a specific value should be used as the result instead of the value produ...
Result_Type make_copy_of_result() const noexcept(noexcept(Result_Type{m_result}))
just_result_consumer_t(Result_Arg &&result) noexcept(noexcept(Result_Type{std::forward< Result_Arg >(result)}))
void consume(Target_Type &dest, Value &&) const
A template for implementation of clause that checks and handles presence of optional entity in the in...
std::optional< parse_error_t > try_process(source_t &from, Target_Type &target)
maybe_clause_t(Subitems_Tuple &&subitems)
Subitems_Tuple m_subitems
A producer for the case when a non-negative decimal number is expected in the input stream.
expected_t< T, parse_error_t > try_parse(source_t &from) const noexcept
A producer for the case when a non-negative decimal number is expected in the input stream.
digits_to_consume_t m_digits_limit
expected_t< T, parse_error_t > try_parse(source_t &from) const noexcept
non_negative_decimal_number_producer_with_digits_limit_t(digits_to_consume_t digits_limit)
A template for implementation of clause that checks absence of some entity in the input stream.
Subitems_Tuple m_subitems
not_clause_t(Subitems_Tuple &&subitems)
std::optional< parse_error_t > try_process(source_t &from, Target_Type &)
A template for producing a value of specific type of a sequence of entities from the input stream.
result_value_wrapper< Target_Type > value_wrapper_t
Subitems_Tuple m_subitems
produce_t(Subitems_Tuple &&subitems)
expected_t< Target_Type, parse_error_t > try_parse(source_t &from)
A template for handling repetition of clauses.
std::optional< parse_error_t > try_process(source_t &from, Target_Type &dest)
std::size_t m_min_occurences
Subitems_Tuple m_subitems
repeat_clause_t(std::size_t min_occurences, std::size_t max_occurences, Subitems_Tuple &&subitems)
std::size_t m_max_occurences
A template for implementation of clause that checks and handles presence of sequence of entities in t...
Subitems_Tuple m_subitems
sequence_clause_t(Subitems_Tuple &&subitems)
std::optional< parse_error_t > try_process(source_t &from, Target_Type &target)
A helper class to automatically return acquired content back to the input stream.
content_consumer_t(const content_consumer_t &)=delete
position_t started_at() const noexcept
content_consumer_t(content_consumer_t &&)=delete
const position_t m_started_at
void commit() noexcept
Consume all acquired content.
~content_consumer_t() noexcept
content_consumer_t(source_t &from) noexcept
content_consumer_t()=delete
The class that implements "input stream".
source_t(string_view_t data) noexcept
Initializing constructor.
string_view_t fragment(string_view_t::size_type from, string_view_t::size_type length=string_view_t::npos) const noexcept
Return a fragment from the input stream.
position_t current_position() const noexcept
Get the current position in the stream.
string_view_t::size_type m_index
The current position in the input stream.
void putback() noexcept
Return one character back to the input stream.
character_t getch() noexcept
Get the next character from the input stream.
bool eof() const noexcept
Is EOF has been reached?
const string_view_t m_data
The content to be used as "input stream".
void backto(position_t pos) noexcept
Return the current position in the input stream at the specified position.
A producer for the case when a symbol should belong to specified range.
symbol_producer_template_t< symbol_from_range_predicate_t > base_type_t
symbol_from_range_producer_t(char left, char right)
A producer for the case when a particual character is expected in the input stream.
symbol_producer_template_t< particular_symbol_predicate_t > base_type_t
symbol_producer_t(char expected)
A template for producer of charachers that satisfy some predicate.
expected_t< char, parse_error_t > try_parse(source_t &from) const noexcept
symbol_producer_template_t(Args &&... args)
A special class to be used as the top level clause in parser.
top_level_clause_t(Producer &&producer)
auto try_process(source_t &from)
Information about parsing error.
error_reason_t m_reason
The reason of the error.
std::size_t position() const noexcept
Get the position in the input stream where error was detected.
error_reason_t reason() const noexcept
Get the reason of the error.
std::size_t m_position
Position in the input stream.
parse_error_t(std::size_t position, error_reason_t reason) noexcept
Initializing constructor.
Exception class for all exceptions thrown by RESTinio.
exception_t(const char *err)
Helper class for accumulating integer value during parsing it from string (with check for overflow).
expected_t< bool, parse_error_t > try_parse_exact_fragment(source_t &from, It begin, It end)
auto operator>>(P producer, T transformer_proxy)
A special operator to connect a value producer with value transformer via transformer-proxy.
constexpr bool is_producer_v
A meta-value to check whether T is a producer type.
constexpr char HTAB
A constant for Horizontal Tab value.
typename conversion_result_type_detector< Result_Type >::type conversion_result_type_detector_t
std::enable_if_t< is_producer_v< P >, consume_value_clause_t< P, field_setter_consumer_t< F, C > > > operator>>(P producer, F C::*member_ptr)
A special operator to connect a value producer with field_setter_consumer.
string_view_t remove_trailing_spaces(string_view_t from) noexcept
Helper function for removal of trailing spaces from a string-view.
expected_t< T, parse_error_t > try_parse_digits_with_digits_limit(source_t &from, digits_to_consume_t digits_limit, Value_Accumulator acc) noexcept
Helper function for parsing integers with respect to the number of digits to be consumed.
constexpr bool is_hexdigit(const char ch) noexcept
Is a character a hexadecimal digit?
constexpr bool is_consumer_v
A meta-value to check whether T is a consumer type.
std::optional< parse_error_t > ensure_no_remaining_content(source_t &from)
A special function to check that there is no more actual data in the input stream except whitespaces.
constexpr char SP
A constant for SPACE value.
expected_t< T, parse_error_t > try_parse_hexdigits_with_digits_limit(source_t &from, digits_to_consume_t digits_limit, Value_Accumulator acc) noexcept
Helper function for parsing integers in hexadecimal form.
std::enable_if_t< is_producer_v< P > &is_transformer_v< T >, transformed_value_producer_t< P, T > > operator>>(P producer, T transformer)
A special operator to connect a value producer with value transformer.
entity_type_t
A marker for distinguish different kind of entities in parser.
@ consumer
Entity is a consumer of values. It requires a value on the input and doesn't produces anything.
@ transformer
Entity is a transformer of a value from one type to another.
@ clause
Entity is a clause. It doesn't produces anything.
@ producer
Entity is a producer of values.
@ transformer_proxy
Entity is a transformer-proxy. It can't be used directly, only for binding a producer and transformer...
constexpr bool is_space(const char ch) noexcept
If a character a space character?
constexpr bool is_transformer_proxy_v
A meta-value to check whether T is a transformer-proxy type.
constexpr bool is_clause_v
A meta-value to check whether T is a consumer type.
expected_t< bool, parse_error_t > try_parse_caseless_exact_fragment(source_t &from, It begin, It end)
constexpr bool is_digit(const char ch) noexcept
Is a character a decimal digit?
constexpr bool is_transformer_v
A meta-value to check whether T is a transformer type.
bool operator!=(const character_t &a, const character_t &b) noexcept
bool operator==(const character_t &a, const character_t &b) noexcept
auto space() noexcept
A factory function to create a clause that expects a space, extracts it and then skips it.
auto digit_p() noexcept
A factory function to create a digit_producer.
auto to_container()
A factory function to create a to_container_consumer.
auto caseless_symbol_p(char expected) noexcept
A factory function to create a caseless_symbol_producer.
auto any_symbol_p() noexcept
A factory function to create an any_symbol_producer.
auto force_only_this_alternative(Clauses &&... clauses)
An alternative that should be parsed correctly or the parsing of the whole alternatives clause should...
auto symbol(char expected) noexcept
A factory function to create a clause that expects the speficied symbol, extracts it and then skips i...
auto space_p() noexcept
A factory function to create a space_producer.
auto decimal_number_p() noexcept
A factory function to create a decimal_number_producer.
constexpr digits_to_consume_t expected_digits(digits_to_consume_t::underlying_int_t min, digits_to_consume_t::underlying_int_t max) noexcept
Create a limit for number of digits to be extracted.
auto and_clause(Clauses &&... clauses)
A factory function to create an and_clause.
auto digit() noexcept
A factory function to create a clause that expects a decimal digit, extracts it and then skips it.
auto exact(string_view_t fragment)
A factory function that creates an instance of exact_fragment clause.
expected_t< typename Producer::result_type, parse_error_t > try_parse(string_view_t from, Producer producer)
Perform the parsing of the specified content by using specified value producer.
auto exact(const char(&fragment)[Size])
A factory function that creates an instance of exact_fragment clause.
std::string make_error_description(const parse_error_t &error, string_view_t from)
Make textual description of error returned by try_parse function.
auto any_symbol_if_not_p(char sentinel) noexcept
A factory function to create a any_symbol_if_not_producer.
auto hexadecimal_number_p(digits_to_consume_t digits_limit) noexcept
A factory function to create a hexadecimal_number_producer.
auto as_result() noexcept
A factory function to create a as_result_consumer.
constexpr digits_to_consume_t expected_digits(digits_to_consume_t::underlying_int_t total) noexcept
Create a limit for number of digits to be extracted.
auto maybe(Clauses &&... clauses)
A factory function to create an optional clause.
auto just(T value) noexcept(noexcept(impl::just_value_transformer_t< T >{value}))
A special transformer that replaces the produced value by a value specified by a user.
auto just_result(T value) noexcept(noexcept(impl::just_result_consumer_t< T >{value}))
A special consumer that replaces the produced value by a value specified by a user and sets that user...
auto skip() noexcept
A factory function to create a skip_consumer.
error_reason_t
Reason of parsing error.
@ unexpected_eof
Unexpected end of input is encontered when some character expected.
@ force_only_this_alternative_failed
A failure of parsing an alternative marked as "force only this alternative".
@ no_appropriate_alternative
None of alternatives was found in the input.
@ unexpected_character
Unexpected character is found in the input.
@ unconsumed_input
There are some unconsumed non-whitespace characters in the input after the completion of parsing.
@ pattern_not_found
Required pattern is not found in the input.
@ illegal_value_found
Illegal value was found in the input.
auto symbol_p(char expected) noexcept
A factory function to create a symbol_producer.
auto to_lower() noexcept
A factory function to create a to_lower_transformer.
auto caseless_exact_p(const char(&fragment)[Size])
A factory function that creates an instance of caseless_exact_fragment_producer.
auto exact_p(const char(&fragment)[Size])
A factory function that creates an instance of exact_fragment_producer.
auto caseless_symbol(char expected) noexcept
A factory function to create a clause that expects the speficied symbol, extracts it and then skips i...
auto alternatives(Clauses &&... clauses)
A factory function to create an alternatives clause.
auto non_negative_decimal_number_p(digits_to_consume_t digits_limit) noexcept
A factory function to create a non_negative_decimal_number_producer.
auto convert(Converter &&converter)
A factory function to create convert_transformer.
auto produce(Clauses &&... clauses)
A factory function to create a producer that creates an instance of the target type by using specifie...
auto not_clause(Clauses &&... clauses)
A factory function to create a not_clause.
auto caseless_exact(string_view_t fragment)
A factory function that creates an instance of caseless_exact_fragment clause.
auto caseless_exact_p(string_view_t fragment)
A factory function that creates an instance of caseless_exact_fragment_producer.
auto symbol_from_range_p(char left, char right) noexcept
A factory function to create a symbol_from_range_producer.
constexpr std::size_t N
A special marker that means infinite repetitions.
auto hexdigit_p() noexcept
A factory function to create a hexdigit_producer.
auto exact_p(string_view_t fragment)
A factory function that creates an instance of exact_fragment_producer.
auto repeat(std::size_t min_occurences, std::size_t max_occurences, Clauses &&... clauses)
A factory function to create repetitor of subclauses.
auto non_negative_decimal_number_p() noexcept
A factory function to create a non_negative_decimal_number_producer.
auto decimal_number_p(digits_to_consume_t digits_limit) noexcept
A factory function to create a decimal_number_producer.
auto symbol_from_range(char left, char right) noexcept
A factory function to create a clause that expects a symbol from specified range, extracts it and the...
auto caseless_exact(const char(&fragment)[Size])
A factory function that creates an instance of caseless_exact_fragment clause.
auto hexadecimal_number_p() noexcept
A factory function to create a hexadecimal_number_producer.
auto sequence(Clauses &&... clauses)
A factory function to create a sequence of subclauses.
typename result_wrapper_for< T >::type result_wrapper_for_t
auto custom_consumer(F consumer)
A factory function to create a custom_consumer.
auto hexdigit() noexcept
A factory function to create a clause that expects a hexadecimal digit, extracts it and then skips it...
char to_lower_case(char ch)
char to_lower_case(unsigned char ch)
A predicate that allows extraction of any symbol.
constexpr bool operator()(const char) const noexcept
A special consumer that simply throws any value away.
void consume(Target_Type &, Value &&) const noexcept
A consumer for the case when the current value should be returned as the result for the producer at o...
void consume(Target_Type &dest, Value &&src) const
A predicate for cases where the case-insensitive match of expected and actual symbols is required.
caseless_particular_symbol_predicate_t(char v) noexcept
bool operator()(const char actual) const noexcept
One character extracted from the input stream.
A special base class to be used with clauses.
static constexpr entity_type_t entity_type
A special base class to be used with consumers.
static constexpr entity_type_t entity_type
A helper template for the detection of type to be produced as conversion procedure.
A predicate for cases where char to be expected to be a decimal digit.
bool operator()(const char actual) const noexcept
A predicate for cases where char to be expected to be a hexadecimal digit.
bool operator()(const char actual) const noexcept
A preducate for symbol_producer_template that checks that a symbol is a space.
bool operator()(const char actual) const noexcept
A predicate for cases where mismatch with a particular symbol is required.
bool operator()(const char actual) const noexcept
A predicate for cases where exact match of expected and actual symbols is required.
bool operator()(const char actual) const noexcept
A special base class to be used with producers.
static constexpr entity_type_t entity_type
A special wrapper for std::array type to be used inside a producer during the parsing.
std::array< T, S > m_array
A predicate for cases where a symbol should belong to specified range.
bool operator()(const char actual) const noexcept
A template for a consumer that stories values into a container.
void consume(Container &to, Item &&item)
A consumer that stores a result value at the specified index in the result tuple.
void consume(Target_Type &&to, Value &&value)
A special type to be used in the case where there is no need to store produced value.
static void as_result(wrapped_type &, result_type &&) noexcept
static result_type && unwrap_value(wrapped_type &v)
static void to_container(wrapped_type &, value_type &&) noexcept
static result_type && unwrap_value(wrapped_type &v)
static void to_container(wrapped_type &to, value_type &&what)
static void to_container(wrapped_type &to, wrapped_type &&what)
Special overload for the case when std::string should be added to another std::string.
std::basic_string< Char, Args... > result_type
static void as_result(wrapped_type &to, result_type &&what)
std::pair< K, V > value_type
std::map< K, V, Args... > result_type
static void to_container(wrapped_type &to, value_type &&what)
static void as_result(wrapped_type &to, result_type &&what)
static result_type && unwrap_value(wrapped_type &v)
typename result_type::value_type value_type
static result_type && unwrap_value(wrapped_type &v)
std::vector< T, Args... > result_type
static void as_result(wrapped_type &to, result_type &&what)
static void to_container(wrapped_type &to, value_type &&what)
A template with specializations for different kind of result values and for type nothing.
static result_type && unwrap_value(wrapped_type &v)
static void as_result(wrapped_type &to, result_type &&what)
A specialization of result_wrapper_for metafunction for the case of std::array wrapper.
result_value_wrapper< std::array< T, S > > type
A metafunction for detection of actual result_value_wrapper type for T.
result_value_wrapper< T > type