25namespace http_field_parsers
32namespace qvalue_details
73 "http_field_parser::rfc::qvalue_t" );
177 result[3] =
'0' +
static_cast<char>(
d2 / 10u);
178 const auto d3 =
d2 % 10u;
179 result[4] =
'0' +
static_cast<char>(
d3);
213 friend std::ostream &
216 return (
to << &
what.make_char_array().front());
224 return a.as_uint() ==
b.as_uint();
231 return a.as_uint() !=
b.as_uint();
238 return a.as_uint() <
b.as_uint();
245 return a.as_uint() <=
b.as_uint();
267 return (
ch >=
'\x41' &&
ch <=
'\x5A') ||
268 (
ch >=
'\x61' &&
ch <=
'\x7A');
323 return (
ch >=
'\x21' &&
ch <=
'\x7E');
359 constexpr unsigned short left = 0x80u;
360 constexpr unsigned short right = 0xFFu;
362 const unsigned short t =
static_cast<unsigned short>(
363 static_cast<unsigned char>(
ch));
385 (
ch >=
'\x23' &&
ch <=
'\x5B') ||
386 (
ch >=
'\x5D' &&
ch <=
'\x7E') ||
406 (
ch >=
'\x21' &&
ch <=
'\x27') ||
407 (
ch >=
'\x2A' &&
ch <=
'\x5B') ||
408 (
ch >=
'\x5D' &&
ch <=
'\x7E') ||
441 static constexpr bool
527 static std::optional< parse_error_t >
534 const auto ch =
from.getch();
537 reason = error_reason_t::unexpected_eof;
544 reason = error_reason_t::unexpected_character;
561 static constexpr bool
575 return { std::move(value) };
597 static std::optional< parse_error_t >
605 const auto ch =
from.getch();
608 reason = error_reason_t::unexpected_eof;
614 else if(
'\\' ==
ch.m_ch )
616 const auto next =
from.getch();
619 reason = error_reason_t::unexpected_eof;
622 else if(
SP == next.m_ch ||
HTAB == next.m_ch ||
630 reason = error_reason_t::unexpected_character;
639 reason = error_reason_t::unexpected_character;
659 const auto ch =
from.getch();
669 return { std::move(value) };
678 error_reason_t::unexpected_character
685 error_reason_t::unexpected_eof
714 const auto ch =
from.getch();
717 if(
'\\' ==
ch.m_ch )
719 const auto next =
from.getch();
722 if(
SP == next.m_ch ||
HTAB == next.m_ch ||
730 reason = error_reason_t::unexpected_character;
734 reason = error_reason_t::unexpected_character;
738 from.current_position(),
1139 []( std::string &
dest, std::string &&
what ) {
1144 ).try_parse(
from );
1321 static_assert( impl::is_producer_v<Element_Producer>,
1322 "Element_Producer should be a value producer type" );
1385 static_assert( impl::is_producer_v<Element_Producer>,
1386 "Element_Producer should be a value producer type" );
1461 static_assert( impl::is_producer_v<Element_Producer>,
1462 "Element_Producer should be a value producer type" );
1507 static_assert( impl::is_producer_v<Element_Producer>,
1508 "Element_Producer should be a value producer type" );
1534 std::vector< parameter_with_mandatory_value_t >;
1574 const auto it = std::find_if(
where.begin(),
where.end(),
1575 [&
what](
const auto & pair ) {
1576 return restinio::impl::is_equal_caseless( pair.first, what );
1587namespace params_with_value_producer_details
1610 >> ¶meter_with_mandatory_value_t::first,
1614 >> ¶meter_with_mandatory_value_t::second,
1616 >> ¶meter_with_mandatory_value_t::second
1635 :
public producer_tag< parameter_with_mandatory_value_container_t >
1686inline impl::params_with_value_producer_t
1698 std::pair< std::string, std::optional<std::string> >;
1709 std::vector< parameter_with_optional_value_t >;
1744 const auto it = std::find_if(
where.begin(),
where.end(),
1745 [&
what](
const auto & pair ) {
1746 return restinio::impl::is_equal_caseless( pair.first, what );
1750 const auto opt =
it->second;
1754 return std::optional< string_view_t >{ std::nullopt };
1763namespace params_with_opt_value_producer_details
1786 >> ¶meter_with_optional_value_t::first,
1791 >> ¶meter_with_optional_value_t::second,
1793 >> ¶meter_with_optional_value_t::second
1813 :
public producer_tag< parameter_with_optional_value_container_t >
1864inline impl::params_with_opt_value_producer_t
A helper class to automatically return acquired content back to the input stream.
The class that implements "input stream".
A template for producer of charachers that satisfy some predicate.
Information about parsing error.
Exception class for all exceptions thrown by RESTinio.
A template for a producer that handles possibly empty list of comma-separated values.
Element_Producer m_element
maybe_empty_comma_separated_list_producer_t(Element_Producer &&element)
expected_t< result_type, parse_error_t > try_parse(source_t &from)
A template for a producer that handles non-empty list of comma-separated values.
Element_Producer m_element
expected_t< result_type, parse_error_t > try_parse(source_t &from)
non_empty_comma_separated_list_producer_t(Element_Producer &&element)
expected_t< result_type, parse_error_t > try_parse(source_t &from) const noexcept
A type of producer that produces instances of parameter_with_optional_value_container.
params_with_opt_value_producer_t()=default
auto try_parse(source_t &from)
std::decay_t< decltype(params_with_opt_value_producer_details::make_parser()) > actual_producer_t
actual_producer_t m_producer
A type of producer that produces instances of parameter_with_mandatory_value_container.
auto try_parse(source_t &from)
actual_producer_t m_producer
std::decay_t< decltype(params_with_value_producer_details::make_parser()) > actual_producer_t
params_with_value_producer_t()=default
A producer for quoted_pair.
expected_t< result_type, parse_error_t > try_parse(source_t &from) const
A producer for quoted_string.
expected_t< result_type, parse_error_t > try_parse(source_t &from) const
static std::optional< parse_error_t > try_parse_value(source_t &from, std::string &accumulator)
A helper class to be used to accumulate actual integer while when the next digit is extracted from th...
void consume(zero_initialized_unit_t &dest, char &&digit)
const qvalue_t::underlying_uint_t m_multiplier
constexpr digit_consumer_t(qvalue_t::underlying_uint_t m)
An implementation of producer of qvalue.
expected_t< result_type, parse_error_t > try_parse(source_t &from) const noexcept
expected_t< result_type, parse_error_t > try_parse(source_t &from) const
static std::optional< parse_error_t > try_parse_value(source_t &from, std::string &accumulator)
static constexpr bool is_token_char(const char ch) noexcept
A helper wrapper to indicate that value is already checked and shouldn't be checked again.
const underlying_uint_t m_value
constexpr trusted(underlying_uint_t value) noexcept
constexpr auto get() const noexcept
A helper wrapper to indicate that value hasn't been checked yet and should be checked in the construc...
auto get() const noexcept
untrusted(underlying_uint_t value)
underlying_uint_t m_value
A class for holding the parsed value of qvalue from RFC7231.
constexpr qvalue_t(qvalue_details::extremum_min_t) noexcept
constexpr auto as_uint() const noexcept
std::array< char, 6 > underlying_char_array_t
underlying_char_array_t make_char_array() const noexcept
static constexpr qvalue_details::extremum_min_t zero
The indicator that tells that new qvalue object should have the minimal allowed value.
constexpr qvalue_t()=default
constexpr qvalue_t(trusted val) noexcept
underlying_uint_t m_value
qvalue_details::underlying_uint_t underlying_uint_t
The type of underlying small integer.
constexpr qvalue_t(qvalue_details::extremum_max_t) noexcept
qvalue_t(untrusted val) noexcept
friend std::ostream & operator<<(std::ostream &to, const qvalue_t &what)
static constexpr qvalue_details::extremum_max_t maximum
The indicator that tells that new qvalue object should have the maximal allowed value.
An very small, simple and somewhat limited implementation of recursive-descent parser.
constexpr char HTAB
A constant for Horizontal Tab value.
constexpr char SP
A constant for SPACE value.
@ consumer
Entity is a consumer of values. It requires a value on the input and doesn't produces anything.
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?
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 symbol(char expected) noexcept
A factory function to create a clause that expects the speficied symbol, extracts it and then skips i...
auto digit() noexcept
A factory function to create a clause that expects a decimal digit, extracts it and then skips it.
auto as_result() noexcept
A factory function to create a as_result_consumer.
auto maybe(Clauses &&... clauses)
A factory function to create an optional clause.
auto skip() noexcept
A factory function to create a skip_consumer.
error_reason_t
Reason of parsing error.
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 not_clause(Clauses &&... clauses)
A factory function to create a not_clause.
auto caseless_exact_p(string_view_t fragment)
A factory function that creates an instance of caseless_exact_fragment_producer.
constexpr std::size_t N
A special marker that means infinite repetitions.
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 sequence(Clauses &&... clauses)
A factory function to create a sequence of subclauses.
auto custom_consumer(F consumer)
A factory function to create a custom_consumer.
auto make_parser()
Helper function that creates an instance of producer of parameter_with_optional_value_container.
auto make_parser()
Helper function that creates an instance of producer of parameter_with_mandatory_value_container.
constexpr bool is_qdtext(const char ch) noexcept
Is a character a qdtext?
constexpr bool is_ctext(const char ch) noexcept
Is a character a ctext?
constexpr bool is_obs_text(const char ch) noexcept
Is a character an obs_text?
constexpr bool is_vchar(const char ch) noexcept
Is a character a VCHAR?
constexpr bool is_alpha(const char ch) noexcept
Is a character an ALPHA?
std::uint_least16_t underlying_uint_t
A type to hold a qvalue.
constexpr underlying_uint_t zero
The minimal allowed value for a qvalue.
constexpr underlying_uint_t maximum
The maximal allowed value for a qvalue.
impl::params_with_value_producer_t params_with_value_p()
A factory of producer of parameter_with_mandatory_value_container.
auto maybe_empty_comma_separated_list_p(Element_Producer element)
A factory for a producer that handles possibly empty list of comma-separated values.
expected_t< string_view_t, not_found_t > find_first(const parameter_with_mandatory_value_container_t &where, string_view_t what)
A helper function to find the first occurence of a parameter with the specified value.
auto vchar_symbol_p()
A factory for producer of VCHAR symbols.
auto qvalue_p() noexcept
A factory function to create a qvalue_producer.
auto ows_p() noexcept
A factory function to create an ows_producer.
auto token_p() noexcept
A factory function to create a token_producer.
auto ctext_symbol_p()
A factory for producer of ctext symbols.
bool operator==(const qvalue_t &a, const qvalue_t &b) noexcept
auto expected_token_p(string_view_t token)
A factory function to create a producer that expect a token with specific value.
auto non_empty_comma_separated_list_p(Element_Producer element)
A factory for a producer that handles non-empty list of comma-separated values.
std::vector< parameter_with_optional_value_t > parameter_with_optional_value_container_t
A type of container for parameters with optional values.
auto alpha_symbol_p()
A factory for producer of ALPHA symbols.
auto token_symbol_p() noexcept
A factory for producer of symbols than can be used in tokens.
bool operator!=(const qvalue_t &a, const qvalue_t &b) noexcept
std::pair< std::string, std::optional< std::string > > parameter_with_optional_value_t
A type that describes a parameter with optional value.
auto alphanum_symbol_p()
A factory for producer of symbol that an ALPHA or DIGIT.
bool operator<=(const qvalue_t &a, const qvalue_t &b) noexcept
auto weight_p() noexcept
A factory function to create a producer for weight parameter.
auto ows() noexcept
A factory function to create an OWS clause.
std::pair< std::string, std::string > parameter_with_mandatory_value_t
A type that describes a parameter with mandatory value.
auto quoted_pair_p() noexcept
A factory function to create a quoted_pair_producer.
impl::params_with_opt_value_producer_t params_with_opt_value_p()
A factory of producer of parameter_with_optional_value_container.
bool operator<(const qvalue_t &a, const qvalue_t &b) noexcept
auto quoted_string_p() noexcept
A factory function to create a quoted_string_producer.
auto comment_p()
A factory for producer of comment token.
auto expected_caseless_token_p(string_view_t token)
A factory function to create a producer that expect a token with specific value.
std::vector< parameter_with_mandatory_value_t > parameter_with_mandatory_value_container_t
A type of container for parameters with mandatory values.
run_on_this_thread_settings_t< Traits > on_this_thread()
A special marker for the case when http_server must be run on the context of the current thread.
std::string_view string_view_t
nonstd::expected< T, E > expected_t
Helpers for caseless comparison of strings.
One character extracted from the input stream.
A special base class to be used with consumers.
A special base class to be used with producers.
std::optional< char > result_type
A preducate for symbol_producer_template that checks that a symbol is an alpha.
bool operator()(const char actual) const noexcept
A preducate for symbol_producer_template that checks that a symbol is an alpha or numeric.
bool operator()(const char actual) const noexcept
A preducate for symbol_producer_template that checks that a symbol is a ctext.
bool operator()(const char actual) const noexcept
A predicate for symbol_producer_template that checks that a symbol can be used inside a token.
static constexpr bool is_token_char(const char ch) noexcept
bool operator()(const char actual) const noexcept
A preducate for symbol_producer_template that checks that a symbol is a VCHAR.
bool operator()(const char actual) const noexcept
qvalue_t::underlying_uint_t m_value
An empty type to be used as indicator of negative search result.