restinio::http_field_parsers Namespace Reference

## Namespaces

namespace | accept_language_details
namespace | authorization_details
namespace | basic_auth
namespace | bearer_auth
namespace | content_disposition_details
namespace | details
namespace | host_details
namespace | impl
namespace | qvalue_details
namespace | range_details
namespace | try_extract_field_details

## Classes

struct | accept_charset_value_t
| Tools for working with the value of Accept-Charset HTTP-field. More...
struct | accept_encoding_value_t
| Tools for working with the value of Accept-Encoding HTTP-field. More...
struct | accept_language_value_t
| Tools for working with the value of Accept-Language HTTP-field. More...
struct | accept_value_t
| Tools for working with the value of Accept HTTP-field. More...
struct | authorization_value_t
| Tools for working with the value of Authorization HTTP-field. More...
struct | cache_control_value_t
| Tools for working with the value of Cache-Control HTTP-field. More...
struct | connection_value_t
| Tools for working with the value of Connection HTTP-field. More...
struct | content_disposition_value_t
| Tools for working with the value of Content-Disposition HTTP-field. More...
struct | content_encoding_value_t
| Tools for working with the value of Content-Encoding HTTP-field. More...
struct | content_type_value_t
| Tools for working with the value of Content-Type HTTP-field. More...
struct | field_not_found_t
| A special type to be returned in the case if HTTP-field isn't found in a request. More...
struct | media_type_value_t
| Tools for working with media-type in HTTP-fields. More...
struct | not_found_t
| An empty type to be used as indicator of negative search result. More...
class | qvalue_t
| A class for holding the parsed value of qvalue from RFC7231. More...
struct | range_value_t
| Tools for working with the value of Range HTTP-field. More...
struct | raw_host_value_t
| Tools for working with the raw value of Host HTTP-field. More...
struct | transfer_encoding_value_t
| Tools for working with the value of Transfer-Encoding HTTP-field. More...
struct | user_agent_value_t
| Tools for working with the value of User-Agent HTTP-field. More...

## Typedefs

using | parameter_with_mandatory_value_t = std::pair< std::string, std::string >
| A type that describes a parameter with mandatory value. More...
using | parameter_with_mandatory_value_container_t = std::vector< parameter_with_mandatory_value_t >
| A type of container for parameters with mandatory values. More...
using | parameter_with_optional_value_t = std::pair< std::string, restinio::optional_t< std::string > >
| A type that describes a parameter with optional value. More...
using | parameter_with_optional_value_container_t = std::vector< parameter_with_optional_value_t >
| A type of container for parameters with optional values. More...

## Functions

