h16_rule.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_RFC_DETAIL_H16_RULE_HPP
  10. #define BOOST_URL_RFC_DETAIL_H16_RULE_HPP
  11. #include <boost/url/detail/config.hpp>
  12. #include <boost/url/error_types.hpp>
  13. #include <cstdint>
  14. namespace boost {
  15. namespace urls {
  16. namespace detail {
  17. /** Rule for h16
  18. This parses a sixteen bit unsigned
  19. hexadecimal number.
  20. @par BNF
  21. @code
  22. h16 = 1*4HEXDIG
  23. ; 16 bits of address represented in hexadecimal
  24. @endcode
  25. @par Specification
  26. @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2"
  27. >3.2.2. Host (rfc3986)</a>
  28. */
  29. struct h16_rule_t
  30. {
  31. struct value_type
  32. {
  33. std::uint8_t hi;
  34. std::uint8_t lo;
  35. };
  36. auto
  37. parse(
  38. char const*& it,
  39. char const* end
  40. ) const noexcept ->
  41. system::result<value_type>;
  42. };
  43. constexpr h16_rule_t h16_rule{};
  44. } // detail
  45. } // urls
  46. } // boost
  47. #endif