GCC Code Coverage Report


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