std::ostream & | operator<< (std::ostream &to, const authorization_value_t::param_value_t &v)
std::ostream & | operator<< (std::ostream &to, const authorization_value_t::param_t &v)
std::ostream & | operator<< (std::ostream &to, const authorization_value_t::auth_param_t &p)
std::ostream & | operator<< (std::ostream &to, const authorization_value_t &v)
RESTINIO_NODISCARD bool | operator== (const qvalue_t &a, const qvalue_t &b) noexcept
RESTINIO_NODISCARD bool | operator!= (const qvalue_t &a, const qvalue_t &b) noexcept
RESTINIO_NODISCARD bool | operator< (const qvalue_t &a, const qvalue_t &b) noexcept
RESTINIO_NODISCARD bool | operator<= (const qvalue_t &a, const qvalue_t &b) noexcept
RESTINIO_NODISCARD auto | alpha_symbol_p ()
| A factory for producer of ALPHA symbols. More...
RESTINIO_NODISCARD auto | alphanum_symbol_p ()
| A factory for producer of symbol that an ALPHA or DIGIT. More...
RESTINIO_NODISCARD auto | vchar_symbol_p ()
| A factory for producer of VCHAR symbols. More...
RESTINIO_NODISCARD auto | ctext_symbol_p ()
| A factory for producer of ctext symbols. More...
RESTINIO_NODISCARD auto | comment_p ()
| A factory for producer of comment token. More...
RESTINIO_NODISCARD auto | ows_p () noexcept
| A factory function to create an ows_producer. More...
RESTINIO_NODISCARD auto | ows () noexcept
| A factory function to create an OWS clause. More...
RESTINIO_NODISCARD auto | token_symbol_p () noexcept
| A factory for producer of symbols than can be used in tokens. More...
RESTINIO_NODISCARD auto | token_p () noexcept
| A factory function to create a token_producer. More...
RESTINIO_NODISCARD auto | quoted_string_p () noexcept
| A factory function to create a quoted_string_producer. More...
RESTINIO_NODISCARD auto | quoted_pair_p () noexcept
| A factory function to create a quoted_pair_producer. More...
RESTINIO_NODISCARD auto | expected_token_p (string_view_t token)
| A factory function to create a producer that expect a token with specific value. More...
RESTINIO_NODISCARD auto | expected_caseless_token_p (string_view_t token)
| A factory function to create a producer that expect a token with specific value. More...
RESTINIO_NODISCARD auto | qvalue_p () noexcept
| A factory function to create a qvalue_producer. More...
RESTINIO_NODISCARD auto | weight_p () noexcept
| A factory function to create a producer for weight parameter. More...
template<typename Container , typename Element_Producer >
RESTINIO_NODISCARD auto | non_empty_comma_separated_list_p (Element_Producer element)
| A factory for a producer that handles non-empty list of comma-separated values. More...
template<typename Container , typename Element_Producer >
RESTINIO_NODISCARD auto | maybe_empty_comma_separated_list_p (Element_Producer element)
| A factory for a producer that handles possibly empty list of comma-separated values. More...
RESTINIO_NODISCARD 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. More...
RESTINIO_NODISCARD impl::params_with_value_producer_t | params_with_value_p ()
| A factory of producer of parameter_with_mandatory_value_container. More...
RESTINIO_NODISCARD expected_t< restinio::optional_t< string_view_t >, not_found_t > | find_first (const parameter_with_optional_value_container_t &where, string_view_t what)
| A helper function to find the first occurence of a parameter with the specified value. More...
RESTINIO_NODISCARD impl::params_with_opt_value_producer_t | params_with_opt_value_p ()
| A factory of producer of parameter_with_optional_value_container. More...
std::ostream & | operator<< (std::ostream &to, const raw_host_value_t &rhv)
template<typename Parsed_Field_Type , typename Extra_Data >
RESTINIO_NODISCARD auto | try_parse_field (const generic_request_t< Extra_Data > &req, string_view_t field_name, string_view_t default_value=string_view_t{})
| A helper function for extraction and parsing a value of HTTP-field. More...
template<typename Parsed_Field_Type , typename Extra_Data >
RESTINIO_NODISCARD auto | try_parse_field (const generic_request_t< Extra_Data > &req, http_field_t field_id, string_view_t default_value=string_view_t{})
| A helper function for extraction and parsing a value of HTTP-field. More...

## Typedef Documentation

## parameter_with_mandatory_value_container_t

using restinio::http_field_parsers::parameter_with_mandatory_value_container_t = typedef std::vector< parameter_with_mandatory_value_t >

A type of container for parameters with mandatory values.

Since
  v.0.6.1

Definition at line 1531 of file basics.hpp.

## parameter_with_mandatory_value_t

using restinio::http_field_parsers::parameter_with_mandatory_value_t = typedef std::pair< std::string, std::string >

A type that describes a parameter with mandatory value.

Since
  v.0.6.1

Definition at line 1521 of file basics.hpp.

## parameter_with_optional_value_container_t

using restinio::http_field_parsers::parameter_with_optional_value_container_t = typedef std::vector< parameter_with_optional_value_t >

A type of container for parameters with optional values.

Since
  v.0.6.1

