RESTinio
accept.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// accept_value_t
24//
52{
53 struct item_t
54 {
56
58
62 };
63
64 using item_container_t = std::vector< item_t >;
65
67
74 static auto
76 {
77 const auto media_type = media_type_value_t::make_weight_aware_parser();
78
79 return produce< accept_value_t >(
80 maybe_empty_comma_separated_list_p< item_container_t >(
81 produce< item_t >(
82 media_type >> &item_t::media_type,
83 maybe(
86 )
87 )
89 );
90 }
91
100 {
102 }
103};
104
105} /* namespace http_field_parsers */
106
107} /* namespace restinio */
108
#define RESTINIO_NODISCARD
Stuff related to Media-Type value in HTTP-fields.
RESTINIO_NODISCARD auto maybe(Clauses &&... clauses)
A factory function to create an optional clause.
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.
std::pair< std::string, restinio::optional_t< std::string > > parameter_with_optional_value_t
A type that describes a parameter with optional value.
Definition: basics.hpp:1696
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
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
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
parameter_with_optional_value_container_t accept_ext_container_t
Definition: accept.hpp:57
parameter_with_optional_value_t accept_ext_t
Definition: accept.hpp:55
restinio::optional_t< qvalue_t > weight
Definition: accept.hpp:60
Tools for working with the value of Accept HTTP-field.
Definition: accept.hpp:52
static RESTINIO_NODISCARD auto make_parser()
A factory function for a parser of Accept value.
Definition: accept.hpp:75
static RESTINIO_NODISCARD expected_t< accept_value_t, restinio::easy_parser::parse_error_t > try_parse(string_view_t what)
An attempt to parse Accept HTTP-field.
Definition: accept.hpp:99
std::vector< item_t > item_container_t
Definition: accept.hpp:64
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