RESTinio
Loading...
Searching...
No Matches
restinio::easy_parser::impl Namespace Reference

Classes

class  alternatives_clause_t
 A template for implementation of clause that selects one of alternative clauses. More...
class  and_clause_t
 A template for implementation of clause that checks the presence of some entity in the input stream. More...
class  any_symbol_if_not_producer_t
 A producer for the case when any character except the specific sentinel character is expected in the input stream. More...
struct  any_symbol_predicate_t
 A predicate that allows extraction of any symbol. More...
struct  any_value_skipper_t
 A special consumer that simply throws any value away. More...
struct  as_result_consumer_t
 A consumer for the case when the current value should be returned as the result for the producer at one level up. More...
class  caseless_exact_fixed_size_fragment_producer_t
 A producer that expects a fragment in the input and produces boolean value if that fragment is found. More...
class  caseless_exact_fragment_producer_t
 A producer that expects a fragment in the input and produces boolean value if that fragment is found. More...
struct  caseless_particular_symbol_predicate_t
 A predicate for cases where the case-insensitive match of expected and actual symbols is required. More...
class  caseless_symbol_producer_t
 A producer for the case when a particual character is expected in the input stream. More...
struct  character_t
 One character extracted from the input stream. More...
struct  clause_tag
 A special base class to be used with clauses. More...
class  consume_value_clause_t
 A template for a clause that binds a value producer with value consumer. More...
struct  consumer_tag
 A special base class to be used with consumers. More...
struct  conversion_result_type_detector
 A helper template for the detection of type to be produced as conversion procedure. More...
struct  conversion_result_type_detector< expected_t< Result_Type, error_reason_t > >
class  convert_transformer_proxy_t
 A proxy for the creation of convert_transformer instances for a specific value producers. More...
class  convert_transformer_t
 A transformator that uses a user supplied function/functor for conversion a value from one type to another. More...
class  custom_consumer_t
 A template for consumers that are released by lambda/functional objects. More...
class  decimal_number_producer_t
 A producer for the case when a signed decimal number is expected in the input stream. More...
class  decimal_number_producer_with_digits_limit_t
 A producer for the case when a signed decimal number is expected in the input stream. More...
class  digit_producer_t
 A producer for the case when a decimal digit is expected in the input stream. More...
class  exact_fixed_size_fragment_producer_t
 A producer that expects a fragment in the input and produces boolean value if that fragment is found. More...
class  exact_fragment_producer_t
 A producer that expects a fragment in the input and produces boolean value if that fragment is found. More...
class  field_setter_consumer_t
 A template for consumers that store a value to the specified field of a target object. More...
class  forced_alternative_clause_t
 An alternative that should be parsed correctly or the parsing of the whole alternatives clause should fail. More...
class  hexadecimal_number_producer_t
 A producer for the case when a number in hexadecimal form is expected in the input stream. More...
class  hexadecimal_number_producer_with_digits_limit_t
 A producer for the case when a number in hexadecimal form is expected in the input stream. More...
class  hexdigit_producer_t
 A producer for the case when a hexadecimal digit is expected in the input stream. More...
struct  is_appropriate_transformer_result_type
 A metafunction that checks is Result_Type can be used as the result of transformation method. More...
struct  is_appropriate_transformer_result_type< expected_t< Result_Type, error_reason_t > >
struct  is_appropriate_transformer_result_type< expected_t< Result_Type, parse_error_t > >
struct  is_clause
struct  is_clause< T, meta::void_t< decltype(std::decay_t< T >::entity_type) > >
struct  is_consumer
struct  is_consumer< T, meta::void_t< decltype(T::entity_type) > >
struct  is_digit_predicate_t
 A predicate for cases where char to be expected to be a decimal digit. More...
struct  is_hexdigit_predicate_t
 A predicate for cases where char to be expected to be a hexadecimal digit. More...
struct  is_producer
struct  is_producer< T, meta::void_t< decltype(T::entity_type) > >
struct  is_space_predicate_t
 A preducate for symbol_producer_template that checks that a symbol is a space. More...
