ipv6_address_rule.hpp 2.4 KB

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