segments_iter_impl.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // Copyright (c) 2019 Vinnie Falco ([email protected])
  3. // Copyright (c) 2022 Alan de Freitas ([email protected])
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // Official repository: https://github.com/boostorg/url
  9. //
  10. #ifndef BOOST_URL_DETAIL_SEGMENTS_ITER_IMPL_HPP
  11. #define BOOST_URL_DETAIL_SEGMENTS_ITER_IMPL_HPP
  12. #include <boost/url/detail/parts_base.hpp>
  13. #include <boost/url/detail/url_impl.hpp>
  14. #include <boost/core/detail/string_view.hpp>
  15. #include <string>
  16. namespace boost {
  17. namespace urls {
  18. namespace detail {
  19. struct segments_iter_impl
  20. : private parts_base
  21. {
  22. path_ref ref;
  23. std::size_t pos = 0;
  24. std::size_t next = 0;
  25. std::size_t index = 0;
  26. std::size_t dn = 0;
  27. private:
  28. pct_string_view s_;
  29. public:
  30. segments_iter_impl() = default;
  31. segments_iter_impl(
  32. segments_iter_impl const&) noexcept = default;
  33. segments_iter_impl& operator=(
  34. segments_iter_impl const&) noexcept = default;
  35. // begin
  36. segments_iter_impl(
  37. detail::path_ref const&) noexcept;
  38. // end
  39. segments_iter_impl(
  40. detail::path_ref const&,
  41. int) noexcept;
  42. // at index
  43. segments_iter_impl(
  44. url_impl const& u_,
  45. std::size_t pos_,
  46. std::size_t i_) noexcept;
  47. void update() noexcept;
  48. BOOST_URL_DECL
  49. void
  50. increment() noexcept;
  51. BOOST_URL_DECL
  52. void
  53. decrement() noexcept;
  54. pct_string_view
  55. dereference() const noexcept
  56. {
  57. return s_;
  58. }
  59. bool
  60. equal(
  61. segments_iter_impl const& other) const noexcept
  62. {
  63. BOOST_ASSERT(ref.alias_of(other.ref));
  64. return index == other.index;
  65. }
  66. };
  67. } // detail
  68. } // urls
  69. } // boost
  70. #endif