pct_encoded_symbols.hpp
Go to the documentation of this file.
/*
* RESTinio
*/
#pragma once
#include <restinio/helpers/http_field_parsers/basics.hpp>
namespace restinio
{
namespace http_field_parsers
{
namespace details
{
//
// pct_encoded_result_type_t
//
using pct_encoded_result_type_t = std::array< char, 3 >;
//
// pct_encoded_symbols_producer
//
RESTINIO_NODISCARD
inline auto
pct_encoded_symbols_p()
{
return produce< pct_encoded_result_type_t >(
symbol_p( '%' ) >> to_container(),
hexdigit_p() >> to_container(),
hexdigit_p() >> to_container()
);
}
//
// pct_encoded_symbols_consumer_t
//
struct pct_encoded_symbols_consumer_t
: public restinio::easy_parser::impl::consumer_tag
{
void
consume( std::string & to, pct_encoded_result_type_t && from ) const
{
to.append( &from[0], from.size() );
}
};
} /* namespace details */
} /* namespace http_field_parsers */
} /* namespace restinio */
basics.hpp
Utilities for parsing values of http-fields.
RESTINIO_NODISCARD
#define RESTINIO_NODISCARD
Definition: compiler_features.hpp:33
restinio::easy_parser::hexdigit_p
RESTINIO_NODISCARD auto hexdigit_p() noexcept
A factory function to create a hexdigit_producer.
Definition: easy_parser.hpp:4172
restinio::easy_parser::to_container
RESTINIO_NODISCARD auto to_container()
A factory function to create a to_container_consumer.
Definition: easy_parser.hpp:4583
restinio::easy_parser::symbol_p
RESTINIO_NODISCARD auto symbol_p(char expected) noexcept
A factory function to create a symbol_producer.
Definition: easy_parser.hpp:3955
restinio::http_field_parsers::details::pct_encoded_result_type_t
std::array< char, 3 > pct_encoded_result_type_t
A type for representing extraction of percent-encoded char from the input stream.
Definition: pct_encoded_symbols.hpp:39
restinio::http_field_parsers::details::pct_encoded_symbols_p
RESTINIO_NODISCARD auto pct_encoded_symbols_p()
A producer that extract a sequence of symbols represented a percent-encoded character.
Definition: pct_encoded_symbols.hpp:57
restinio
Definition: asio_include.hpp:21
restinio::easy_parser::impl::consumer_tag
A special base class to be used with consumers.
Definition: easy_parser.hpp:1343
restinio::http_field_parsers::details::pct_encoded_symbols_consumer_t
A special consumer that inserts an extracted sequence of symbols into the result string.
Definition: pct_encoded_symbols.hpp:80
restinio::http_field_parsers::details::pct_encoded_symbols_consumer_t::consume
void consume(std::string &to, pct_encoded_result_type_t &&from) const
Definition: pct_encoded_symbols.hpp:82