relative_part_rule.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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_RELATIVE_PART_RULE_HPP
  10. #define BOOST_URL_RFC_DETAIL_RELATIVE_PART_RULE_HPP
  11. #include <boost/url/detail/config.hpp>
  12. #include <boost/url/error_types.hpp>
  13. #include <boost/url/pct_string_view.hpp>
  14. #include <boost/url/rfc/authority_rule.hpp>
  15. #include <cstdlib>
  16. namespace boost {
  17. namespace urls {
  18. namespace detail {
  19. /** Rule for relative-part
  20. @par BNF
  21. @code
  22. relative-part = "//" authority path-abempty
  23. / path-absolute
  24. / path-noscheme
  25. / path-abempty
  26. / path-empty
  27. @endcode
  28. @par Specification
  29. @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-4.2"
  30. >4.2. Relative Reference (rfc3986)</a>
  31. @li <a href="https://www.rfc-editor.org/errata/eid5428"
  32. >Errata ID: 5428 (rfc3986)</a>
  33. @see
  34. @ref authority_rule.
  35. */
  36. struct relative_part_rule_t
  37. {
  38. struct value_type
  39. {
  40. authority_view authority;
  41. pct_string_view path;
  42. std::size_t segment_count = 0;
  43. bool has_authority = false;
  44. };
  45. auto
  46. parse(
  47. char const*& it,
  48. char const* end
  49. ) const noexcept ->
  50. system::result<value_type>;
  51. };
  52. constexpr relative_part_rule_t relative_part_rule{};
  53. } // detail
  54. } // urls
  55. } // boost
  56. #endif