14 #include <restinio/helpers/http_field_parsers/basics.hpp> 16 #include <restinio/helpers/http_field_parsers/details/pct_encoded_symbols.hpp> 50 return hfp_impl::is_alpha(actual)
51 || hfp_impl::is_digit(actual)
74 return ep_impl::symbol_producer_template_t< unreserved_predicate_t >{};
123 return ep_impl::symbol_producer_template_t< sub_delims_predicate_t >{};
151 const auto dec_octet = produce< std::string >(
154 symbol_p(
'2') >> to_container(),
155 symbol_p(
'5') >> to_container(),
156 symbol_from_range_p(
'0',
'5') >> to_container()
159 symbol_p(
'2') >> to_container(),
160 symbol_from_range_p(
'0',
'4') >> to_container(),
161 digit_p() >> to_container()
164 symbol_p(
'1') >> to_container(),
165 digit_p() >> to_container(),
166 digit_p() >> to_container()
169 symbol_from_range_p(
'1',
'9') >> to_container(),
170 digit_p() >> to_container()
172 digit_p() >> to_container()
176 return produce< std::string >(
177 dec_octet >> to_container(),
178 symbol_p(
'.') >> to_container(),
179 dec_octet >> to_container(),
180 symbol_p(
'.') >> to_container(),
181 dec_octet >> to_container(),
182 symbol_p(
'.') >> to_container(),
183 dec_octet >> to_container()
237 const auto h16 = produce< std::string >(
238 repeat( 1u, 4u, hexdigit_p() >> to_container() )
240 const auto h16_with_colon = sequence(
241 h16 >> to_container(),
242 symbol_p(
':') >> to_container(),
243 not_clause( symbol(
':') )
245 const auto ls32 = produce< std::string >(
248 h16 >> to_container(),
249 symbol_p(
':') >> to_container(),
250 h16 >> to_container()
252 ipv4_address_p() >> as_result()
255 const auto double_colon =
256 exact_p(
"::" ) >> just( std::string{
"::" } ) >> to_container()
259 return produce< std::string >(
262 repeat( 6u, 6u, h16_with_colon ),
263 ls32 >> to_container()
267 repeat( 5u, 5u, h16_with_colon ),
268 ls32 >> to_container()
271 maybe( h16 >> to_container() ),
273 repeat( 4u, 4u, h16_with_colon ),
274 ls32 >> to_container()
278 repeat( 0u, 1u, h16_with_colon ),
279 h16 >> to_container()
282 repeat( 3u, 3u, h16_with_colon ),
283 ls32 >> to_container()
287 repeat( 0u, 2u, h16_with_colon ),
288 h16 >> to_container()
291 repeat( 2u, 2u, h16_with_colon ),
292 ls32 >> to_container()
296 repeat( 0u, 3u, h16_with_colon ),
297 h16 >> to_container()
301 ls32 >> to_container()
305 repeat( 0u, 4u, h16_with_colon ),
306 h16 >> to_container()
309 ls32 >> to_container()
313 repeat( 0u, 5u, h16_with_colon ),
314 h16 >> to_container()
317 h16 >> to_container()
321 repeat( 0u, 6u, h16_with_colon ),
322 h16 >> to_container()
355 return produce< std::string >(
358 unreserved_symbol_p() >> to_container(),
359 hfp_details::pct_encoded_symbols_p()
360 >> hfp_details::pct_encoded_symbols_consumer_t{},
361 sub_delims_symbol_p() >> to_container()
418 return reg_name_t{ std::move(v) };
451 return ipv4_address_t{ std::move(v) };
484 return ipv6_address_t{ std::move(v) };
509 return produce< raw_host_value_t >(
510 produce< host_value_t >(
513 produce< ipv6_address_t >(
517 >> convert( ipv6_address_t::from_string )
522 produce< ipv4_address_t >(
524 >> convert( ipv4_address_t::from_string )
528 produce< reg_name_t >(
529 reg_name_p() >> to_lower()
530 >> convert( reg_name_t::from_string )
534 ) >> &raw_host_value_t::host,
537 non_negative_decimal_number_p< std::uint16_t >()
538 >> &raw_host_value_t::port
552 return restinio::easy_parser::try_parse( what, make_parser() );
575 m_to <<
'[' << n.v <<
']';
579 visit( host_dumper_t{ to }, rhv.host );
582 to <<
':' << *(rhv.port) << std::endl;
friend bool operator!=(const ipv6_address_t &a, const ipv6_address_t &b) noexcept
expected_t< std::optional< string_view_t >, not_found_t > find_first(const parameter_with_optional_value_container_t &where, string_view_t what)
A helper function to find the first occurence of a parameter with the specified value.
friend bool operator<(const ipv6_address_t &a, const ipv6_address_t &b) noexcept
std::ostream & operator<<(std::ostream &to, const raw_host_value_t &rhv)
auto ipv4_address_p()
A factory for producer of IPv4address value.
friend bool operator==(const ipv4_address_t &a, const ipv4_address_t &b) noexcept
A preducate for symbol_producer_template that checks that a symbol is sub-delims symbol from RCF3986...
reg_name_t(std::string val) noexcept
ipv4_address_t(std::string val) noexcept
Tools for working with the raw value of Host HTTP-field.
friend bool operator==(const reg_name_t &a, const reg_name_t &b) noexcept
static reg_name_t from_string(std::string v) noexcept
static ipv4_address_t from_string(std::string v) noexcept
friend bool operator!=(const reg_name_t &a, const reg_name_t &b) noexcept
auto unreserved_symbol_p()
A factory for producer that extracts unreserved symbols.
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, std::optional< Value_Type > >::type opt_value(const Parameter_Container ¶ms, string_view_t key)
Gets the value of a parameter specified by key wrapped in std::optional<Value_Type> if parameter exis...
auto ipv6_address_p()
A factory for producer of ipv6_address value.
friend bool operator==(const ipv6_address_t &a, const ipv6_address_t &b) noexcept
bool operator()(const char actual) const noexcept
static expected_t< raw_host_value_t, restinio::easy_parser::parse_error_t > try_parse(string_view_t what)
An attempt to parse Host HTTP-field.
A preducate for symbol_producer_template that checks that a symbol is unreserved symbol from RCF3986...
auto reg_name_p()
A factory for producer of reg-name value.
bool operator()(const char actual) const noexcept
std::optional< std::uint16_t > port
Optional port value.
friend bool operator<(const ipv4_address_t &a, const ipv4_address_t &b) noexcept
ipv6_address_t(std::string val) noexcept
static ipv6_address_t from_string(std::string v) noexcept
auto sub_delims_symbol_p()
A factory for producer that extracts sub-delims symbols.
friend bool operator<(const reg_name_t &a, const reg_name_t &b) noexcept
static auto make_parser()
A factory function for a parser of Host value.
friend bool operator!=(const ipv4_address_t &a, const ipv4_address_t &b) noexcept