179template<
typename T >
188 to = std::move(what);
244template<
typename T >
250template<
typename T >
253template<
typename T,
typename... Args >
263 to = std::move(what);
269 to.push_back( std::move(what) );
298template<
typename T, std::
size_t S >
307template<
typename T, std::
size_t S >
308struct result_value_wrapper< std::array< T, S > >
311 using value_type =
typename result_type::value_type;
317 to.m_array = std::move(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);
338 return std::move(
v.m_array);
348template<
typename T, std::
size_t S >
354template<
typename Char,
typename... Args >
364 to = std::move(what);
370 to.push_back( what );
400template<
typename K,
typename V,
typename... Args >
413 to = std::move(what);
419 to.emplace( std::move(what) );
456constexpr std::size_t
N = std::numeric_limits<std::size_t>::max();
517 constexpr static auto
520 return std::numeric_limits<underlying_int_t>::max();
527 constexpr static auto
549inline constexpr digits_to_consume_t
570inline constexpr digits_to_consume_t
603 return (a.m_eof == b.m_eof && a.m_ch == b.m_ch);
610 return (a.m_eof != b.m_eof || a.m_ch != b.m_ch);
618constexpr char SP =
' ';
638 return ch ==
SP || ch ==
HTAB;
672 return (ch >=
'0' && ch <=
'9');
705 return (ch >=
'0' && ch <=
'9') ||
706 (ch >=
'A' && ch <=
'F') ||
707 (ch >=
'a' && ch <=
'f');
797 if( pos <=
m_data.size() )
819 string_view_t::size_type from,
823 string_view_t::size_type length = string_view_t::npos )
const noexcept
825 return m_data.substr( from, length );
944template<
typename Result_Type >
951template<
typename T,
typename = meta::
void_t<> >
954template<
typename T >
970template<
typename T >
998template<
typename Result_Type >
1005template<
typename T,
typename = meta::
void_t<> >
1008template<
typename T >
1024template<
typename T >
1047template<
typename Result_Type >
1050 template<
typename Transformer,
typename Input_Type >
1058 return transformer.transform( std::move(*input) );
1068template<
typename Result_Type >
1071 template<
typename Transformer,
typename Input_Type >
1080 auto result =
transformer.transform( std::move(*input) );
1110template<
typename Result_Type >
1116template<
typename Result_Type >
1123template<
typename Result_Type >
1144template<
typename Producer,
typename Transformer >
1148 "Producer should be a producer type" );
1150 "Transformer should be a transformer type" );
1153 std::declval<Producer &>().try_parse( std::declval<source_t &>() )
1157 std::declval<Transformer &>().transform(
1158 std::move(*(std::declval<producer_result_t>())) )
1179template<
typename Producer,
typename Transformer >
1181 :
public producer_tag< typename Transformer::result_type >
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>" );
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() );
1229template<
typename P,
typename T >
1233 transformed_value_producer_t< P, T > >
1272template<
typename T,
typename = meta::
void_t<> >
1275template<
typename T >
1290template<
typename T >
1302 typename S = std::enable_if_t<
1312 typename P::result_type >();
1314 using transformator_type = std::decay_t<
decltype(real_transformer) >;
1318 return producer_type{ std::move(
producer), std::move(real_transformer) };
1348template<
typename T,
typename = meta::
void_t<> >
1351template<
typename T >
1367template<
typename T >
1398template<
typename T,
typename = meta::
void_t<> >
1401template<
typename T >
1403 decltype(std::decay_t<T>::entity_type) > >
1420template<
typename T >
1456template<
typename... Entities >
1458 meta::transform_t< std::decay, meta::type_list<Entities...> >,
1473template<
typename P,
typename C >
1488 template<
typename Target_Type >
1490 std::optional< parse_error_t >
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();
1509template<
typename P,
typename C >
1513 consume_value_clause_t< P, C > >
1532template<
typename Producer >
1536 "Producer should be a producer type" );
1566inline std::optional< parse_error_t >
1570 while( !from.
eof() )
1582 return std::nullopt;
1597 auto s = from.size();
1598 for(; s &&
is_space( from[ (s-1u) ] ); --s) {}
1600 return from.substr( 0u, s );
1635 typename Subitems_Tuple >
1642 Subitems_Tuple && subitems )
1646 template<
typename Target_Type >
1648 std::optional< parse_error_t >
1653 std::optional< parse_error_t > actual_parse_error;
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;
1716 typename Subitems_Tuple >
1723 Subitems_Tuple && subitems )
1727 template<
typename Target_Type >
1729 std::optional< parse_error_t >
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;
1779 typename Subitems_Tuple >
1786 Subitems_Tuple && subitems )
1790 template<
typename Target_Type >
1792 std::optional< parse_error_t >
1798 Target_Type dummy_value;
1802 [&from, &dummy_value](
auto && one_producer ) {
1803 return !one_producer.try_process( from, dummy_value );
1816 return std::nullopt;
1847 typename Subitems_Tuple >
1854 Subitems_Tuple && subitems )
1858 template<
typename Target_Type >
1860 std::optional< parse_error_t >
1866 Target_Type dummy_value;
1870 [&from, &dummy_value](
auto && one_producer ) {
1871 return !one_producer.try_process( from, dummy_value );
1880 return std::nullopt;
1908 typename Subitems_Tuple >
1915 Subitems_Tuple && subitems )
1919 template<
typename Target_Type >
1921 std::optional< parse_error_t >
1925 Target_Type tmp_value{ target };
1928 std::optional< parse_error_t > result;
1932 [&from, &tmp_value, &result](
auto && one_producer ) {
1933 result = one_producer.try_process( from, tmp_value );
1939 target = std::move(tmp_value);
1961 typename Subitems_Tuple >
1967 using base_type_t::base_type_t;
1969 template<
typename Target_Type >
1971 std::optional< parse_error_t >
1986 return std::nullopt;
2008 typename Target_Type,
2009 typename Subitems_Tuple >
2018 Subitems_Tuple && subitems )
2027 std::optional< parse_error_t > error;
2031 [&from, &tmp_value, &error](
auto && one_clause ) {
2032 error = one_clause.try_process( from, tmp_value );
2039 return make_unexpected( *error );
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 >
2080 std::optional< parse_error_t >
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 )
2100 item_consumer.commit();
2107 whole_consumer.commit();
2108 return std::nullopt;
2130template<
typename Predicate >
2133 ,
protected Predicate
2136 template<
typename... Args >
2138 : Predicate{ std::forward<Args>(args)... }
2145 const auto ch = from.getch();
2149 if( (*
this)(ch.m_ch) )
2155 from.current_position(),
2162 from.current_position(),
2435template<
typename T,
typename Value_Accumulator >
2441 Value_Accumulator acc )
noexcept
2447 for(
auto ch = from.getch(); !ch.m_eof; ch = from.getch() )
2451 acc.next_digit(
static_cast<T
>(ch.m_ch -
'0') );
2453 if( acc.overflow_detected() )
2459 ++symbols_processed;
2460 if( symbols_processed == digits_limit.max() )
2470 if( symbols_processed < digits_limit.min() )
2473 from.current_position(),
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) );
2522 for(
auto ch = from.getch(); !ch.m_eof; ch = from.getch() )
2524 const auto d = ch_to_digit( ch.m_ch );
2527 acc.next_digit( d.second );
2529 if( acc.overflow_detected() )
2535 ++symbols_processed;
2536 if( symbols_processed == digits_limit.max() )
2546 if( symbols_processed < digits_limit.min() )
2549 from.current_position(),
2570template<
typename T >
2598template<
typename T >
2632template<
typename T >
2635 static_assert( std::is_unsigned<T>::value,
2636 "T is expected to be unsigned type" );
2663template<
typename T >
2697template<
typename T >
2700 static_assert( std::is_signed<T>::value,
2701 "decimal_number_producer_t can be used only for signed types" );
2717 template<
typename Digits_Limit_Maker >
2722 Digits_Limit_Maker && digits_limit_maker )
const noexcept
2726 auto sign_ch = from.getch();
2727 if( !sign_ch.m_eof )
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
2758 if(
'-' == first_symbol )
2762 digits_limit_maker(),
2763 overflow_controlled_integer_accumulator_t<
2766 check_negative_extremum >{} );
2768 return static_cast< T
>( -(*r) );
2774 else if(
'+' == first_symbol )
2778 digits_limit_maker(),
2779 overflow_controlled_integer_accumulator_t< T, 10 >{} );
2786 digits_limit_maker(),
2787 overflow_controlled_integer_accumulator_t< T, 10 >{} );
2791 from.current_position(),
2810template<
typename T >
2845 template<
typename Target_Type,
typename Value >
2847 consume( Target_Type &, Value && ) const noexcept {}
2872 template<
typename Target_Type,
typename Value >
2877 dest, std::forward<Value>(src) );
2891template<
typename Result_Type >
2904 noexcept(noexcept(Result_Type{
m_result}))
2910 template<
typename Result_Arg >
2912 noexcept(
noexcept(Result_Type{std::forward<Result_Arg>(result)}))
2913 :
m_result{ std::forward<Result_Arg>(result) }
2916 template<
typename Target_Type,
typename Value >
2939template<
typename C >
2947 template<
typename Target_Type,
typename Value >
2950 noexcept(
noexcept(
m_consumer(dest, std::forward<Value>(src))))
2952 m_consumer( dest, std::forward<Value>(src) );
2968template<
typename F,
typename C >
2986 noexcept(
noexcept(to.*
m_ptr = std::move(value)))
2988 to.*
m_ptr = std::move(value);
2998template<
typename P,
typename F,
typename C >
3002 consume_value_clause_t< P, field_setter_consumer_t<F,C> > >
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 >
3061 std::transform( result.begin(), result.end(), result.begin(),
3062 [](
unsigned char ch ) ->
char {
3063 return restinio::impl::to_lower_case(ch);
3096template< std::
size_t S >
3108 std::transform( input.begin(), input.end(), result.begin(),
3109 [](
unsigned char ch ) ->
char {
3110 return restinio::impl::to_lower_case(ch);
3127 template<
typename Input_Type >
3145template<
typename T >
3155 template<
typename Input >
3173template<
typename Output_Type,
typename Converter >
3179 template<
typename Convert_Arg >
3181 noexcept(
noexcept(Converter{std::forward<Convert_Arg>(converter)}))
3182 :
m_converter{ std::forward<Convert_Arg>(converter) }
3193 template<
typename Input >
3197 noexcept(
noexcept(
m_converter(std::forward<Input>(input))))
3199 using actual_result_t = std::decay_t<
decltype(
3205 "the return value of converter should be either Output_Type or "
3206 "expected_t<Output_Type, error_reason_t>" );
3225template<
typename Result_Type >
3231template<
typename Result_Type >
3242template<
typename Result_Type >
3262template<
typename Converter >
3265 template<
typename Input_Type >
3267 std::decay_t<
decltype(
3268 std::declval<Converter &>()(std::declval<Input_Type&&>())
3275 template<
typename Convert_Arg >
3277 noexcept(
noexcept(Converter{std::forward<Convert_Arg>(converter)}))
3278 :
m_converter{ std::forward<Convert_Arg>(converter) }
3281 template<
typename Input_Type >
3292 template<
typename Input_Type >
3296 noexcept(
noexcept(Converter{std::move(
m_converter)}))
3311template<
typename It >
3316 assert( begin != end );
3322 if( ch.m_ch != *begin )
3327 if( ++begin == end )
3354template< std::
size_t Size >
3358 static_assert( 1u < Size,
"Size is expected to greater that 1" );
3398 throw exception_t(
"'fragment' value for exact_fragment_producer_t "
3399 "can't be empty!" );
3417template<
typename It >
3422 assert( begin != end );
3433 if( ++begin == end )
3462template< std::
size_t Size >
3466 static_assert( 1u < Size,
"Size is expected to greater that 1" );
3479 [](
const char src ) {
3480 return restinio::impl::to_lower_case( src );
3514 throw exception_t(
"'fragment' value for exact_fragment_producer_t "
3515 "can't be empty!" );
3551 typename Target_Type,
3552 typename... Clauses >
3557 static_assert( 0 !=
sizeof...(clauses),
3558 "list of clauses can't be empty" );
3560 "all arguments for produce() should be clauses" );
3566 return producer_type_t{
3567 std::make_tuple(std::forward<Clauses>(clauses)...)
3593template<
typename... Clauses >
3598 static_assert( 0 !=
sizeof...(clauses),
3599 "list of clauses can't be empty" );
3601 "all arguments for alternatives() should be clauses" );
3606 return clause_type_t{
3607 std::make_tuple(std::forward<Clauses>(clauses)...)
3632template<
typename... Clauses >
3637 static_assert( 0 !=
sizeof...(clauses),
3638 "list of clauses can't be empty" );
3640 "all arguments for maybe() should be clauses" );
3645 return clause_type_t{
3646 std::make_tuple(std::forward<Clauses>(clauses)...)
3674template<
typename... Clauses >
3679 static_assert( 0 !=
sizeof...(clauses),
3680 "list of clauses can't be empty" );
3682 "all arguments for not_clause() should be clauses" );
3687 return clause_type_t{
3688 std::make_tuple(std::forward<Clauses>(clauses)...)
3716template<
typename... Clauses >
3721 static_assert( 0 !=
sizeof...(clauses),
3722 "list of clauses can't be empty" );
3724 "all arguments for sequence() should be clauses" );
3729 return clause_type_t{
3730 std::make_tuple(std::forward<Clauses>(clauses)...)
3756template<
typename... Clauses >
3761 static_assert( 0 !=
sizeof...(clauses),
3762 "list of clauses can't be empty" );
3764 "all arguments for sequence() should be clauses" );
3769 return clause_type_t{
3770 std::make_tuple(std::forward<Clauses>(clauses)...)
3819template<
typename... Clauses >
3824 static_assert( 0 !=
sizeof...(clauses),
3825 "list of clauses can't be empty" );
3827 "all arguments for force_only_this_alternative() should "
3833 return clause_type_t{
3834 std::make_tuple(std::forward<Clauses>(clauses)...)
3874 typename... Clauses >
3879 std::size_t min_occurences,
3886 std::size_t max_occurences,
3888 Clauses &&... clauses )
3890 static_assert( 0 !=
sizeof...(clauses),
3891 "list of clauses can't be empty" );
3893 "all arguments for repeat() should be clauses" );
3898 return producer_type_t{
3901 std::make_tuple(std::forward<Clauses>(clauses)...)
4216template<
typename T >
4255template<
typename T >
4285template<
typename T >
4327template<
typename T >
4365template<
typename T >
4370 static_assert( std::is_signed<T>::value,
4371 "decimal_number_p() can be used only for signed numeric types" );
4418template<
typename T >
4423 static_assert( std::is_signed<T>::value,
4424 "decimal_number_p() can be used only for signed numeric types" );
4494template<
typename F >
4501 return actual_consumer_t{ std::move(consumer) };
4523 template<
typename Container,
typename Item >
4528 container_adaptor_type::to_container( to, std::move(item) );
4613template<
typename T >
4618 return impl::just_value_transformer_t<T>{value};
4642template<
typename T >
4648 return impl::just_result_consumer_t<T>{value};
4715template<
typename Converter >
4720 using converter_type = std::decay_t<Converter>;
4725 return transformer_proxy_type{ std::forward<Converter>(converter) };
4752 std::string{ fragment.data(), fragment.size() }
4790template< std::
size_t Size >
4817 std::string{ fragment.data(), fragment.size() }
4849template< std::
size_t Size >
4881 std::string{ fragment.data(), fragment.size() }
4919template< std::
size_t Size >
4946 std::string{ fragment.data(), fragment.size() }
4978template< std::
size_t Size >
5020template<
typename Producer >
5028 "Producer should be a value producer type" );
5039 const auto all_content_check =
5041 if( all_content_check )
5042 return make_unexpected( *all_content_check );
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,
'"' );
5098 &from[ error.
position() ] - prefix_size,
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,
'\'' );
5121 if( error.
position() + 1u < from.size() )
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) {
5139 result += std::to_string( error.
position() );
5141 append_quote( result );
5147 basic_reaction(
"unexpected character" );
5151 result +=
"unexpected EOF at ";
5152 result += std::to_string( error.
position() );
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.
std::int_fast8_t underlying_int_t
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
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
expected_t< T, parse_error_t > try_parse_result_type
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.
string_view_t::size_type position_t
Type to be used as the index inside the input stream.
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)
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.
Helper class for accumulating integer value during parsing it from string (with check for overflow).
Detection of compiler version and absence of various features.
expected_t< bool, parse_error_t > try_parse_exact_fragment(source_t &from, It begin, It end)
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
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.
meta::rename_t< meta::transform_t< std::decay, meta::type_list< Entities... > >, std::tuple > tuple_of_entities_t
A helper meta-function to create an actual type of tuple with clauses/producers.
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.
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.
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 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_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 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 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 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)
bool all_of(Tuple &&tuple, Predicate &&predicate)
bool any_of(Tuple &&tuple, Predicate &&predicate)
std::string_view string_view_t
nonstd::expected< T, E > expected_t
Helper for parsing integer values.
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)
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
Various meta-functions for operating the content of a tuple.