dec_octet_rule.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot 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_GRAMMAR_DEC_OCTET_RULE_HPP
  10. #define BOOST_URL_GRAMMAR_DEC_OCTET_RULE_HPP
  11. #include <boost/url/detail/config.hpp>
  12. #include <boost/url/error_types.hpp>
  13. namespace boost {
  14. namespace urls {
  15. namespace grammar {
  16. namespace implementation_defined {
  17. struct dec_octet_rule_t
  18. {
  19. using value_type = unsigned char;
  20. BOOST_URL_DECL
  21. auto
  22. parse(
  23. char const*& it,
  24. char const* end
  25. ) const noexcept ->
  26. system::result<value_type>;
  27. };
  28. }
  29. /** Match a decimal octet
  30. A decimal octet is precise way of
  31. saying a number from 0 to 255. These
  32. are commonly used in IPv4 addresses.
  33. @par Value Type
  34. @code
  35. using value_type = unsigned char;
  36. @endcode
  37. @par Example
  38. Rules are used with the function @ref parse.
  39. @code
  40. system::result< unsigned char > rv = parse( "255", dec_octet_rule );
  41. @endcode
  42. @par BNF
  43. @code
  44. dec-octet = DIGIT ; 0-9
  45. / %x31-39 DIGIT ; 10-99
  46. / "1" 2DIGIT ; 100-199
  47. / "2" %x30-34 DIGIT ; 200-249
  48. / "25" %x30-35 ; 250-255
  49. @endcode
  50. @par Specification
  51. @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
  52. >3.2.2. Host (rfc3986)</a>
  53. @see
  54. @ref parse.
  55. */
  56. constexpr implementation_defined::dec_octet_rule_t dec_octet_rule{};
  57. } // grammar
  58. } // urls
  59. } // boost
  60. #endif