Line data Source code
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_HPP
12 : #define BOOST_URL_IMPL_SEGMENTS_REF_HPP
13 :
14 : #include <boost/url/detail/config.hpp>
15 : #include <boost/url/detail/any_segments_iter.hpp>
16 : #include <boost/url/detail/segments_iter_impl.hpp>
17 : #include <type_traits>
18 :
19 : namespace boost {
20 : namespace urls {
21 :
22 : //------------------------------------------------
23 : //
24 : // Modifiers
25 : //
26 : //------------------------------------------------
27 :
28 : template<class FwdIt>
29 : void
30 34 : segments_ref::
31 : assign(FwdIt first, FwdIt last)
32 : {
33 : /* If you get a compile error here, it
34 : means that the iterators you passed
35 : do not meet the requirements stated
36 : in the documentation.
37 : */
38 : static_assert(
39 : std::is_convertible<
40 : typename std::iterator_traits<
41 : FwdIt>::reference,
42 : core::string_view>::value,
43 : "Type requirements not met");
44 :
45 68 : u_->edit_segments(
46 34 : begin().it_,
47 68 : end().it_,
48 : detail::make_segments_iter(
49 : first, last));
50 34 : }
51 :
52 : template<class FwdIt>
53 : auto
54 31 : segments_ref::
55 : insert(
56 : iterator before,
57 : FwdIt first,
58 : FwdIt last) ->
59 : iterator
60 : {
61 : /* If you get a compile error here, it
62 : means that the iterators you passed
63 : do not meet the requirements stated
64 : in the documentation.
65 : */
66 : static_assert(
67 : std::is_convertible<
68 : typename std::iterator_traits<
69 : FwdIt>::reference,
70 : core::string_view>::value,
71 : "Type requirements not met");
72 :
73 62 : return insert(
74 : before,
75 : first,
76 : last,
77 : typename std::iterator_traits<
78 62 : FwdIt>::iterator_category{});
79 : }
80 :
81 : template<class FwdIt>
82 : auto
83 14 : segments_ref::
84 : replace(
85 : iterator from,
86 : iterator to,
87 : FwdIt first,
88 : FwdIt last) ->
89 : iterator
90 : {
91 : /* If you get a compile error here, it
92 : means that the iterators you passed
93 : do not meet the requirements stated
94 : in the documentation.
95 : */
96 : static_assert(
97 : std::is_convertible<
98 : typename std::iterator_traits<
99 : FwdIt>::reference,
100 : core::string_view>::value,
101 : "Type requirements not met");
102 :
103 28 : return u_->edit_segments(
104 : from.it_,
105 : to.it_,
106 : detail::make_segments_iter(
107 28 : first, last));
108 : }
109 :
110 : //------------------------------------------------
111 :
112 : template<class FwdIt>
113 : auto
114 31 : segments_ref::
115 : insert(
116 : iterator before,
117 : FwdIt first,
118 : FwdIt last,
119 : std::forward_iterator_tag) ->
120 : iterator
121 : {
122 62 : return u_->edit_segments(
123 : before.it_,
124 : before.it_,
125 : detail::make_segments_iter(
126 62 : first, last));
127 : }
128 :
129 : } // urls
130 : } // boost
131 :
132 : #endif
|