GCC Code Coverage Report


Directory: libs/url/
File: boost/url/impl/params_encoded_base.hpp
Date: 2024-04-08 19:38:36
Exec Total Coverage
Lines: 41 41 100.0%
Functions: 15 15 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 //
2 // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3 // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
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
11 #ifndef BOOST_URL_IMPL_PARAMS_ENCODED_BASE_HPP
12 #define BOOST_URL_IMPL_PARAMS_ENCODED_BASE_HPP
13
14 #include <boost/url/detail/params_iter_impl.hpp>
15
16 namespace boost {
17 namespace urls {
18
19 #ifndef BOOST_URL_DOCS
20 class params_ref;
21 #endif
22
23 //------------------------------------------------
24
25 class params_encoded_base::iterator
26 {
27 detail::params_iter_impl it_;
28
29 friend class params_encoded_base;
30 friend class params_encoded_ref;
31
32 iterator(detail::query_ref const& ref) noexcept;
33 iterator(detail::query_ref const& ref, int) noexcept;
34 159 iterator(
35 detail::params_iter_impl const& it)
36 159 : it_(it)
37 {
38 159 }
39
40 public:
41 using value_type =
42 params_encoded_base::value_type;
43 using reference =
44 params_encoded_base::reference;
45 using pointer = reference;
46 using difference_type = std::ptrdiff_t;
47 using iterator_category =
48 std::bidirectional_iterator_tag;
49
50 4 iterator() = default;
51 iterator(iterator const&) = default;
52 iterator& operator=(
53 iterator const&) = default;
54
55 iterator&
56 696 operator++() noexcept
57 {
58 696 it_.increment();
59 696 return *this;
60 }
61
62 iterator
63 292 operator++(int) noexcept
64 {
65 292 auto tmp = *this;
66 292 ++*this;
67 292 return tmp;
68 }
69
70 iterator&
71 580 operator--() noexcept
72 {
73 580 it_.decrement();
74 580 return *this;
75 }
76
77 iterator
78 290 operator--(int) noexcept
79 {
80 290 auto tmp = *this;
81 290 --*this;
82 290 return tmp;
83 }
84
85 reference
86 622 operator*() const
87 {
88 622 return it_.dereference();
89 }
90
91 pointer
92 21 operator->() const
93 {
94 21 return it_.dereference();
95 }
96
97 friend
98 bool
99 617 operator==(
100 iterator const& it0,
101 iterator const& it1) noexcept
102 {
103 617 return it0.it_.equal(it1.it_);
104 }
105
106 friend
107 bool
108 111 operator!=(
109 iterator const& it0,
110 iterator const& it1) noexcept
111 {
112 111 return ! it0.it_.equal(it1.it_);
113 }
114 };
115
116 //------------------------------------------------
117 //
118 // Observers
119 //
120 //------------------------------------------------
121
122 inline
123 bool
124 28 params_encoded_base::
125 contains(
126 pct_string_view key,
127 ignore_case_param ic) const noexcept
128 {
129 28 return find_impl(
130 28 begin().it_, key, ic) != end();
131 }
132
133 inline
134 auto
135 38 params_encoded_base::
136 find(
137 pct_string_view key,
138 ignore_case_param ic) const noexcept ->
139 iterator
140 {
141 38 return find_impl(
142 38 begin().it_, key, ic);
143 }
144
145 inline
146 auto
147 32 params_encoded_base::
148 find(
149 iterator it,
150 pct_string_view key,
151 ignore_case_param ic) const noexcept ->
152 iterator
153 {
154 32 return find_impl(
155 32 it.it_, key, ic);
156 }
157
158 inline
159 auto
160 4 params_encoded_base::
161 find_last(
162 pct_string_view key,
163 ignore_case_param ic) const noexcept ->
164 iterator
165 {
166 4 return find_last_impl(
167 4 end().it_, key, ic);
168 }
169
170 inline
171 auto
172 9 params_encoded_base::
173 find_last(
174 iterator it,
175 pct_string_view key,
176 ignore_case_param ic) const noexcept ->
177 iterator
178 {
179 9 return find_last_impl(
180 9 it.it_, key, ic);
181 }
182
183 } // urls
184 } // boost
185
186 #endif
187