GCC Code Coverage Report


Directory: libs/url/
File: boost/url/impl/params_ref.hpp
Date: 2024-09-08 09:46:49
Exec Total Coverage
Lines: 39 39 100.0%
Functions: 14 14 100.0%
Branches: 5 10 50.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_REF_HPP
12 #define BOOST_URL_IMPL_PARAMS_REF_HPP
13
14 #include <boost/url/params_view.hpp>
15 #include <boost/url/detail/any_params_iter.hpp>
16 #include <boost/url/detail/except.hpp>
17 #include <boost/url/grammar/recycled.hpp>
18 #include <boost/assert.hpp>
19
20 namespace boost {
21 namespace urls {
22
23 inline
24 94 params_ref::
25 params_ref(
26 url_base& u,
27 94 encoding_opts opt) noexcept
28 94 : params_base(u.impl_, opt)
29 94 , u_(&u)
30 {
31 94 }
32
33 //------------------------------------------------
34 //
35 // Special Members
36 //
37 //------------------------------------------------
38
39 inline
40 1 params_ref::
41 params_ref(
42 params_ref const& other,
43 1 encoding_opts opt) noexcept
44 1 : params_ref(*other.u_, opt)
45 {
46 1 }
47
48 inline
49 auto
50 1 params_ref::
51 operator=(std::initializer_list<
52 param_view> init) ->
53 params_ref&
54 {
55 1 assign(init);
56 1 return *this;
57 }
58
59 //------------------------------------------------
60 //
61 // Modifiers
62 //
63 //------------------------------------------------
64
65 inline
66 void
67 3 params_ref::
68 clear() noexcept
69 {
70 3 u_->remove_query();
71 3 }
72
73 //------------------------------------------------
74
75 template<class FwdIt>
76 void
77 10 params_ref::
78 assign(FwdIt first, FwdIt last)
79 {
80 /* If you get a compile error here, it
81 means that the iterators you passed
82 do not meet the requirements stated
83 in the documentation.
84 */
85 static_assert(
86 std::is_convertible<
87 typename std::iterator_traits<
88 FwdIt>::reference,
89 param_view>::value,
90 "Type requirements not met");
91
92
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
10 assign(first, last,
93 typename std::iterator_traits<
94 FwdIt>::iterator_category{});
95 10 }
96
97 inline
98 auto
99 7 params_ref::
100 append(
101 param_view const& p) ->
102 iterator
103 {
104 7 return insert(end(), p);
105 }
106
107 inline
108 auto
109 5 params_ref::
110 append(
111 std::initializer_list<
112 param_view> init) ->
113 iterator
114 {
115 5 return insert(end(), init);
116 }
117
118 template<class FwdIt>
119 auto
120 4 params_ref::
121 append(FwdIt first, FwdIt last) ->
122 iterator
123 {
124 /* If you get a compile error here, it
125 means that the iterators you passed
126 do not meet the requirements stated
127 in the documentation.
128 */
129 static_assert(
130 std::is_convertible<
131 typename std::iterator_traits<
132 FwdIt>::reference,
133 param_view>::value,
134 "Type requirements not met");
135
136 4 return insert(
137 4 end(), first, last);
138 }
139
140 template<class FwdIt>
141 auto
142 19 params_ref::
143 insert(
144 iterator before,
145 FwdIt first,
146 FwdIt last) ->
147 iterator
148 {
149 /* If you get a compile error here, it
150 means that the iterators you passed
151 do not meet the requirements stated
152 in the documentation.
153 */
154 static_assert(
155 std::is_convertible<
156 typename std::iterator_traits<
157 FwdIt>::reference,
158 param_view>::value,
159 "Type requirements not met");
160
161
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
38 return insert(
162 before,
163 first,
164 last,
165 typename std::iterator_traits<
166 38 FwdIt>::iterator_category{});
167 }
168
169 template<class FwdIt>
170 auto
171 4 params_ref::
172 replace(
173 iterator from,
174 iterator to,
175 FwdIt first,
176 FwdIt last) ->
177 iterator
178 {
179 /* If you get a compile error here, it
180 means that the iterators you passed
181 do not meet the requirements stated
182 in the documentation.
183 */
184 static_assert(
185 std::is_convertible<
186 typename std::iterator_traits<
187 FwdIt>::reference,
188 param_view>::value,
189 "Type requirements not met");
190
191 return iterator(
192
1/2
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
8 u_->edit_params(
193 from.it_, to.it_,
194 detail::make_params_iter(
195 first, last)),
196 8 opt_);
197 }
198
199 //------------------------------------------------
200 //
201 // implementation
202 //
203 //------------------------------------------------
204
205 template<class FwdIt>
206 void
207 10 params_ref::
208 assign(FwdIt first, FwdIt last,
209 std::forward_iterator_tag)
210 {
211
1/2
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
20 u_->edit_params(
212 10 begin().it_,
213 20 end().it_,
214 detail::make_params_iter(
215 first, last));
216 10 }
217
218 template<class FwdIt>
219 auto
220 19 params_ref::
221 insert(
222 iterator before,
223 FwdIt first,
224 FwdIt last,
225 std::forward_iterator_tag) ->
226 iterator
227 {
228 return iterator(
229
1/2
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
38 u_->edit_params(
230 before.it_,
231 before.it_,
232 detail::make_params_iter(
233 first, last)),
234 38 opt_);
235 }
236
237 } // urls
238 } // boost
239
240 #endif
241