ipv6_address_rule.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // Copyright (c) 2022 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_IPV6_ADDRESS_RULE_HPP
  10. #define BOOST_URL_RFC_IPV6_ADDRESS_RULE_HPP
  11. #include <boost/url/detail/config.hpp>
  12. #include <boost/url/ipv6_address.hpp>
  13. #include <boost/url/error_types.hpp>
  14. namespace boost {
  15. namespace urls {
  16. namespace implementation_defined {
  17. struct ipv6_address_rule_t
  18. {
  19. using value_type =
  20. ipv6_address;
  21. BOOST_URL_DECL
  22. auto
  23. parse(
  24. char const*& it,
  25. char const* end
  26. ) const noexcept ->
  27. system::result<ipv6_address>;
  28. };
  29. } // implementation_defined
  30. /** Rule for An IP version 6 style address
  31. @par Value Type
  32. @code
  33. using value_type = ipv6_address;
  34. @endcode
  35. @par Example
  36. Rules are used with the function @ref grammar::parse.
  37. @code
  38. system::result< ipv6_address > rv = grammar::parse( "2001:0db8:85a3:0000:0000:8a2e:0370:7334", ipv6_address_rule );
  39. @endcode
  40. @par BNF
  41. @code
  42. IPv6address = 6( h16 ":" ) ls32
  43. / "::" 5( h16 ":" ) ls32
  44. / [ h16 ] "::" 4( h16 ":" ) ls32
  45. / [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
  46. / [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
  47. / [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
  48. / [ *4( h16 ":" ) h16 ] "::" ls32
  49. / [ *5( h16 ":" ) h16 ] "::" h16
  50. / [ *6( h16 ":" ) h16 ] "::"
  51. ls32 = ( h16 ":" h16 ) / IPv4address
  52. ; least-significant 32 bits of address
  53. h16 = 1*4HEXDIG
  54. ; 16 bits of address represented in hexadecimal
  55. @endcode
  56. @par Specification
  57. @li <a href="https://datatracker.ietf.org/doc/html/rfc4291"
  58. >IP Version 6 Addressing Architecture (rfc4291)</a>
  59. @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
  60. >3.2.2. Host (rfc3986)</a>
  61. @see
  62. @ref ipv6_address,
  63. @ref parse_ipv6_address,
  64. @ref grammar::parse.
  65. */
  66. constexpr implementation_defined::ipv6_address_rule_t ipv6_address_rule{};
  67. } // urls
  68. } // boost
  69. #endif