struct  is_transformer
struct  is_transformer< T, meta::void_t< decltype(T::entity_type) > >
struct  is_transformer_proxy
struct  is_transformer_proxy< T, meta::void_t< decltype(T::entity_type) > >
class  just_result_consumer_t
 A consumer for the case when a specific value should be used as the result instead of the value produced on the previous step. More...
class  just_value_transformer_t
 A transformer that skips incoming value and returns a value specified by a user. More...
class  maybe_clause_t
 A template for implementation of clause that checks and handles presence of optional entity in the input stream. More...
class  non_negative_decimal_number_producer_t
 A producer for the case when a non-negative decimal number is expected in the input stream. More...
class  non_negative_decimal_number_producer_with_digits_limit_t
 A producer for the case when a non-negative decimal number is expected in the input stream. More...
class  not_clause_t
 A template for implementation of clause that checks absence of some entity in the input stream. More...
struct  not_particular_symbol_predicate_t
 A predicate for cases where mismatch with a particular symbol is required. More...
struct  particular_symbol_predicate_t
 A predicate for cases where exact match of expected and actual symbols is required. More...
class  produce_t
 A template for producing a value of specific type of a sequence of entities from the input stream. More...
struct  producer_tag
 A special base class to be used with producers. More...
class  repeat_clause_t
 A template for handling repetition of clauses. More...
class  sequence_clause_t
 A template for implementation of clause that checks and handles presence of sequence of entities in the input stream. More...
class  source_t
 The class that implements "input stream". More...
struct  std_array_wrapper
 A special wrapper for std::array type to be used inside a producer during the parsing. More...
struct  symbol_from_range_predicate_t
 A predicate for cases where a symbol should belong to specified range. More...
class  symbol_from_range_producer_t
 A producer for the case when a symbol should belong to specified range. More...
class  symbol_producer_t
 A producer for the case when a particual character is expected in the input stream. More...
class  symbol_producer_template_t
 A template for producer of charachers that satisfy some predicate. More...
struct  to_container_consumer_t
 A template for a consumer that stories values into a container. More...
struct  to_lower_transformer_proxy_t
 A proxy for the creation of an appropriate to_lower_transformer. More...
struct  to_lower_transformer_t
struct  to_lower_transformer_t< char >
 An implementation of transformer that converts the content of the input character to lower case. More...
struct  to_lower_transformer_t< std::array< char, S > >
 An implementation of transformer that converts the content of the input std::array to lower case. More...
struct  to_lower_transformer_t< std::string >
 An implementation of transformer that converts the content of the input std::string to lower case. More...
class  top_level_clause_t
 A special class to be used as the top level clause in parser. More...
class  transformed_value_producer_t
 A template of producer that gets a value from another producer, transforms it and produces transformed value. More...
struct  transformed_value_producer_traits_checker
 A helper template for checking a possibility to connect a producer with a transformer. More...
struct  transformer_invoker
 A helper template for calling transformation function. More...
struct  transformer_invoker< expected_t< Result_Type, error_reason_t > >
struct  transformer_proxy_tag
 A special base class to be used with transformer-proxies. More...
struct  transformer_tag
 A special base class to be used with transformers. More...
struct  tuple_item_consumer_t
 A consumer that stores a result value at the specified index in the result tuple. More...

Typedefs

template<typename... Entities>
using tuple_of_entities_t
 A helper meta-function to create an actual type of tuple with clauses/producers.
template<typename Result_Type>
using conversion_result_type_detector_t

Enumerations

enum class  entity_type_t {
  producer , transformer , consumer , clause ,
  transformer_proxy
}
 A marker for distinguish different kind of entities in parser. More...

Functions

bool operator== (const character_t &a, const character_t &b) noexcept
bool operator!= (const character_t &a, const character_t &b) noexcept
constexpr bool is_space (const char ch) noexcept
 If a character a space character?
constexpr bool is_digit (const char ch) noexcept
 Is a character a decimal digit?
