RESTinio
Loading...
Searching...
No Matches
range.hpp
Go to the documentation of this file.
1/*
2 * RESTinio
3 */
4
12#pragma once
13
15
16#include <variant>
17
18namespace restinio
19{
20
21namespace http_field_parsers
22{
23
24namespace range_details
25{
26
38template< typename T >
44
56template< typename T >
58{
60};
61
73template< typename T >
75{
77};
78
84template< typename T >
85using byte_range_spec_t = std::variant<
89
95template< typename T >
97{
98 std::vector< byte_range_spec_t<T> > ranges;
99};
100
115{
116 std::string range_unit;
117 std::string range_set;
118};
119
125template< typename T >
126using value_t = std::variant<
129
149template< typename T >
150[[nodiscard]]
151auto
176
182[[nodiscard]]
183inline auto
185{
186 return sequence( exact( "bytes" ), symbol('=') );
187}
188
208template< typename T >
209[[nodiscard]]
210auto
223
237[[nodiscard]]
238inline auto
251
252} /* namespace range_details */
253
254//
255// range_value_t
256//
285template< typename T >
479
480} /* namespace http_field_parsers */
481
482} /* namespace restinio */
483
Utilities for parsing values of http-fields.
auto to_container()
A factory function to create a to_container_consumer.
auto force_only_this_alternative(Clauses &&... clauses)
An alternative that should be parsed correctly or the parsing of the whole alternatives clause should...
auto symbol(char expected) noexcept
A factory function to create a clause that expects the speficied symbol, extracts it and then skips i...
auto exact(string_view_t fragment)
A factory function that creates an instance of exact_fragment clause.
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.
auto as_result() noexcept
A factory function to create a as_result_consumer.
auto alternatives(Clauses &&... clauses)
A factory function to create an alternatives clause.
auto produce(Clauses &&... clauses)
A factory function to create a producer that creates an instance of the target type by using specifie...
constexpr std::size_t N
A special marker that means infinite repetitions.
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 make_other_ranges_specifier_parser()
Factory for creation of a parser for other_ranges_specifier values.
Definition range.hpp:239
auto make_byte_range_spec_parser()
Factory for creation of a parser for byte_range_spec values.
Definition range.hpp:152
auto make_bytes_prefix_parser()
Factory for a parser of 'bytes=' prefix.
Definition range.hpp:184
std::variant< byte_ranges_specifier_t< T >, other_ranges_specifier_t > value_t
Variant type for holding parsed value of Range HTTP-field.
Definition range.hpp:126
std::variant< double_ended_range_t< T >, open_ended_range_t< T >, suffix_length_t< T > > byte_range_spec_t
Variant type for all possible cases of specification for one range.
Definition range.hpp:85
auto make_byte_ranges_specifier_parser()
Factory for creation of a parser for byte_ranges_specifier values.
Definition range.hpp:211
auto vchar_symbol_p()
A factory for producer of VCHAR symbols.
Definition basics.hpp:834
auto token_p() noexcept
A factory function to create a token_producer.
Definition basics.hpp:987
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:1459
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
Definition expected.hpp:18
A struct that holds a container of byte_range_specs.
Definition range.hpp:97
Value of range for the case where both ends of the range are defined.
Definition range.hpp:40
Value of range for the case where only left border of the range is defined.
Definition range.hpp:58
A description of a range value of units those are not "bytes".
Definition range.hpp:115
Value of range for the case where only length of range's suffix is defined.
Definition range.hpp:75
Tools for working with the value of Range HTTP-field.
Definition range.hpp:287
static expected_t< range_value_t, restinio::easy_parser::parse_error_t > try_parse(string_view_t what)
An attempt to parse Range HTTP-field.
Definition range.hpp:474
static auto make_parser()
A factory function for a parser of Range value.
Definition range.hpp:453
range_details::value_t< T > value_t
Variant type for holding parsed value of Range HTTP-field.
Definition range.hpp:442
range_details::byte_range_spec_t< T > byte_range_spec_t
Variant type for all possible cases of specification for one range.
Definition range.hpp:388