GCC Code Coverage Report


Directory: libs/url/
File: libs/url/src/segments_encoded_ref.cpp
Date: 2024-01-19 15:42:54
Exec Total Coverage
Lines: 39 39 100.0%
Functions: 12 12 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_SEGMENTS_ENCODED_REF_IPP
12 #define BOOST_URL_IMPL_SEGMENTS_ENCODED_REF_IPP
13
14 #include <boost/url/detail/config.hpp>
15 #include <boost/url/segments_encoded_ref.hpp>
16 #include <boost/url/url.hpp>
17 #include "detail/path.hpp"
18
19 namespace boost {
20 namespace urls {
21
22 //------------------------------------------------
23 //
24 // Special Members
25 //
26 //------------------------------------------------
27
28 462 segments_encoded_ref::
29 segments_encoded_ref(
30 462 url_base& u) noexcept
31 : segments_encoded_base(
32 924 detail::path_ref(u.impl_))
33 462 , u_(&u)
34 {
35 462 }
36
37 34 segments_encoded_ref::
38 operator
39 segments_encoded_view() const noexcept
40 {
41 34 return segments_encoded_view(ref_);
42 }
43
44 segments_encoded_ref&
45 1 segments_encoded_ref::
46 operator=(
47 segments_encoded_ref const& other)
48 {
49
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 if (!ref_.alias_of(other.ref_))
50 1 assign(other.begin(), other.end());
51 1 return *this;
52 }
53
54 segments_encoded_ref&
55 1 segments_encoded_ref::
56 operator=(
57 segments_encoded_view const& other)
58 {
59 1 assign(other.begin(), other.end());
60 1 return *this;
61 }
62
63 segments_encoded_ref&
64 4 segments_encoded_ref::
65 operator=(std::initializer_list<
66 pct_string_view> init)
67 {
68 4 assign(init.begin(), init.end());
69 4 return *this;
70 }
71
72 //------------------------------------------------
73 //
74 // Modifiers
75 //
76 //------------------------------------------------
77
78 void
79 6 segments_encoded_ref::
80 assign(
81 std::initializer_list<
82 pct_string_view> init)
83 {
84 6 assign(init.begin(), init.end());
85 6 }
86
87 auto
88 50 segments_encoded_ref::
89 insert(
90 iterator before,
91 pct_string_view s) ->
92 iterator
93 {
94 100 return u_->edit_segments(
95 before.it_,
96 before.it_,
97
1/2
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
50 detail::segment_encoded_iter(s));
98 }
99
100 auto
101 14 segments_encoded_ref::
102 insert(
103 iterator before,
104 std::initializer_list<
105 pct_string_view> init) ->
106 iterator
107 {
108 return insert(
109 before,
110 init.begin(),
111 14 init.end());
112 }
113
114 auto
115 152 segments_encoded_ref::
116 erase(
117 iterator first,
118 iterator last) noexcept ->
119 iterator
120 {
121 152 core::string_view s;
122 304 return u_->edit_segments(
123 first.it_,
124 last.it_,
125 304 detail::make_segments_encoded_iter(
126 152 &s, &s));
127 }
128
129 auto
130 10 segments_encoded_ref::
131 replace(
132 iterator pos,
133 pct_string_view s) ->
134 iterator
135 {
136 20 return u_->edit_segments(
137 pos.it_,
138
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 std::next(pos).it_,
139
1/2
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 detail::segment_encoded_iter(s));
140 }
141
142 auto
143 12 segments_encoded_ref::
144 replace(
145 iterator from,
146 iterator to,
147 pct_string_view s) ->
148 iterator
149 {
150 24 return u_->edit_segments(
151 from.it_,
152 to.it_,
153
1/2
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 detail::segment_encoded_iter(s));
154 }
155
156 auto
157 6 segments_encoded_ref::
158 replace(
159 iterator from,
160 iterator to,
161 std::initializer_list<
162 pct_string_view> init) ->
163 iterator
164 {
165 return replace(
166 from,
167 to,
168 init.begin(),
169 6 init.end());
170 }
171
172 } // urls
173 } // boost
174
175 #endif
176