restinio::http_field_parsers::media_type_value_t Struct Reference

Tools for working with media-type in HTTP-fields. More...

`#include <media-type.hpp>`

## Public Types

using | parameter_t = parameter_with_mandatory_value_t
using | parameter_container_t = parameter_with_mandatory_value_container_t

## Static Public Member Functions

static RESTINIO_NODISCARD auto | make_default_parser ()
static RESTINIO_NODISCARD auto | make_weight_aware_parser ()
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. More...

## Public Attributes

std::string | type
std::string | subtype
parameter_container_t | parameters

## Detailed Description

Tools for working with media-type in HTTP-fields.

This struct represents parsed value of media-type. Media-type is present in different HTTP-fields and has the following format (see https://tools.ietf.org/html/rfc7231 section `3.1.1.1. Media Type`):

         media-type = type "/" subtype *( OWS ";" OWS parameter )
         type       = token
         subtype    = token
         parameter  = token "=" ( token / quoted-string )

Since
  v.0.6.1

Definition at line 41 of file media-type.hpp.

## Member Typedef Documentation

## parameter_container_t

using restinio::http_field_parsers::media_type_value_t::parameter_container_t = parameter_with_mandatory_value_container_t

Definition at line 45 of file media-type.hpp.

## parameter_t

using restinio::http_field_parsers::media_type_value_t::parameter_t = parameter_with_mandatory_value_t

Definition at line 43 of file media-type.hpp.

## Member Function Documentation

## make_default_parser()

static RESTINIO_NODISCARD auto restinio::http_field_parsers::media_type_value_t::make_default_parser | ( |  | ) |

inlinestatic

       @brief Make a default parser that doesn't handles weight parameter
       a special way.

       This parser handles the following rules:

         media-type = type "/" subtype *( OWS ";" OWS parameter )
         type       = token
         subtype    = token
         parameter  = token "=" ( token / quoted-string )

Since
  v.0.6.1

Definition at line 66 of file media-type.hpp.

## make_weight_aware_parser()

static RESTINIO_NODISCARD auto restinio::http_field_parsers::media_type_value_t::make_weight_aware_parser | ( |  | ) |

inlinestatic

       @brief Make a special parser that stops when weight parameter is found.

       This parser handles the following rules:

         media-type = type "/" subtype *( ![weight] OWS ";" OWS parameter )
         type       = token
         subtype    = token
         parameter  = token "=" ( token / quoted-string )
         weight = OWS ";" OWS "q=" qvalue
         qvalue = ( "0" [ "." 0*3DIGIT ] )
                / ( "1" [ "." 0*3("0") ] )

Since
  v.0.6.1

Definition at line 93 of file media-type.hpp.

## try_parse()

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

inlinestatic

An attempt to parse media-type value.

Note
  This method uses make_default_parser() for actual parser.

Since
  v.0.6.1

Definition at line 128 of file media-type.hpp.

## Member Data Documentation

## parameters

parameter_container_t restinio::http_field_parsers::media_type_value_t::parameters

Definition at line 49 of file media-type.hpp.

## subtype

std::string restinio::http_field_parsers::media_type_value_t::subtype

Definition at line 48 of file media-type.hpp.

## type

std::string restinio::http_field_parsers::media_type_value_t::type

Definition at line 47 of file media-type.hpp.

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

- restinio/helpers/http_field_parsers/media-type.hpp