GCC Code Coverage Report


Directory: libs/url/
File: boost/url/impl/segments_encoded_ref.hpp
Date: 2024-02-29 20:02:56
Exec Total Coverage
Lines: 24 24 100.0%
Functions: 15 15 100.0%
Branches: 6 8 75.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_SEGMENTS_ENCODED_REF_HPP
12 #define BOOST_URL_IMPL_SEGMENTS_ENCODED_REF_HPP
13
14 #include <boost/url/detail/config.hpp>
15 #include <boost/url/detail/segments_iter_impl.hpp>
16 #include <boost/url/detail/any_segments_iter.hpp>
17 #include <type_traits>
18
19 namespace boost {
20 namespace urls {
21
22 //------------------------------------------------
23 //
24 // Modifiers
25 //
26 //------------------------------------------------
27
28 inline
29 void
30 9 segments_encoded_ref::
31 clear() noexcept
32 {
33 9 erase(begin(), end());
34 9 }
35
36 template<class FwdIt>
37 void
38 36 segments_encoded_ref::
39 assign(
40 FwdIt first, FwdIt last)
41 {
42 /* If you get a compile error here, it
43 means that the iterators you passed
44 do not meet the requirements stated
45 in the documentation.
46 */
47 static_assert(
48 std::is_convertible<
49 typename std::iterator_traits<
50 FwdIt>::reference,
51 core::string_view>::value,
52 "Type requirements not met");
53
54
1/2
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
66 u_->edit_segments(
55 30 begin().it_,
56 60 end().it_,
57 detail::make_segments_encoded_iter(
58 first, last));
59 30 }
60
61 template<class FwdIt>
62 auto
63 158 segments_encoded_ref::
64 insert(
65 iterator before,
66 FwdIt first,
67 FwdIt last) ->
68 iterator
69 {
70 /* If you get a compile error here, it
71 means that the iterators you passed
72 do not meet the requirements stated
73 in the documentation.
74 */
75 static_assert(
76 std::is_convertible<
77 typename std::iterator_traits<
78 FwdIt>::reference,
79 core::string_view>::value,
80 "Type requirements not met");
81
82 return insert(
83 before,
84 first,
85 last,
86 typename std::iterator_traits<
87
2/2
✓ Branch 1 taken 151 times.
✓ Branch 2 taken 7 times.
158 FwdIt>::iterator_category{});
88 }
89
90 inline
91 auto
92 137 segments_encoded_ref::
93 erase(
94 iterator pos) noexcept ->
95 iterator
96 {
97 137 return erase(pos, std::next(pos));
98 }
99
100 template<class FwdIt>
101 auto
102 14 segments_encoded_ref::
103 replace(
104 iterator from,
105 iterator to,
106 FwdIt first,
107 FwdIt last) ->
108 iterator
109 {
110 /* If you get a compile error here, it
111 means that the iterators you passed
112 do not meet the requirements stated
113 in the documentation.
114 */
115 static_assert(
116 std::is_convertible<
117 typename std::iterator_traits<
118 FwdIt>::reference,
119 core::string_view>::value,
120 "Type requirements not met");
121
122 14 return u_->edit_segments(
123 from.it_,
124 to.it_,
125 detail::make_segments_encoded_iter(
126
2/2
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 2 times.
14 first, last));
127 }
128
129 //------------------------------------------------
130
131 inline
132 void
133 20 segments_encoded_ref::
134 push_back(
135 pct_string_view s)
136 {
137 20 insert(end(), s);
138 20 }
139
140 inline
141 void
142 125 segments_encoded_ref::
143 pop_back() noexcept
144 {
145 125 erase(std::prev(end()));
146 125 }
147
148 //------------------------------------------------
149
150 template<class FwdIt>
151 auto
152 158 segments_encoded_ref::
153 insert(
154 iterator before,
155 FwdIt first,
156 FwdIt last,
157 std::forward_iterator_tag) ->
158 iterator
159 {
160 158 return u_->edit_segments(
161 before.it_,
162 before.it_,
163 detail::make_segments_encoded_iter(
164
1/2
✓ Branch 2 taken 151 times.
✗ Branch 3 not taken.
158 first, last));
165 }
166
167 } // urls
168 } // boost
169
170 #endif
171