File indexing completed on 2025-01-18 09:53:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_URL_IMPL_PARAMS_REF_HPP
0012 #define BOOST_URL_IMPL_PARAMS_REF_HPP
0013
0014 #include <boost/url/params_view.hpp>
0015 #include <boost/url/detail/any_params_iter.hpp>
0016 #include <boost/url/detail/except.hpp>
0017 #include <boost/url/grammar/recycled.hpp>
0018 #include <boost/assert.hpp>
0019
0020 namespace boost {
0021 namespace urls {
0022
0023 inline
0024 params_ref::
0025 params_ref(
0026 url_base& u,
0027 encoding_opts opt) noexcept
0028 : params_base(u.impl_, opt)
0029 , u_(&u)
0030 {
0031 }
0032
0033
0034
0035
0036
0037
0038
0039 inline
0040 params_ref::
0041 params_ref(
0042 params_ref const& other,
0043 encoding_opts opt) noexcept
0044 : params_ref(*other.u_, opt)
0045 {
0046 }
0047
0048 inline
0049 auto
0050 params_ref::
0051 operator=(std::initializer_list<
0052 param_view> init) ->
0053 params_ref&
0054 {
0055 assign(init);
0056 return *this;
0057 }
0058
0059
0060
0061
0062
0063
0064
0065 inline
0066 void
0067 params_ref::
0068 clear() noexcept
0069 {
0070 u_->remove_query();
0071 }
0072
0073
0074
0075 template<class FwdIt>
0076 void
0077 params_ref::
0078 assign(FwdIt first, FwdIt last)
0079 {
0080
0081
0082
0083
0084
0085 static_assert(
0086 std::is_convertible<
0087 typename std::iterator_traits<
0088 FwdIt>::reference,
0089 param_view>::value,
0090 "Type requirements not met");
0091
0092 assign(first, last,
0093 typename std::iterator_traits<
0094 FwdIt>::iterator_category{});
0095 }
0096
0097 inline
0098 auto
0099 params_ref::
0100 append(
0101 param_view const& p) ->
0102 iterator
0103 {
0104 return insert(end(), p);
0105 }
0106
0107 inline
0108 auto
0109 params_ref::
0110 append(
0111 std::initializer_list<
0112 param_view> init) ->
0113 iterator
0114 {
0115 return insert(end(), init);
0116 }
0117
0118 template<class FwdIt>
0119 auto
0120 params_ref::
0121 append(FwdIt first, FwdIt last) ->
0122 iterator
0123 {
0124
0125
0126
0127
0128
0129 static_assert(
0130 std::is_convertible<
0131 typename std::iterator_traits<
0132 FwdIt>::reference,
0133 param_view>::value,
0134 "Type requirements not met");
0135
0136 return insert(
0137 end(), first, last);
0138 }
0139
0140 template<class FwdIt>
0141 auto
0142 params_ref::
0143 insert(
0144 iterator before,
0145 FwdIt first,
0146 FwdIt last) ->
0147 iterator
0148 {
0149
0150
0151
0152
0153
0154 static_assert(
0155 std::is_convertible<
0156 typename std::iterator_traits<
0157 FwdIt>::reference,
0158 param_view>::value,
0159 "Type requirements not met");
0160
0161 return insert(
0162 before,
0163 first,
0164 last,
0165 typename std::iterator_traits<
0166 FwdIt>::iterator_category{});
0167 }
0168
0169 template<class FwdIt>
0170 auto
0171 params_ref::
0172 replace(
0173 iterator from,
0174 iterator to,
0175 FwdIt first,
0176 FwdIt last) ->
0177 iterator
0178 {
0179
0180
0181
0182
0183
0184 static_assert(
0185 std::is_convertible<
0186 typename std::iterator_traits<
0187 FwdIt>::reference,
0188 param_view>::value,
0189 "Type requirements not met");
0190
0191 return iterator(
0192 u_->edit_params(
0193 from.it_, to.it_,
0194 detail::make_params_iter(
0195 first, last)),
0196 opt_);
0197 }
0198
0199
0200
0201
0202
0203
0204
0205 template<class FwdIt>
0206 void
0207 params_ref::
0208 assign(FwdIt first, FwdIt last,
0209 std::forward_iterator_tag)
0210 {
0211 u_->edit_params(
0212 begin().it_,
0213 end().it_,
0214 detail::make_params_iter(
0215 first, last));
0216 }
0217
0218 template<class FwdIt>
0219 auto
0220 params_ref::
0221 insert(
0222 iterator before,
0223 FwdIt first,
0224 FwdIt last,
0225 std::forward_iterator_tag) ->
0226 iterator
0227 {
0228 return iterator(
0229 u_->edit_params(
0230 before.it_,
0231 before.it_,
0232 detail::make_params_iter(
0233 first, last)),
0234 opt_);
0235 }
0236
0237 }
0238 }
0239
0240 #endif