Definition at line 1706 of file basics.hpp.

## parameter_with_optional_value_t

using restinio::http_field_parsers::parameter_with_optional_value_t = typedef std::pair< std::string, restinio::optional_t<std::string> >

A type that describes a parameter with optional value.

Since
  v.0.6.1

Definition at line 1695 of file basics.hpp.

## Function Documentation

## alpha_symbol_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::alpha_symbol_p | ( |  | ) |

inline

A factory for producer of ALPHA symbols.

Usage example:

produce<std::string>(
repeat(1, 20, alpha_symbol_p() >> to_container());
restinio::easy_parser::repeat
RESTINIO_NODISCARD auto repeat(std::size_t min_occurences, std::size_t max_occurences, Clauses &&... clauses)
A factory function to create repetitor of subclauses.
Definition: easy_parser.hpp:3876
restinio::easy_parser::to_container
RESTINIO_NODISCARD auto to_container()
A factory function to create a to_container_consumer.
Definition: easy_parser.hpp:4583
restinio::http_field_parsers::alpha_symbol_p
RESTINIO_NODISCARD auto alpha_symbol_p()
A factory for producer of ALPHA symbols.
Definition: basics.hpp:788

Since
  v.0.6.2

Definition at line 788 of file basics.hpp.

## alphanum_symbol_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::alphanum_symbol_p | ( |  | ) |

inline

A factory for producer of symbol that an ALPHA or DIGIT.

Usage example:

produce<std::string>(
repeat(1, 20, alphanum_symbol_p() >> to_container());
restinio::http_field_parsers::alphanum_symbol_p
RESTINIO_NODISCARD auto alphanum_symbol_p()
A factory for producer of symbol that an ALPHA or DIGIT.
Definition: basics.hpp:810

Since
  v.0.6.2

Definition at line 810 of file basics.hpp.

## comment_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::comment_p | ( |  | ) |

inline

A factory for producer of comment token.

Usage example:

produce<std::string>(
alternatives(
token_p() >> as_result(),
comment_p() >> as_result()
)
);
restinio::easy_parser::as_result
RESTINIO_NODISCARD auto as_result() noexcept
A factory function to create a as_result_consumer.
Definition: easy_parser.hpp:4470
restinio::easy_parser::alternatives
RESTINIO_NODISCARD auto alternatives(Clauses &&... clauses)
A factory function to create an alternatives clause.
Definition: easy_parser.hpp:3595
restinio::http_field_parsers::comment_p
RESTINIO_NODISCARD auto comment_p()
A factory for producer of comment token.
Definition: basics.hpp:880
restinio::http_field_parsers::token_p
RESTINIO_NODISCARD auto token_p() noexcept
A factory function to create a token_producer.
Definition: basics.hpp:985

Since
  v.0.6.4

Definition at line 880 of file basics.hpp.

## ctext_symbol_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::ctext_symbol_p | ( |  | ) |

inline

A factory for producer of ctext symbols.

Usage example:

produce<std::string>(
repeat(1, 20, ctext_symbol_p() >> to_container());
restinio::http_field_parsers::ctext_symbol_p
RESTINIO_NODISCARD auto ctext_symbol_p()
A factory for producer of ctext symbols.
Definition: basics.hpp:854

Since
  v.0.6.4

Definition at line 854 of file basics.hpp.

## expected_caseless_token_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::expected_caseless_token_p | ( | string_view_t | token | ) |

inline

A factory function to create a producer that expect a token with specific value.

This processer uses case-insensitive comparison.

If the expected token is successfully parsed then boolean value is produced.

Usage example:

enum class compression { zlib, bz2, xz };
produce<compression>(
caseless_expected_token_p("Compression") >> skip(),
ows(),
symbol('='),
ows(),
alternatives(
caseless_expected_token_p("ZLib") >> just_result(compression::zlib),
caseless_expected_token_p("BZ2") >> just_result(compression::bz2),
caseless_expected_token_p("xz") >> just_result(compression::xz)
)
);
restinio::easy_parser::symbol
RESTINIO_NODISCARD auto symbol(char expected) noexcept
A factory function to create a clause that expects the speficied symbol, extracts it and then skips i...
Definition: easy_parser.hpp:4032
restinio::easy_parser::skip
RESTINIO_NODISCARD auto skip() noexcept
A factory function to create a skip_consumer.
Definition: easy_parser.hpp:3922
restinio::easy_parser::just_result
RESTINIO_NODISCARD 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...
Definition: easy_parser.hpp:4664
restinio::http_field_parsers::ows
RESTINIO_NODISCARD auto ows() noexcept
A factory function to create an OWS clause.
Definition: basics.hpp:939

Since
  v.0.6.9

Definition at line 1112 of file basics.hpp.

## expected_token_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::expected_token_p | ( | string_view_t | token | ) |

inline

A factory function to create a producer that expect a token with specific value.

If the expected token is successfully parsed then boolean value is produced.

Usage example:

enum class compression { zlib, bz2, xz };
produce<compression>(
expected_token_p("compression") >> skip(),
ows(),
symbol('='),
ows(),
alternatives(
expected_token_p("zlib") >> just_result(compression::zlib),
expected_token_p("bz2") >> just_result(compression::bz2),
expected_token_p("xz") >> just_result(compression::xz)
)
);
restinio::http_field_parsers::expected_token_p
RESTINIO_NODISCARD auto expected_token_p(string_view_t token)
A factory function to create a producer that expect a token with specific value.
Definition: basics.hpp:1073

Since
  v.0.6.9

Definition at line 1073 of file basics.hpp.

## find_first() [1/2]

RESTINIO_NODISCARD expected_t< string_view_t, not_found_t > restinio::http_field_parsers::find_first | ( | const parameter_with_mandatory_value_container_t & | where,
|  | string_view_t | what
| ) |  |

inline

A helper function to find the first occurence of a parameter with the specified value.

Note
  The caseless (case-insentive) search is used. It means that search with value "charset" will returns items "CharSet", "charset", "CHARSET" and so on.

Usage example:

const auto charset = find_first(content_type_params, "charset");
if(charset) {
... // Handle the value of charset parameter.
}
restinio::http_field_parsers::find_first
RESTINIO_NODISCARD 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.
Definition: basics.hpp:1568

Since
  v.0.6.1

Definition at line 1568 of file basics.hpp.

## find_first() [2/2]

RESTINIO_NODISCARD expected_t< restinio::optional_t< string_view_t >, not_found_t > restinio::http_field_parsers::find_first | ( | const parameter_with_optional_value_container_t & | where,
|  | string_view_t | what
| ) |  |

inline

A helper function to find the first occurence of a parameter with the specified value.

Note
  The caseless (case-insentive) search is used. It means that search with value "charset" will returns items "CharSet", "charset", "CHARSET" and so on.

Usage example:

const auto max_age = find_first(cache_control_params, "max-age");
if(max_age) {
if(*max_age) {
... // Handle the value of max-age parameter.
}
else {
... // Handle the case where max-age specified but without a value.
}
}

Since
  v.0.6.1

Definition at line 1738 of file basics.hpp.

## maybe_empty_comma_separated_list_p()

template<typename Container , typename Element_Producer >

RESTINIO_NODISCARD auto restinio::http_field_parsers::maybe_empty_comma_separated_list_p | ( | Element_Producer | element | ) |

A factory for a producer that handles possibly empty list of comma-separated values.

That producer handles the following rule:

    #element => [ ( "," / element ) *( OWS "," [ OWS element ] ) ]

See: https://tools.ietf.org/html/rfc7230 (section "7. ABNF List Extension: #rule")

Usage example:

auto parse = produce< byte_ranges_data >(
make_bytes_prefix_parser(),
maybe_empty_comma_separated_list_p< std::vector< byte_range > >(
make_byte_range_parser()
) >> &byte_ranges_data::ranges
);
restinio::http_field_parsers::range_details::make_bytes_prefix_parser
RESTINIO_NODISCARD auto make_bytes_prefix_parser()
Factory for a parser of 'bytes=' prefix.
Definition: range.hpp:184
restinio::http_field_parsers::maybe_empty_comma_separated_list_p
RESTINIO_NODISCARD auto maybe_empty_comma_separated_list_p(Element_Producer element)
A factory for a producer that handles possibly empty list of comma-separated values.
Definition: basics.hpp:1503
restinio::path2regex::impl::parse
token_list_t< Route_Param_Appender > parse(string_view_t route_sv, const options_t &options)
Parse a string for the raw tokens.
Definition: path2regex.hpp:676

Template Parameters

  Container | the type of container to be produced.
  Element_Producer | the type of the producer of a single item.

Since
  v.0.6.1

Definition at line 1503 of file basics.hpp.

## non_empty_comma_separated_list_p()

template<typename Container , typename Element_Producer >

RESTINIO_NODISCARD auto restinio::http_field_parsers::non_empty_comma_separated_list_p | ( | Element_Producer | element | ) |

A factory for a producer that handles non-empty list of comma-separated values.

That producer handles the following rule:

    1#element => *( "," OWS ) element *( OWS "," [ OWS element ] )

See: https://tools.ietf.org/html/rfc7230 (section "7. ABNF List Extension: #rule")

Usage example:

auto parse = produce< byte_ranges_data >(
make_bytes_prefix_parser(),
non_empty_comma_separated_list_p< std::vector< byte_range > >(
make_byte_range_parser()
) >> &byte_ranges_data::ranges
);
restinio::http_field_parsers::non_empty_comma_separated_list_p
RESTINIO_NODISCARD auto non_empty_comma_separated_list_p(Element_Producer element)
A factory for a producer that handles non-empty list of comma-separated values.
Definition: basics.hpp:1457

Template Parameters

  Container | the type of container to be produced.
  Element_Producer | the type of the producer of a single item.

Since
  v.0.6.1

Definition at line 1457 of file basics.hpp.

## operator!=()

RESTINIO_NODISCARD bool restinio::http_field_parsers::operator!= | ( | const qvalue_t & | a,
|  | const qvalue_t & | b
| ) |  |

inlinenoexcept

Definition at line 227 of file basics.hpp.

## operator<()

RESTINIO_NODISCARD bool restinio::http_field_parsers::operator< | ( | const qvalue_t & | a,
|  | const qvalue_t & | b
| ) |  |

inlinenoexcept

Definition at line 233 of file basics.hpp.

## operator<<() [1/5]

std::ostream & restinio::http_field_parsers::operator<< | ( | std::ostream & | to,
|  | const authorization_value_t & | v
| ) |  |

inline

Definition at line 306 of file authorization.hpp.

## operator<<() [2/5]

std::ostream & restinio::http_field_parsers::operator<< | ( | std::ostream & | to,
|  | const authorization_value_t::auth_param_t & | p
| ) |  |

inline

Definition at line 268 of file authorization.hpp.

## operator<<() [3/5]

std::ostream & restinio::http_field_parsers::operator<< | ( | std::ostream & | to,
|  | const authorization_value_t::param_t & | v
| ) |  |

inline

Definition at line 260 of file authorization.hpp.

## operator<<() [4/5]

std::ostream & restinio::http_field_parsers::operator<< | ( | std::ostream & | to,
|  | const authorization_value_t::param_value_t & | v
| ) |  |

inline

Definition at line 248 of file authorization.hpp.

## operator<<() [5/5]

std::ostream & restinio::http_field_parsers::operator<< | ( | std::ostream & | to,
|  | const raw_host_value_t & | rhv
| ) |  |

inline

Definition at line 556 of file host.hpp.

## operator<=()

RESTINIO_NODISCARD bool restinio::http_field_parsers::operator<= | ( | const qvalue_t & | a,
|  | const qvalue_t & | b
| ) |  |

inlinenoexcept

Definition at line 240 of file basics.hpp.

## operator==()

RESTINIO_NODISCARD bool restinio::http_field_parsers::operator== | ( | const qvalue_t & | a,
|  | const qvalue_t & | b
| ) |  |

inlinenoexcept

Definition at line 220 of file basics.hpp.

## ows()

RESTINIO_NODISCARD auto restinio::http_field_parsers::ows | ( |  | ) |

inlinenoexcept

A factory function to create an OWS clause.

This clause handles an optional sequence of spaces in the input stream and skips the value of that sequence.

Usage example:

produce<std::string>(
ows(),
symbol('v'),
symbol('='),
ows(),
token_p() >> as_result()
);

This expression corresponds the following rule:

    T := OWS 'v' '=' OWS token

Since
  v.0.6.1

Definition at line 939 of file basics.hpp.

## ows_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::ows_p | ( |  | ) |

inlinenoexcept

A factory function to create an ows_producer.

Usage example:

produce<std::string>(
ows_p() >> skip(),
symbol('v'),
symbol('='),
ows_p() >> skip(),
token_p() >> as_result()
);
restinio::http_field_parsers::ows_p
RESTINIO_NODISCARD auto ows_p() noexcept
A factory function to create an ows_producer.
Definition: basics.hpp:909

Note
  Factory function ows() can be used instead of expression `ows_p() >> skip()`.

Since
  v.0.6.1

Definition at line 909 of file basics.hpp.

## params_with_opt_value_p()

RESTINIO_NODISCARD impl::params_with_opt_value_producer_t restinio::http_field_parsers::params_with_opt_value_p | ( |  | ) |

inline

A factory of producer of parameter_with_optional_value_container.

Creates a produces that handles the following rule:

    T := *( OWS ';' OWS token ['=' OWS (token / quoted_string)] )

Usage example:

struct my_field {
std::string value;
parameter_with_optional_value_container_t params;
};
produce<my_field>(
token_p() >> to_lower() >> &my_field::value,
params_with_opt_value_p() >> &my_field::params
);
restinio::easy_parser::to_lower
RESTINIO_NODISCARD auto to_lower() noexcept
A factory function to create a to_lower_transformer.
Definition: easy_parser.hpp:4610
restinio::http_field_parsers::params_with_opt_value_p
RESTINIO_NODISCARD impl::params_with_opt_value_producer_t params_with_opt_value_p()
A factory of producer of parameter_with_optional_value_container.
Definition: basics.hpp:1863
restinio::http_field_parsers::parameter_with_optional_value_container_t
std::vector< parameter_with_optional_value_t > parameter_with_optional_value_container_t
A type of container for parameters with optional values.
Definition: basics.hpp:1707

Note
  Parameters names are converted to lower case. Parameters' values are not changed and stored as they are.

Since
  v.0.6.1

Definition at line 1863 of file basics.hpp.

## params_with_value_p()

RESTINIO_NODISCARD impl::params_with_value_producer_t restinio::http_field_parsers::params_with_value_p | ( |  | ) |

inline

A factory of producer of parameter_with_mandatory_value_container.

Creates a produces that handles the following rule:

    T := *( OWS ';' OWS token '=' OWS (token / quoted_string))

Usage example:

struct my_field {
std::string value;
parameter_with_mandatory_value_container_t params;
};
produce<my_field>(
token_p() >> to_lower() >> &my_field::value,
params_with_value_p() >> &my_field::params
);
restinio::http_field_parsers::params_with_value_p
RESTINIO_NODISCARD impl::params_with_value_producer_t params_with_value_p()
A factory of producer of parameter_with_mandatory_value_container.
Definition: basics.hpp:1685
restinio::http_field_parsers::parameter_with_mandatory_value_container_t
std::vector< parameter_with_mandatory_value_t > parameter_with_mandatory_value_container_t
A type of container for parameters with mandatory values.
Definition: basics.hpp:1532

Note
  Parameters names are converted to lower case. Parameters' values are not changed and stored as they are.

Since
  v.0.6.1

Definition at line 1685 of file basics.hpp.

## quoted_pair_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::quoted_pair_p | ( |  | ) |

inlinenoexcept

A factory function to create a quoted_pair_producer.

Usage example:

produce<std::string>(
repeat(1, N,
alternatives(
ctext_symbol_p() >> to_container(),
quoted_pair_p() >> to_container()
)
);
restinio::easy_parser::N
constexpr std::size_t N
A special marker that means infinite repetitions.
Definition: easy_parser.hpp:455
restinio::http_field_parsers::quoted_pair_p
RESTINIO_NODISCARD auto quoted_pair_p() noexcept
A factory function to create a quoted_pair_producer.
Definition: basics.hpp:1038

Since
  v.0.6.4

Definition at line 1038 of file basics.hpp.

## quoted_string_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::quoted_string_p | ( |  | ) |

inlinenoexcept

A factory function to create a quoted_string_producer.

Usage example:

using parameter = std::pair<std::string, std::string>;
produce<parameter>(
ows(),
token_p() >> &parameter::first,
symbol('='),
ows(),
alternatives(
token_p() >> &parameter::second,
quoted_string_p() >> &parameter::second
)
);
restinio::http_field_parsers::quoted_string_p
RESTINIO_NODISCARD auto quoted_string_p() noexcept
A factory function to create a quoted_string_producer.
Definition: basics.hpp:1012

Since
  v.0.6.1

Definition at line 1012 of file basics.hpp.

## qvalue_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::qvalue_p | ( |  | ) |

inlinenoexcept

A factory function to create a qvalue_producer.

Usage example:

produce<qvalue_t>(
alternatives(symbol('r'), symbol('R')),
symbol('='),
qvalue_p() >> as_result()
);
restinio::http_field_parsers::qvalue_p
RESTINIO_NODISCARD auto qvalue_p() noexcept
A factory function to create a qvalue_producer.
Definition: basics.hpp:1250

Since
  v.0.6.1

Definition at line 1250 of file basics.hpp.

## token_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::token_p | ( |  | ) |

inlinenoexcept

A factory function to create a token_producer.

Usage example:

using parameter = std::pair<std::string, std::string>;
produce<parameter>(
ows(),
token_p() >> &parameter::first,
symbol('='),
ows(),
token_p() >> &parameter::second
);

Since
  v.0.6.1

Definition at line 985 of file basics.hpp.

## token_symbol_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::token_symbol_p | ( |  | ) |

inlinenoexcept

A factory for producer of symbols than can be used in tokens.

Usage example:

produce<std::string>(
repeat(1, 20, token_symbol_p() >> to_container());
restinio::http_field_parsers::token_symbol_p
RESTINIO_NODISCARD auto token_symbol_p() noexcept
A factory for producer of symbols than can be used in tokens.
Definition: basics.hpp:957

Since
  v.0.6.9

Definition at line 957 of file basics.hpp.

## try_parse_field() [1/2]

template<typename Parsed_Field_Type , typename Extra_Data >

RESTINIO_NODISCARD auto restinio::http_field_parsers::try_parse_field | ( | const generic_request_t< Extra_Data > & | req,
|  | http_field_t | field_id,
|  | string_view_t | default_value = `string_view_t{}`
| ) |  |

A helper function for extraction and parsing a value of HTTP-field.

This helper is intended to be used when HTTP-field is identified by its ID.

Usage example:

auto on_post(const restinio::request_handle_t & req) {
using namespace restinio::http_field_parsers;
const auto auth_field = try_parse_field< authorization_value_t >(
req, restinio::http_field::authorization);
if(auto * auth = restinio::get_if<authorization_value_t>(&auth_field)) {
// Authorization is successfully parsed.
if("basic" == auth->auth_scheme) {
... // Dealing with basic authentification.
}
else if("bearer" == auth->auth_scheme) {
... // Dealing with bearer authentification.
}
else {
...
}
}
}
restinio::http_field_parsers
Definition: accept-charset.hpp:20
restinio::request_handle_t
std::shared_ptr< request_t > request_handle_t
An alias for handle for incoming request without additional extra-data.
Definition: request_handler.hpp:463

Template Parameters

  Parsed_Field_Type | The type of field value to be received as the result of successful parse if the field is present.
  Extra_Data | The type of extra-data incorporated into an instance of restinio::generic_request_t. There is no need to specify that type, it has to be detected automatically by the compiler.

Since
  v.0.6.8

Parameters

  req | A request that should hold a HTTP-field.
  field_id | The ID of a HTTP-field to be extracted and parsed.
  default_value | The default value to be used if HTTP-field is not found. If this value is not empty, then the variant with field_not_found_t won't be returned.

Definition at line 209 of file try_parse_field.hpp.

## try_parse_field() [2/2]

template<typename Parsed_Field_Type , typename Extra_Data >

RESTINIO_NODISCARD auto restinio::http_field_parsers::try_parse_field | ( | const generic_request_t< Extra_Data > & | req,
|  | string_view_t | field_name,
|  | string_view_t | default_value = `string_view_t{}`
| ) |  |

A helper function for extraction and parsing a value of HTTP-field.

This helper is intended to be used when HTTP-field is identified by its name.

Usage example:

auto on_post(const restinio::request_handle_t & req) {
using namespace restinio::http_field_parsers;
const auto auth_field = try_parse_field< authorization_value_t >(
req, "X-My-Authorization");
if(auto * auth = restinio::get_if<authorization_value_t>(&auth_field)) {
// X-My-Authorization is successfully parsed.
if("basic" == auth->auth_scheme) {
... // Dealing with basic authentification.
}
else if("bearer" == auth->auth_scheme) {
... // Dealing with bearer authentification.
}
else {
...
}
}
}

Template Parameters

  Parsed_Field_Type | The type of field value to be received as the result of successful parse if the field is present.
  Extra_Data | The type of extra-data incorporated into an instance of restinio::generic_request_t. There is no need to specify that type, it has to be detected automatically by the compiler.

Since
  v.0.6.8

Parameters

  req | A request that should hold a HTTP-field.
  field_name | The name of HTTP-field to be extracted and parsed.
  default_value | The default value to be used if HTTP-field is not found. If this value is not empty, then the variant with field_not_found_t won't be returned.

Definition at line 151 of file try_parse_field.hpp.

## vchar_symbol_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::vchar_symbol_p | ( |  | ) |

inline

A factory for producer of VCHAR symbols.

Usage example:

produce<std::string>(
repeat(1, 20, vchar_symbol_p() >> to_container());
restinio::http_field_parsers::vchar_symbol_p
RESTINIO_NODISCARD auto vchar_symbol_p()
A factory for producer of VCHAR symbols.
Definition: basics.hpp:832

Since
  v.0.6.2

Definition at line 832 of file basics.hpp.

## weight_p()

RESTINIO_NODISCARD auto restinio::http_field_parsers::weight_p | ( |  | ) |

inlinenoexcept

A factory function to create a producer for weight parameter.

Returns a producer that handles the following rules:

    weight = OWS ';' OWS ('q' / 'Q') '=' qvalue

    qvalue = ( "0" [ "." 0*3DIGIT ] )
           / ( "1" [ "." 0*3("0") ] )

See: https://tools.ietf.org/html/rfc7231

That producer produces a value of type qvalue_t.

Since
  v.0.6.1

Definition at line 1277 of file basics.hpp.