1  
//
1  
//
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3  
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
3  
// Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
4  
//
4  
//
5  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
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)
6  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  
//
7  
//
8  
// Official repository: https://github.com/boostorg/url
8  
// Official repository: https://github.com/boostorg/url
9  
//
9  
//
10  

10  

11  
#ifndef BOOST_URL_IMPL_SEGMENTS_ENCODED_REF_HPP
11  
#ifndef BOOST_URL_IMPL_SEGMENTS_ENCODED_REF_HPP
12  
#define BOOST_URL_IMPL_SEGMENTS_ENCODED_REF_HPP
12  
#define BOOST_URL_IMPL_SEGMENTS_ENCODED_REF_HPP
13  

13  

14  
#include <boost/url/detail/config.hpp>
14  
#include <boost/url/detail/config.hpp>
15  
#include <boost/url/detail/segments_iter_impl.hpp>
15  
#include <boost/url/detail/segments_iter_impl.hpp>
16  
#include <boost/url/detail/any_segments_iter.hpp>
16  
#include <boost/url/detail/any_segments_iter.hpp>
17  
#include <type_traits>
17  
#include <type_traits>
18  

18  

19  
namespace boost {
19  
namespace boost {
20  
namespace urls {
20  
namespace urls {
21  

21  

22  
//------------------------------------------------
22  
//------------------------------------------------
23  
//
23  
//
24  
// Modifiers
24  
// Modifiers
25  
//
25  
//
26  
//------------------------------------------------
26  
//------------------------------------------------
27 -
inline
 
28 -
void
 
29 -
segments_encoded_ref::
 
30 -
clear() noexcept
 
31 -
{
 
32 -
    erase(begin(), end());
 
33 -
}
 
34 -

 
35  

27  

36  
template<class FwdIt>
28  
template<class FwdIt>
37  
void
29  
void
38  
segments_encoded_ref::
30  
segments_encoded_ref::
39  
assign(
31  
assign(
40  
    FwdIt first, FwdIt last)
32  
    FwdIt first, FwdIt last)
41  
{
33  
{
42  
/*  If you get a compile error here, it
34  
/*  If you get a compile error here, it
43  
    means that the iterators you passed
35  
    means that the iterators you passed
44  
    do not meet the requirements stated
36  
    do not meet the requirements stated
45  
    in the documentation.
37  
    in the documentation.
46  
*/
38  
*/
47  
    static_assert(
39  
    static_assert(
48  
        std::is_convertible<
40  
        std::is_convertible<
49  
            typename std::iterator_traits<
41  
            typename std::iterator_traits<
50  
                FwdIt>::reference,
42  
                FwdIt>::reference,
51  
            core::string_view>::value,
43  
            core::string_view>::value,
52  
        "Type requirements not met");
44  
        "Type requirements not met");
53  

45  

54  
    u_->edit_segments(
46  
    u_->edit_segments(
55  
        begin().it_,
47  
        begin().it_,
56  
        end().it_,
48  
        end().it_,
57  
        detail::make_segments_encoded_iter(
49  
        detail::make_segments_encoded_iter(
58  
            first, last));
50  
            first, last));
59  
}
51  
}
60  

52  

61  
template<class FwdIt>
53  
template<class FwdIt>
62  
auto
54  
auto
63  
segments_encoded_ref::
55  
segments_encoded_ref::
64  
insert(
56  
insert(
65  
    iterator before,
57  
    iterator before,
66  
    FwdIt first,
58  
    FwdIt first,
67  
    FwdIt last) ->
59  
    FwdIt last) ->
68  
        iterator
60  
        iterator
69  
{
61  
{
70  
/*  If you get a compile error here, it
62  
/*  If you get a compile error here, it
71  
    means that the iterators you passed
63  
    means that the iterators you passed
72  
    do not meet the requirements stated
64  
    do not meet the requirements stated
73  
    in the documentation.
65  
    in the documentation.
74  
*/
66  
*/
75  
    static_assert(
67  
    static_assert(
76  
        std::is_convertible<
68  
        std::is_convertible<
77  
            typename std::iterator_traits<
69  
            typename std::iterator_traits<
78  
                FwdIt>::reference,
70  
                FwdIt>::reference,
79  
            core::string_view>::value,
71  
            core::string_view>::value,
80  
        "Type requirements not met");
72  
        "Type requirements not met");
81  

73  

82  
    return insert(
74  
    return insert(
83  
        before,
75  
        before,
84  
        first,
76  
        first,
85  
        last,
77  
        last,
86  
        typename std::iterator_traits<
78  
        typename std::iterator_traits<
87  
            FwdIt>::iterator_category{});
79  
            FwdIt>::iterator_category{});
88  
}
80  
}
89 -
inline
 
90 -
auto
 
91 -
segments_encoded_ref::
 
92 -
erase(
 
93 -
    iterator pos) noexcept ->
 
94 -
        iterator
 
95 -
{
 
96 -
    return erase(pos, std::next(pos));
 
97 -
}
 
98 -

 
99  

81  

100  
template<class FwdIt>
82  
template<class FwdIt>
101  
auto
83  
auto
102  
segments_encoded_ref::
84  
segments_encoded_ref::
103  
replace(
85  
replace(
104  
    iterator from,
86  
    iterator from,
105  
    iterator to,
87  
    iterator to,
106  
    FwdIt first,
88  
    FwdIt first,
107  
    FwdIt last) ->
89  
    FwdIt last) ->
108  
        iterator
90  
        iterator
109  
{
91  
{
110  
/*  If you get a compile error here, it
92  
/*  If you get a compile error here, it
111  
    means that the iterators you passed
93  
    means that the iterators you passed
112  
    do not meet the requirements stated
94  
    do not meet the requirements stated
113  
    in the documentation.
95  
    in the documentation.
114  
*/
96  
*/
115  
    static_assert(
97  
    static_assert(
116  
        std::is_convertible<
98  
        std::is_convertible<
117  
            typename std::iterator_traits<
99  
            typename std::iterator_traits<
118  
                FwdIt>::reference,
100  
                FwdIt>::reference,
119  
            core::string_view>::value,
101  
            core::string_view>::value,
120  
        "Type requirements not met");
102  
        "Type requirements not met");
121  

103  

122  
    return u_->edit_segments(
104  
    return u_->edit_segments(
123  
        from.it_,
105  
        from.it_,
124  
        to.it_,
106  
        to.it_,
125  
        detail::make_segments_encoded_iter(
107  
        detail::make_segments_encoded_iter(
126 -
}
 
127 -

 
128 -
//------------------------------------------------
 
129 -

 
130 -
inline
 
131 -
void
 
132 -
segments_encoded_ref::
 
133 -
push_back(
 
134 -
    pct_string_view s)
 
135 -
{
 
136 -
    insert(end(), s);
 
137 -
}
 
138 -

 
139 -
inline
 
140 -
void
 
141 -
segments_encoded_ref::
 
142 -
pop_back() noexcept
 
143 -
{
 
144 -
    erase(std::prev(end()));
 
145  
            first, last));
108  
            first, last));
146  
}
109  
}
147  

110  

148  
//------------------------------------------------
111  
//------------------------------------------------
149  

112  

150  
template<class FwdIt>
113  
template<class FwdIt>
151  
auto
114  
auto
152  
segments_encoded_ref::
115  
segments_encoded_ref::
153  
insert(
116  
insert(
154  
    iterator before,
117  
    iterator before,
155  
    FwdIt first,
118  
    FwdIt first,
156  
    FwdIt last,
119  
    FwdIt last,
157  
    std::forward_iterator_tag) ->
120  
    std::forward_iterator_tag) ->
158  
        iterator
121  
        iterator
159  
{
122  
{
160  
    return u_->edit_segments(
123  
    return u_->edit_segments(
161  
        before.it_,
124  
        before.it_,
162  
        before.it_,
125  
        before.it_,
163  
        detail::make_segments_encoded_iter(
126  
        detail::make_segments_encoded_iter(
164  
            first, last));
127  
            first, last));
165  
}
128  
}
166  

129  

167  
} // urls
130  
} // urls
168  
} // boost
131  
} // boost
169  

132  

170  
#endif
133  
#endif