dec_octet_rule.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. /** Match a decimal octet
  17. A decimal octet is precise way of
  18. saying a number from 0 to 255. These
  19. are commonly used in IPv4 addresses.
  20. @par Value Type
  21. @code
  22. using value_type = unsigned char;
  23. @endcode
  24. @par Example
  25. Rules are used with the function @ref parse.
  26. @code
  27. system::result< unsigned char > rv = parse( "255", dec_octet_rule );
  28. @endcode
  29. @par BNF
  30. @code
  31. dec-octet = DIGIT ; 0-9
  32. / %x31-39 DIGIT ; 10-99
  33. / "1" 2DIGIT ; 100-199
  34. / "2" %x30-34 DIGIT ; 200-249
  35. / "25" %x30-35 ; 250-255
  36. @endcode
  37. @par Specification
  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 parse.
  42. */
  43. #ifdef BOOST_URL_DOCS
  44. constexpr __implementation_defined__ dec_octet_rule;
  45. #else
  46. struct dec_octet_rule_t
  47. {
  48. using value_type = unsigned char;
  49. BOOST_URL_DECL
  50. auto
  51. parse(
  52. char const*& it,
  53. char const* end
  54. ) const noexcept ->
  55. system::result<value_type>;
  56. };
  57. constexpr dec_octet_rule_t dec_octet_rule{};
  58. #endif
  59. } // grammar
  60. } // urls
  61. } // boost
  62. #endif