constexpr bool is_hexdigit (const char ch) noexcept
 Is a character a hexadecimal digit?
template<typename P, typename T>
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.
template<typename P, typename T, typename S = std::enable_if_t< is_producer_v<P> & is_transformer_proxy_v<T>, void >>
auto operator>> (P producer, T transformer_proxy)
 A special operator to connect a value producer with value transformer via transformer-proxy.
template<typename P, typename C>
std::enable_if_t< is_producer_v< P > &&is_consumer_v< C >, consume_value_clause_t< P, C > > operator>> (P producer, C consumer)
 A special operator to connect a value producer with a value consumer.
std::optional< parse_error_tensure_no_remaining_content (source_t &from)
 A special function to check that there is no more actual data in the input stream except whitespaces.
string_view_t remove_trailing_spaces (string_view_t from) noexcept
 Helper function for removal of trailing spaces from a string-view.
template<typename T, typename Value_Accumulator>
expected_t< T, parse_error_ttry_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.
template<typename T, typename Value_Accumulator>
expected_t< T, parse_error_ttry_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.
template<typename P, typename F, typename C>
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.
template<typename It>
expected_t< bool, parse_error_ttry_parse_exact_fragment (source_t &from, It begin, It end)
template<typename It>
expected_t< bool, parse_error_ttry_parse_caseless_exact_fragment (source_t &from, It begin, It end)

Variables

constexpr char SP = ' '
 A constant for SPACE value.
constexpr char HTAB = '\x09'
 A constant for Horizontal Tab value.
template<typename T>
constexpr bool is_producer_v = is_producer<T>::value
 A meta-value to check whether T is a producer type.
template<typename T>
constexpr bool is_transformer_v = is_transformer<T>::value
 A meta-value to check whether T is a transformer type.
template<typename T>
constexpr bool is_transformer_proxy_v = is_transformer_proxy<T>::value
 A meta-value to check whether T is a transformer-proxy type.
template<typename T>
constexpr bool is_consumer_v = is_consumer<T>::value
 A meta-value to check whether T is a consumer type.
template<typename T>
constexpr bool is_clause_v = is_clause<T>::value
 A meta-value to check whether T is a consumer type.

Typedef Documentation

◆ conversion_result_type_detector_t

Initial value:

A helper for simplification of usage of conversion_result_type_detector<R>.

Since
v.0.6.11

Definition at line 3243 of file easy_parser.hpp.

◆ tuple_of_entities_t

template<typename... Entities>
using restinio::easy_parser::impl::tuple_of_entities_t
Initial value:
meta::rename_t<
meta::transform_t< std::decay, meta::type_list<Entities...> >,
std::tuple >

A helper meta-function to create an actual type of tuple with clauses/producers.

Usage example:

template< typename... Clauses >
auto
some_clause( Clauses && ...clauses ) {
using clause_type = impl::some_clause_t<
return clause_type{ std::forward<Clauses>(clauses)... };
}
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.

The tuple_of_entities_t takes care about such cases as references and constness of parameters. For example:

auto c = symbol('c');
const auto b = symbol('b');
auto clause = some_clause(c, b);
@ clause
Entity is a clause. It doesn't produces anything.
auto symbol(char expected) noexcept
A factory function to create a clause that expects the speficied symbol, extracts it and then skips i...

In that case Clauses... will be symbol_clause_t&, const symbol_clause_t&. And an attempt to make type std::tuple<Clauses...> will produce type std::tuple<symbol_clause_t&, const symbol_clause_t&>. But we need std::tuple<symbol_clause_t, symbol_clause_t>. This result will be obtained if tuple_of_entities_t is used instead of std::tuple.

Since
v.0.6.6

Definition at line 1457 of file easy_parser.hpp.

Enumeration Type Documentation

◆ entity_type_t

A marker for distinguish different kind of entities in parser.

Since
v.0.6.1
Enumerator
producer 

Entity is a producer of values.

transformer 

Entity is a transformer of a value from one type to another.

consumer 

Entity is a consumer of values. It requires a value on the input and doesn't produces anything.

