restinio::http_field_parsers::range_value_t< T > Struct Template Reference

Tools for working with the value of Range HTTP-field. More...

`#include <range.hpp>`

## Public Types

using | double_ended_range_t = range_details::double_ended_range_t< T >
| Value of range for the case where both ends of the range are defined. More...
using | open_ended_range_t = range_details::open_ended_range_t< T >
| Value of range for the case where only left border of the range is defined. More...
using | suffix_length_t = range_details::suffix_length_t< T >
| Value of range for the case where only length of range's suffix is defined. More...
using | byte_range_spec_t = range_details::byte_range_spec_t< T >
| Variant type for all possible cases of specification for one range. More...
using | byte_ranges_specifier_t = range_details::byte_ranges_specifier_t< T >
| A struct that holds a container of byte_range_specs. More...
using | other_ranges_specifier_t = range_details::other_ranges_specifier_t
| A description of a range value of units those are not "bytes". More...
using | value_t = range_details::value_t< T >
| Variant type for holding parsed value of Range HTTP-field. More...

## Static Public Member Functions

static RESTINIO_NODISCARD auto | make_parser ()
| A factory function for a parser of Range value. More...
static RESTINIO_NODISCARD expected_t< range_value_t, restinio::easy_parser::parse_error_t > | try_parse (string_view_t what)
| An attempt to parse Range HTTP-field. More...

## Public Attributes

value_t | value

## Detailed Description

template<typename T>
struct restinio::http_field_parsers::range_value_t< T >

Tools for working with the value of Range HTTP-field.

