ipv4_address_rule.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/url
  8. //
  9. #ifndef BOOST_URL_RFC_IPV4_ADDRESS_RULE_HPP
  10. #define BOOST_URL_RFC_IPV4_ADDRESS_RULE_HPP
  11. #include <boost/url/detail/config.hpp>
  12. #include <boost/url/ipv4_address.hpp>
  13. #include <boost/url/error_types.hpp>
  14. namespace boost {
  15. namespace urls {
  16. namespace implementation_defined {
  17. struct ipv4_address_rule_t
  18. {
  19. using value_type =
  20. ipv4_address;
  21. BOOST_URL_DECL
  22. auto
  23. parse(
  24. char const*& it,
  25. char const* end
  26. ) const noexcept ->
  27. system::result<ipv4_address>;
  28. };
  29. } // implementation_defined
  30. /** Rule for an IP version 4 style address
  31. @par Value Type
  32. @code
  33. using value_type = ipv4_address;
  34. @endcode
  35. @par Example
  36. Rules are used with the function @ref grammar::parse.
  37. @code
  38. system::result< ipv4_address > rv = grammar::parse( "192.168.0.1", ipv4_address_rule );
  39. @endcode
  40. @par BNF
  41. @code
  42. IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
  43. dec-octet = DIGIT ; 0-9
  44. / %x31-39 DIGIT ; 10-99
  45. / "1" 2DIGIT ; 100-199
  46. / "2" %x30-34 DIGIT ; 200-249
  47. / "25" %x30-35 ; 250-255
  48. @endcode
  49. @par Specification
  50. @li <a href="https://en.wikipedia.org/wiki/IPv4"
  51. >IPv4 (Wikipedia)</a>
  52. @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
  53. >3.2.2. Host (rfc3986)</a>
  54. @see
  55. @ref ipv4_address,
  56. @ref parse_ipv4_address,
  57. @ref grammar::parse.
  58. */
  59. constexpr implementation_defined::ipv4_address_rule_t ipv4_address_rule{};
  60. } // urls
  61. } // boost
  62. #endif