RESTinio
media-type.hpp
Go to the documentation of this file.
1/*
2 * RESTinio
3 */
4
12#pragma once
13
15
16namespace restinio
17{
18
19namespace http_field_parsers
20{
21
22//
23// media_type_value_t
24//
42{
44
46
47 std::string type;
48 std::string subtype;
50
65 static auto
67 {
68 return produce< media_type_value_t >(
70 symbol('/'),
73 );
74 }
75
92 static auto
94 {
95 return produce< media_type_value_t >(
97 symbol('/'),
99 produce< parameter_container_t >(
100 repeat( 0, N,
101 produce< parameter_t >(
102 not_clause( weight_p() >> skip() ),
103 ows(),
104 symbol(';'),
105 ows(),
106 token_p() >> to_lower() >> &parameter_t::first,
107 symbol('='),
109 token_p() >> &parameter_t::second,
110 quoted_string_p() >> &parameter_t::second
111 )
112 ) >> to_container()
113 )
115 );
116 }
117
129 {
131 }
132};
133
134} /* namespace http_field_parsers */
135
136} /* namespace restinio */
137
Utilities for parsing values of http-fields.
#define RESTINIO_NODISCARD
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...
RESTINIO_NODISCARD 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.
RESTINIO_NODISCARD auto repeat(std::size_t min_occurences, std::size_t max_occurences, Clauses &&... clauses)
A factory function to create repetitor of subclauses.
RESTINIO_NODISCARD auto skip() noexcept
A factory function to create a skip_consumer.
constexpr std::size_t N
A special marker that means infinite repetitions.
RESTINIO_NODISCARD auto to_container()
A factory function to create a to_container_consumer.
RESTINIO_NODISCARD auto not_clause(Clauses &&... clauses)
A factory function to create a not_clause.
RESTINIO_NODISCARD auto to_lower() noexcept
A factory function to create a to_lower_transformer.
RESTINIO_NODISCARD auto alternatives(Clauses &&... clauses)
A factory function to create an alternatives clause.
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
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
RESTINIO_NODISCARD auto ows() noexcept
A factory function to create an OWS clause.
Definition: basics.hpp:939
RESTINIO_NODISCARD auto token_p() noexcept
A factory function to create a token_producer.
Definition: basics.hpp:985
RESTINIO_NODISCARD auto quoted_string_p() noexcept
A factory function to create a quoted_string_producer.
Definition: basics.hpp:1012
std::pair< std::string, std::string > parameter_with_mandatory_value_t
A type that describes a parameter with mandatory value.
Definition: basics.hpp:1521
RESTINIO_NODISCARD auto weight_p() noexcept
A factory function to create a producer for weight parameter.
Definition: basics.hpp:1277
nonstd::string_view string_view_t
Definition: string_view.hpp:19
nonstd::expected< T, E > expected_t
Definition: expected.hpp:22
Tools for working with media-type in HTTP-fields.
Definition: media-type.hpp:42
static RESTINIO_NODISCARD auto make_weight_aware_parser()
Definition: media-type.hpp:93
static RESTINIO_NODISCARD expected_t< media_type_value_t, restinio::easy_parser::parse_error_t > try_parse(string_view_t what)
An attempt to parse media-type value.
Definition: media-type.hpp:128
static RESTINIO_NODISCARD auto make_default_parser()
Definition: media-type.hpp:66
parameter_with_mandatory_value_container_t parameter_container_t
Definition: media-type.hpp:45
parameter_with_mandatory_value_t parameter_t
Definition: media-type.hpp:43