RESTinio
accept.hpp
Go to the documentation of this file.
1 /*
2  * RESTinio
3  */
4 
12 #pragma once
13 
15 
16 namespace restinio
17 {
18 
19 namespace 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 
RESTINIO_NODISCARD
#define RESTINIO_NODISCARD
Definition: compiler_features.hpp:33
restinio::http_field_parsers::accept_value_t::try_parse
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
restinio::http_field_parsers::accept_value_t::item_container_t
std::vector< item_t > item_container_t
Definition: accept.hpp:64
restinio::string_view_t
nonstd::string_view string_view_t
Definition: string_view.hpp:19
restinio::http_field_parsers::accept_value_t::item_t::accept_ext_container_t
parameter_with_optional_value_container_t accept_ext_container_t
Definition: accept.hpp:57
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::accept_value_t::item_t
Definition: accept.hpp:54
restinio::easy_parser::try_parse
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.
Definition: easy_parser.hpp:5042
restinio::http_field_parsers::media_type_value_t::make_weight_aware_parser
static RESTINIO_NODISCARD auto make_weight_aware_parser()
Definition: media-type.hpp:93
restinio::http_field_parsers::weight_p
RESTINIO_NODISCARD auto weight_p() noexcept
A factory function to create a producer for weight parameter.
Definition: basics.hpp:1277
nonstd::optional_lite::optional
class optional
Definition: optional.hpp:839
restinio::http_field_parsers::media_type_value_t
Tools for working with media-type in HTTP-fields.
Definition: media-type.hpp:42
restinio::expected_t
nonstd::expected< T, E > expected_t
Definition: expected.hpp:22
restinio::http_field_parsers::parameter_with_optional_value_t
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::http_field_parsers::accept_value_t::make_parser
static RESTINIO_NODISCARD auto make_parser()
A factory function for a parser of Accept value.
Definition: accept.hpp:75
restinio
Definition: asio_include.hpp:21
restinio::http_field_parsers::accept_value_t::item_t::accept_params
accept_ext_container_t accept_params
Definition: accept.hpp:61
restinio::http_field_parsers::accept_value_t::item_t::accept_ext_t
parameter_with_optional_value_t accept_ext_t
Definition: accept.hpp:55
restinio::http_field_parsers::accept_value_t::item_t::media_type
media_type_value_t media_type
Definition: accept.hpp:59
media-type.hpp
Stuff related to Media-Type value in HTTP-fields.
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
restinio::http_field_parsers::accept_value_t::item_t::weight
restinio::optional_t< qvalue_t > weight
Definition: accept.hpp:60
restinio::http_field_parsers::accept_value_t
Tools for working with the value of Accept HTTP-field.
Definition: accept.hpp:52
restinio::http_field_parsers::accept_value_t::items
item_container_t items
Definition: accept.hpp:66
restinio::easy_parser::maybe
RESTINIO_NODISCARD auto maybe(Clauses &&... clauses)
A factory function to create an optional clause.
Definition: easy_parser.hpp:3634