clause 

Entity is a clause. It doesn't produces anything.

transformer_proxy 

Entity is a transformer-proxy. It can't be used directly, only for binding a producer and transformer together.

Since
v.0.6.6.

Definition at line 901 of file easy_parser.hpp.

Function Documentation

◆ ensure_no_remaining_content()

std::optional< parse_error_t > restinio::easy_parser::impl::ensure_no_remaining_content ( source_t & from)
inlinenodiscard

A special function to check that there is no more actual data in the input stream except whitespaces.

Returns
parse_error_t if some non-whitespace character is found in the input stream.
Since
v.0.6.1

Definition at line 1567 of file easy_parser.hpp.

◆ is_digit()

bool restinio::easy_parser::impl::is_digit ( const char ch)
inlinenodiscardconstexprnoexcept

Is a character a decimal digit?

Since
v.0.6.1

Definition at line 670 of file easy_parser.hpp.

◆ is_hexdigit()

bool restinio::easy_parser::impl::is_hexdigit ( const char ch)
inlinenodiscardconstexprnoexcept

Is a character a hexadecimal digit?

Since
v.0.6.6

Definition at line 703 of file easy_parser.hpp.

◆ is_space()

bool restinio::easy_parser::impl::is_space ( const char ch)
inlinenodiscardconstexprnoexcept

If a character a space character?

Since
v.0.6.1

Definition at line 636 of file easy_parser.hpp.

◆ operator!=()

bool restinio::easy_parser::impl::operator!= ( const character_t & a,
const character_t & b )
inlinenodiscardnoexcept

Definition at line 608 of file easy_parser.hpp.

◆ operator==()

bool restinio::easy_parser::impl::operator== ( const character_t & a,
const character_t & b )
inlinenodiscardnoexcept

Definition at line 601 of file easy_parser.hpp.

◆ operator>>() [1/4]

template<typename P, typename C>
std::enable_if_t< is_producer_v< P > &&is_consumer_v< C >, consume_value_clause_t< P, C > > restinio::easy_parser::impl::operator>> ( P producer,
C consumer )
nodiscard

A special operator to connect a value producer with a value consumer.

Since
v.0.6.1

Definition at line 1514 of file easy_parser.hpp.

◆ operator>>() [2/4]

template<typename P, typename F, typename C>
std::enable_if_t< is_producer_v< P >, consume_value_clause_t< P, field_setter_consumer_t< F, C > > > restinio::easy_parser::impl::operator>> ( P producer,
F C::* member_ptr )
nodiscard

A special operator to connect a value producer with field_setter_consumer.

Since
v.0.6.1

Definition at line 3003 of file easy_parser.hpp.

◆ operator>>() [3/4]

template<typename P, typename T>
std::enable_if_t< is_producer_v< P > &is_transformer_v< T >, transformed_value_producer_t< P, T > > restinio::easy_parser::impl::operator>> ( P producer,
T transformer )
nodiscard

A special operator to connect a value producer with value transformer.

Since
v.0.6.1

Definition at line 1234 of file easy_parser.hpp.

◆ operator>>() [4/4]

template<typename P, typename T, typename S = std::enable_if_t< is_producer_v<P> & is_transformer_proxy_v<T>, void >>
auto restinio::easy_parser::impl::operator>> ( P producer,
T transformer_proxy )
nodiscard

A special operator to connect a value producer with value transformer via transformer-proxy.

Since
v.0.6.6

Definition at line 1307 of file easy_parser.hpp.

◆ remove_trailing_spaces()

string_view_t restinio::easy_parser::impl::remove_trailing_spaces ( string_view_t from)
inlinenodiscardnoexcept

Helper function for removal of trailing spaces from a string-view.

Since
v.0.6.7

Definition at line 1595 of file easy_parser.hpp.

◆ try_parse_caseless_exact_fragment()

template<typename It>
expected_t< bool, parse_error_t > restinio::easy_parser::impl::try_parse_caseless_exact_fragment ( source_t & from,
It begin,
It end )
nodiscard