This struct represents parsed value of HTTP-field Range (see https://tools.ietf.org/html/rfc7233#section-3.1 and https://tools.ietf.org/html/rfc7233#section-2):

    Range = byte-ranges-specifier / other-ranges-specifier

    byte-ranges-specifier = bytes-unit "=" byte-range-set
    byte-range-set  = 1#( byte-range-spec / suffix-byte-range-spec )
    byte-range-spec = first-byte-pos "-" [ last-byte-pos ]
    first-byte-pos  = 1*DIGIT
    last-byte-pos   = 1*DIGIT

    suffix-byte-range-spec = "-" suffix-length
    suffix-length = 1*DIGIT

    other-ranges-specifier = other-range-unit "=" other-range-set
    other-range-set = 1*VCHAR

Template Parameters

  T | integer type for holding parsed values for byte-ranges-specifier. It is expected to be type like int, unsigned int, long, unsigned long, std::uint64_t, std::uint_least64_t and so on.

Since
  v.0.6.2

Definition at line 286 of file range.hpp.

## Member Typedef Documentation

## byte_range_spec_t

template<typename T >

using restinio::http_field_parsers::range_value_t< T >::byte_range_spec_t = range_details::byte_range_spec_t<T>

Variant type for all possible cases of specification for one range.

Since
  v.0.6.2

Definition at line 388 of file range.hpp.

## byte_ranges_specifier_t

template<typename T >

using restinio::http_field_parsers::range_value_t< T >::byte_ranges_specifier_t = range_details::byte_ranges_specifier_t<T>

A struct that holds a container of byte_range_specs.

Usage example:

using range_type = restinio::http_field_parsers::range_value_t<std::uint_least64_t>;
const auto parse_result = range_type::try_parse(range_field_value);
if(parse_result) {
if(const auto * byte_ranges =
restinio::get_if<range_type::byte_ranges_specifier_t>(parse_result->value)) {
for(const auto & r : byte_ranges->ranges) {
if(const auto * full_range =
restinio::get_if<range_type::double_ended_range_t>(&r)) {
... // access to full_range->first and full_range->last
}
else if(const auto * open_range =
restinio::get_if<range_type::open_ended_range_t>(&r)) {
... // access to open_range->first.
}
else if(const auto * suffix =
restinio::get_if<range_type::suffix_length_t>(&r)) {
... // access to suffix->first.
}
}
}
}
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::range_value_t
Tools for working with the value of Range HTTP-field.
Definition: range.hpp:287

Since
  v.0.6.2

Definition at line 420 of file range.hpp.

## double_ended_range_t

template<typename T >

using restinio::http_field_parsers::range_value_t< T >::double_ended_range_t = range_details::double_ended_range_t<T>

Value of range for the case where both ends of the range are defined.

This type will be used if a range is defined such way:

    bytes=1000-5000,6000-7000

Usage example:

using range_type = restinio::http_field_parsers::range_value_t<std::uint_least64_t>;
const auto parse_result = range_type::try_parse(range_field_value);
if(parse_result) {
if(const auto * byte_ranges =
restinio::get_if<range_type::byte_ranges_specifier_t>(parse_result->value)) {
for(const auto & r : byte_ranges->ranges) {
if(const auto * full_range =
restinio::get_if<range_type::double_ended_range_t>(&r)) {
... // access to full_range->first and full_range->last
}
else
...
}
}
}

Since
  v.0.6.2

Definition at line 318 of file range.hpp.

## open_ended_range_t

template<typename T >

using restinio::http_field_parsers::range_value_t< T >::open_ended_range_t = range_details::open_ended_range_t<T>

Value of range for the case where only left border of the range is defined.

This type will be used if a range is defined such way:

    bytes=1000-

Usage example:

using range_type = restinio::http_field_parsers::range_value_t<std::uint_least64_t>;
const auto parse_result = range_type::try_parse(range_field_value);
if(parse_result) {
if(const auto * byte_ranges =
restinio::get_if<range_type::byte_ranges_specifier_t>(parse_result->value)) {
for(const auto & r : byte_ranges->ranges) {
if(const auto * open_range =
restinio::get_if<range_type::open_ended_range_t>(&r)) {
... // access to open_range->first.
}
else
...
}
}
}

Since
  v.0.6.2

Definition at line 349 of file range.hpp.

## other_ranges_specifier_t

template<typename T >

using restinio::http_field_parsers::range_value_t< T >::other_ranges_specifier_t = range_details::other_ranges_specifier_t

A description of a range value of units those are not "bytes".

This type will be used for values like:

    x-megabytes=1-45,450-1300

Please note that other_ranges_specifier_t::range_set contains the raw value. E.g. for the example above range_set will hold "1-45,450-1300".

Since
  v.0.6.2

Definition at line 435 of file range.hpp.

## suffix_length_t

template<typename T >

using restinio::http_field_parsers::range_value_t< T >::suffix_length_t = range_details::suffix_length_t<T>

Value of range for the case where only length of range's suffix is defined.

This type will be used if a range is defined such way:

    bytes=-450

Usage example:

using range_type = restinio::http_field_parsers::range_value_t<std::uint_least64_t>;
const auto parse_result = range_type::try_parse(range_field_value);
if(parse_result) {
if(const auto * byte_ranges =
restinio::get_if<range_type::byte_ranges_specifier_t>(parse_result->value)) {
for(const auto & r : byte_ranges->ranges) {
if(const auto * suffix =
restinio::get_if<range_type::suffix_length_t>(&r)) {
... // access to suffix->first.
}
else
...
}
}
}

Since
  v.0.6.2

Definition at line 381 of file range.hpp.

## value_t

template<typename T >

using restinio::http_field_parsers::range_value_t< T >::value_t = range_details::value_t<T>

Variant type for holding parsed value of Range HTTP-field.

Since
  v.0.6.2

Definition at line 442 of file range.hpp.

## Member Function Documentation

## make_parser()

template<typename T >

static RESTINIO_NODISCARD auto restinio::http_field_parsers::range_value_t< T >::make_parser | ( |  | ) |

inlinestatic

A factory function for a parser of Range value.

Since
  v.0.6.2

Definition at line 453 of file range.hpp.

## try_parse()

template<typename T >

static RESTINIO_NODISCARD expected_t< range_value_t, restinio::easy_parser::parse_error_t > restinio::http_field_parsers::range_value_t< T >::try_parse | ( | string_view_t | what | ) |

inlinestatic

An attempt to parse Range HTTP-field.

Since
  v.0.6.2

Definition at line 474 of file range.hpp.

## Member Data Documentation

## value

template<typename T >

value_t restinio::http_field_parsers::range_value_t< T >::value

Definition at line 444 of file range.hpp.

The documentation for this struct was generated from the following file:

- restinio/helpers/http_field_parsers/range.hpp