ipv4_address_rule.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /** Rule for an IP version 4 style address
  17. @par Value Type
  18. @code
  19. using value_type = ipv4_address;
  20. @endcode
  21. @par Example
  22. Rules are used with the function @ref grammar::parse.
  23. @code
  24. system::result< ipv4_address > rv = grammar::parse( "192.168.0.1", ipv4_address_rule );
  25. @endcode
  26. @par BNF
  27. @code
  28. IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
  29. dec-octet = DIGIT ; 0-9
  30. / %x31-39 DIGIT ; 10-99
  31. / "1" 2DIGIT ; 100-199
  32. / "2" %x30-34 DIGIT ; 200-249
  33. / "25" %x30-35 ; 250-255
  34. @endcode
  35. @par Specification
  36. @li <a href="https://en.wikipedia.org/wiki/IPv4"
  37. >IPv4 (Wikipedia)</a>
  38. @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
  39. >3.2.2. Host (rfc3986)</a>
  40. @see
  41. @ref ipv4_address,
  42. @ref parse_ipv4_address,
  43. @ref grammar::parse.
  44. */
  45. #ifdef BOOST_URL_DOCS
  46. constexpr __implementation_defined__ ipv4_address_rule;
  47. #else
  48. struct ipv4_address_rule_t
  49. {
  50. using value_type =
  51. ipv4_address;
  52. BOOST_URL_DECL
  53. auto
  54. parse(
  55. char const*& it,
  56. char const* end
  57. ) const noexcept ->
  58. system::result<ipv4_address>;
  59. };
  60. constexpr ipv4_address_rule_t ipv4_address_rule{};
  61. #endif
  62. } // urls
  63. } // boost
  64. #endif