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