params_iter_impl.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // Copyright (c) 2019 Vinnie Falco ([email protected])
  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_DETAIL_PARAMS_ITER_IMPL_HPP
  10. #define BOOST_URL_DETAIL_PARAMS_ITER_IMPL_HPP
  11. #include <boost/url/param.hpp>
  12. #include <boost/url/detail/parts_base.hpp>
  13. #include <boost/url/detail/url_impl.hpp>
  14. #include <boost/assert.hpp>
  15. namespace boost {
  16. namespace urls {
  17. namespace detail {
  18. struct BOOST_URL_DECL params_iter_impl
  19. : parts_base
  20. {
  21. query_ref ref;
  22. std::size_t index = 0;
  23. std::size_t pos;
  24. std::size_t nk;
  25. std::size_t nv;
  26. std::size_t dk;
  27. std::size_t dv;
  28. params_iter_impl() = default;
  29. params_iter_impl(
  30. params_iter_impl const&) = default;
  31. params_iter_impl& operator=(
  32. params_iter_impl const&) = default;
  33. // begin
  34. params_iter_impl(
  35. query_ref const&) noexcept;
  36. // end
  37. params_iter_impl(
  38. query_ref const&,
  39. int) noexcept;
  40. // at index
  41. params_iter_impl(
  42. query_ref const&,
  43. std::size_t,
  44. std::size_t) noexcept;
  45. void setup() noexcept;
  46. void increment() noexcept;
  47. void decrement() noexcept;
  48. param_pct_view
  49. dereference() const noexcept;
  50. pct_string_view key() const noexcept;
  51. auto
  52. next() const noexcept ->
  53. params_iter_impl
  54. {
  55. auto next = *this;
  56. next.increment();
  57. return next;
  58. }
  59. bool
  60. equal(
  61. params_iter_impl const&
  62. other) const noexcept
  63. {
  64. // different containers
  65. BOOST_ASSERT(ref.alias_of(other.ref));
  66. return index == other.index;
  67. }
  68. };
  69. } // detail
  70. } // urls
  71. } // boost
  72. #endif