GCC Code Coverage Report


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