Definition at line 3420 of file easy_parser.hpp.

◆ try_parse_digits_with_digits_limit()

template<typename T, typename Value_Accumulator>
expected_t< T, parse_error_t > restinio::easy_parser::impl::try_parse_digits_with_digits_limit ( source_t & from,
digits_to_consume_t digits_limit,
Value_Accumulator acc )
nodiscardnoexcept

Helper function for parsing integers with respect to the number of digits to be consumed.

Usage example:

// For the case of unsigned or positive signed integer:
// For the case of negative signed integer.
short,
10,
Helper class for accumulating integer value during parsing it from string (with check for overflow).
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 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.
Since
v.0.6.6

Definition at line 2438 of file easy_parser.hpp.

◆ try_parse_exact_fragment()

template<typename It>
expected_t< bool, parse_error_t > restinio::easy_parser::impl::try_parse_exact_fragment ( source_t & from,
It begin,
It end )
nodiscard

Definition at line 3314 of file easy_parser.hpp.

◆ try_parse_hexdigits_with_digits_limit()

template<typename T, typename Value_Accumulator>
expected_t< T, parse_error_t > restinio::easy_parser::impl::try_parse_hexdigits_with_digits_limit ( source_t & from,
digits_to_consume_t digits_limit,
Value_Accumulator acc )
nodiscardnoexcept

Helper function for parsing integers in hexadecimal form.

Usage example:

// For the case of unsigned or positive signed integer:
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.
Since
v.0.6.6

Definition at line 2502 of file easy_parser.hpp.

Variable Documentation

◆ HTAB

char restinio::easy_parser::impl::HTAB = '\x09'
constexpr

A constant for Horizontal Tab value.

Since
v.0.6.1

Definition at line 624 of file easy_parser.hpp.

◆ is_clause_v

template<typename T>
bool restinio::easy_parser::impl::is_clause_v = is_clause<T>::value
constexpr

A meta-value to check whether T is a consumer type.

Note
The current implementation checks only the presence of T::entity_type of type entity_type_t and the value of T::entity_type. Presence of T::try_process is not checked.
Since
v.0.6.1

Definition at line 1421 of file easy_parser.hpp.

◆ is_consumer_v

template<typename T>
bool restinio::easy_parser::impl::is_consumer_v = is_consumer<T>::value
constexpr

A meta-value to check whether T is a consumer type.

Note
The current implementation checks only the presence of T::entity_type of type entity_type_t and the value of T::entity_type. Presence of T::consume is not checked.
Since
v.0.6.1

Definition at line 1368 of file easy_parser.hpp.

◆ is_producer_v

template<typename T>
bool restinio::easy_parser::impl::is_producer_v = is_producer<T>::value
constexpr

A meta-value to check whether T is a producer type.

Note
The current implementation checks only the presence of T::entity_type of type entity_type_t and the value of T::entity_type. Presence of T::result_type and T::try_parse is not checked.
Since
v.0.6.1

Definition at line 971 of file easy_parser.hpp.

◆ is_transformer_proxy_v

template<typename T>
bool restinio::easy_parser::impl::is_transformer_proxy_v = is_transformer_proxy<T>::value
constexpr

A meta-value to check whether T is a transformer-proxy type.

Note
The current implementation checks only the presence of T::entity_type of type entity_type_t and the value of T::entity_type.
Since
v.0.6.6

Definition at line 1291 of file easy_parser.hpp.

◆ is_transformer_v

template<typename T>
bool restinio::easy_parser::impl::is_transformer_v = is_transformer<T>::value
constexpr

A meta-value to check whether T is a transformer type.

Note
The current implementation checks only the presence of T::entity_type of type entity_type_t and the value of T::entity_type. Presence of T::result_type and T::transform is not checked.
Since
v.0.6.1

Definition at line 1025 of file easy_parser.hpp.

◆ SP

char restinio::easy_parser::impl::SP = ' '
constexpr

A constant for SPACE value.

Since
v.0.6.1

Definition at line 618 of file easy_parser.hpp.