1  
//
1  
//
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3  
//
3  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
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)
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
6  
//
7  
// Official repository: https://github.com/boostorg/url
7  
// Official repository: https://github.com/boostorg/url
8  
//
8  
//
9  

9  

10  
#ifndef BOOST_URL_DETAIL_PARAMS_ITER_IMPL_HPP
10  
#ifndef BOOST_URL_DETAIL_PARAMS_ITER_IMPL_HPP
11  
#define BOOST_URL_DETAIL_PARAMS_ITER_IMPL_HPP
11  
#define BOOST_URL_DETAIL_PARAMS_ITER_IMPL_HPP
12  

12  

13  
#include <boost/url/param.hpp>
13  
#include <boost/url/param.hpp>
14  
#include <boost/url/detail/parts_base.hpp>
14  
#include <boost/url/detail/parts_base.hpp>
15  
#include <boost/url/detail/url_impl.hpp>
15  
#include <boost/url/detail/url_impl.hpp>
16  
#include <boost/assert.hpp>
16  
#include <boost/assert.hpp>
17  

17  

18  
namespace boost {
18  
namespace boost {
19  
namespace urls {
19  
namespace urls {
20  
namespace detail {
20  
namespace detail {
21  

21  

22  
struct BOOST_URL_DECL params_iter_impl
22  
struct BOOST_URL_DECL params_iter_impl
23  
    : parts_base
23  
    : parts_base
24  
{
24  
{
25  
    query_ref ref;
25  
    query_ref ref;
26  
    std::size_t index = 0;
26  
    std::size_t index = 0;
27  
    std::size_t pos;
27  
    std::size_t pos;
28  
    std::size_t nk;
28  
    std::size_t nk;
29  
    std::size_t nv;
29  
    std::size_t nv;
30  
    std::size_t dk;
30  
    std::size_t dk;
31  
    std::size_t dv;
31  
    std::size_t dv;
32  

32  

33  
    params_iter_impl() = default;
33  
    params_iter_impl() = default;
34  
    params_iter_impl(
34  
    params_iter_impl(
35  
        params_iter_impl const&) = default;
35  
        params_iter_impl const&) = default;
36  
    params_iter_impl& operator=(
36  
    params_iter_impl& operator=(
37  
        params_iter_impl const&) = default;
37  
        params_iter_impl const&) = default;
38  

38  

39  
    // begin
39  
    // begin
40  
    params_iter_impl(
40  
    params_iter_impl(
41  
        query_ref const&) noexcept;
41  
        query_ref const&) noexcept;
42  

42  

43  
    // end
43  
    // end
44  
    params_iter_impl(
44  
    params_iter_impl(
45  
        query_ref const&,
45  
        query_ref const&,
46  
        int) noexcept;
46  
        int) noexcept;
47  

47  

48  
    // at index
48  
    // at index
49  
    params_iter_impl(
49  
    params_iter_impl(
50  
        query_ref const&,
50  
        query_ref const&,
51  
        std::size_t,
51  
        std::size_t,
52  
        std::size_t) noexcept;
52  
        std::size_t) noexcept;
53  
    void setup() noexcept;
53  
    void setup() noexcept;
54  
    void increment() noexcept;
54  
    void increment() noexcept;
55  
    void decrement() noexcept;
55  
    void decrement() noexcept;
56  
    param_pct_view
56  
    param_pct_view
57  
        dereference() const noexcept;
57  
        dereference() const noexcept;
58  
    pct_string_view key() const noexcept;
58  
    pct_string_view key() const noexcept;
59  

59  

60  
    auto
60  
    auto
61  
    next() const noexcept ->
61  
    next() const noexcept ->
62  
        params_iter_impl
62  
        params_iter_impl
63  
    {
63  
    {
64  
        auto next = *this;
64  
        auto next = *this;
65  
        next.increment();
65  
        next.increment();
66  
        return next;
66  
        return next;
67  
    }
67  
    }
68  

68  

69  
    bool
69  
    bool
70  
    equal(
70  
    equal(
71  
        params_iter_impl const&
71  
        params_iter_impl const&
72  
            other) const noexcept
72  
            other) const noexcept
73  
    {
73  
    {
74  
        // different containers
74  
        // different containers
75  
        BOOST_ASSERT(ref.alias_of(other.ref));
75  
        BOOST_ASSERT(ref.alias_of(other.ref));
76  
        return index == other.index;
76  
        return index == other.index;
77  
    }
77  
    }
78  
};
78  
};
79  

79  

80  
} // detail
80  
} // detail
81  
} // urls
81  
} // urls
82  
} // boost
82  
} // boost
83  

83  

84  
#endif
84  
#endif