99.40% Lines (167/168)
100.00% Functions (24/24)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 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) 2023 Alan de Freitas (alandefreitas@gmail.com) | 3 | // Copyright (c) 2023 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_DETAIL_IMPL_ANY_PARAMS_ITER_HPP | 11 | #ifndef BOOST_URL_DETAIL_IMPL_ANY_PARAMS_ITER_HPP | |||||
| 12 | #define BOOST_URL_DETAIL_IMPL_ANY_PARAMS_ITER_HPP | 12 | #define BOOST_URL_DETAIL_IMPL_ANY_PARAMS_ITER_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/url/encode.hpp> | 14 | #include <boost/url/encode.hpp> | |||||
| 15 | #include <boost/url/rfc/detail/charsets.hpp> | 15 | #include <boost/url/rfc/detail/charsets.hpp> | |||||
| 16 | #include <boost/assert.hpp> | 16 | #include <boost/assert.hpp> | |||||
| 17 | 17 | |||||||
| 18 | namespace boost { | 18 | namespace boost { | |||||
| 19 | namespace urls { | 19 | namespace urls { | |||||
| 20 | namespace detail { | 20 | namespace detail { | |||||
| 21 | 21 | |||||||
| 22 | /* | 22 | /* | |||||
| 23 | When a string is transformed into a range of | 23 | When a string is transformed into a range of | |||||
| 24 | params, the empty string becomes ambiguous: | 24 | params, the empty string becomes ambiguous: | |||||
| 25 | it can be an empty range, or a range with | 25 | it can be an empty range, or a range with | |||||
| 26 | one param. The value `not_empty` is used on | 26 | one param. The value `not_empty` is used on | |||||
| 27 | construction to inform the transformation | 27 | construction to inform the transformation | |||||
| 28 | that the empty string should be treated as | 28 | that the empty string should be treated as | |||||
| 29 | a one-element range. This simplifies | 29 | a one-element range. This simplifies | |||||
| 30 | edit_params(). | 30 | edit_params(). | |||||
| 31 | */ | 31 | */ | |||||
| 32 | 32 | |||||||
| 33 | //------------------------------------------------ | 33 | //------------------------------------------------ | |||||
| 34 | // | 34 | // | |||||
| 35 | // any_params_iter | 35 | // any_params_iter | |||||
| 36 | // | 36 | // | |||||
| 37 | //------------------------------------------------ | 37 | //------------------------------------------------ | |||||
| 38 | 38 | |||||||
| 39 | inline | 39 | inline | |||||
| HITCBC | 40 | 1695 | any_params_iter:: | 40 | 1701 | any_params_iter:: | ||
| 41 | ~any_params_iter() noexcept = default; | 41 | ~any_params_iter() noexcept = default; | |||||
| 42 | 42 | |||||||
| 43 | //------------------------------------------------ | 43 | //------------------------------------------------ | |||||
| 44 | // | 44 | // | |||||
| 45 | // query_iter | 45 | // query_iter | |||||
| 46 | // | 46 | // | |||||
| 47 | //------------------------------------------------ | 47 | //------------------------------------------------ | |||||
| 48 | 48 | |||||||
| 49 | inline | 49 | inline | |||||
| HITCBC | 50 | 429 | query_string_iter:: | 50 | 431 | query_string_iter:: | ||
| 51 | query_string_iter( | 51 | query_string_iter( | |||||
| 52 | core::string_view s, | 52 | core::string_view s, | |||||
| HITCBC | 53 | 429 | bool ne) noexcept | 53 | 431 | bool ne) noexcept | ||
| 54 | : any_params_iter( | 54 | : any_params_iter( | |||||
| HITCBC | 55 | 429 | s.empty() && ! ne, s) | 55 | 431 | s.empty() && ! ne, s) | ||
| 56 | { | 56 | { | |||||
| HITCBC | 57 | 429 | rewind(); | 57 | 431 | rewind(); | ||
| HITCBC | 58 | 429 | } | 58 | 431 | } | ||
| 59 | 59 | |||||||
| 60 | inline | 60 | inline | |||||
| 61 | void | 61 | void | |||||
| HITCBC | 62 | 598 | query_string_iter:: | 62 | 600 | query_string_iter:: | ||
| 63 | rewind() noexcept | 63 | rewind() noexcept | |||||
| 64 | { | 64 | { | |||||
| HITCBC | 65 | 598 | if(empty) | 65 | 600 | if(empty) | ||
| 66 | { | 66 | { | |||||
| HITCBC | 67 | 260 | at_end_ = true; | 67 | 262 | at_end_ = true; | ||
| HITCBC | 68 | 260 | return; | 68 | 262 | return; | ||
| 69 | } | 69 | } | |||||
| HITCBC | 70 | 338 | p_ = s0.begin(); | 70 | 338 | p_ = s0.begin(); | ||
| HITCBC | 71 | 338 | if(! s0.empty()) | 71 | 338 | if(! s0.empty()) | ||
| 72 | { | 72 | { | |||||
| 73 | auto pos = | 73 | auto pos = | |||||
| HITCBC | 74 | 330 | s0.find_first_of('&'); | 74 | 330 | s0.find_first_of('&'); | ||
| HITCBC | 75 | 330 | if(pos != core::string_view::npos) | 75 | 330 | if(pos != core::string_view::npos) | ||
| HITCBC | 76 | 314 | n_ = pos; | 76 | 314 | n_ = pos; | ||
| 77 | else | 77 | else | |||||
| HITCBC | 78 | 16 | n_ = s0.size(); | 78 | 16 | n_ = s0.size(); | ||
| 79 | } | 79 | } | |||||
| 80 | else | 80 | else | |||||
| 81 | { | 81 | { | |||||
| HITCBC | 82 | 8 | n_ = 0; | 82 | 8 | n_ = 0; | ||
| 83 | } | 83 | } | |||||
| HITCBC | 84 | 338 | at_end_ = false; | 84 | 338 | at_end_ = false; | ||
| 85 | } | 85 | } | |||||
| 86 | 86 | |||||||
| 87 | inline | 87 | inline | |||||
| 88 | bool | 88 | bool | |||||
| HITCBC | 89 | 755 | query_string_iter:: | 89 | 757 | query_string_iter:: | ||
| 90 | measure( | 90 | measure( | |||||
| 91 | std::size_t& n) noexcept | 91 | std::size_t& n) noexcept | |||||
| 92 | { | 92 | { | |||||
| HITCBC | 93 | 755 | if(at_end_) | 93 | 757 | if(at_end_) | ||
| HITCBC | 94 | 429 | return false; | 94 | 431 | return false; | ||
| 95 | // When interacting with the query as | 95 | // When interacting with the query as | |||||
| 96 | // an intact string, we do not treat | 96 | // an intact string, we do not treat | |||||
| 97 | // the plus sign as an encoded space. | 97 | // the plus sign as an encoded space. | |||||
| HITCBC | 98 | 326 | encoding_opts opt; | 98 | 326 | encoding_opts opt; | ||
| HITCBC | 99 | 326 | opt.space_as_plus = false; | 99 | 326 | opt.space_as_plus = false; | ||
| HITCBC | 100 | 326 | n += encoded_size( | 100 | 326 | n += encoded_size( | ||
| 101 | core::string_view(p_, n_), | 101 | core::string_view(p_, n_), | |||||
| 102 | query_chars, | 102 | query_chars, | |||||
| 103 | opt); | 103 | opt); | |||||
| HITCBC | 104 | 326 | increment(); | 104 | 326 | increment(); | ||
| HITCBC | 105 | 326 | return true; | 105 | 326 | return true; | ||
| 106 | } | 106 | } | |||||
| 107 | 107 | |||||||
| 108 | inline | 108 | inline | |||||
| 109 | void | 109 | void | |||||
| HITCBC | 110 | 326 | query_string_iter:: | 110 | 326 | query_string_iter:: | ||
| 111 | copy( | 111 | copy( | |||||
| 112 | char*& dest, | 112 | char*& dest, | |||||
| 113 | char const* end) noexcept | 113 | char const* end) noexcept | |||||
| 114 | { | 114 | { | |||||
| HITCBC | 115 | 326 | BOOST_ASSERT(! at_end_); | 115 | 326 | BOOST_ASSERT(! at_end_); | ||
| 116 | // When interacting with the query as | 116 | // When interacting with the query as | |||||
| 117 | // an intact string, we do not treat | 117 | // an intact string, we do not treat | |||||
| 118 | // the plus sign as an encoded space. | 118 | // the plus sign as an encoded space. | |||||
| HITCBC | 119 | 326 | encoding_opts opt; | 119 | 326 | encoding_opts opt; | ||
| HITCBC | 120 | 326 | opt.space_as_plus = false; | 120 | 326 | opt.space_as_plus = false; | ||
| HITCBC | 121 | 326 | dest += encode_unsafe( | 121 | 326 | dest += encode_unsafe( | ||
| 122 | dest, | 122 | dest, | |||||
| HITCBC | 123 | 326 | end - dest, | 123 | 326 | end - dest, | ||
| 124 | core::string_view(p_, n_), | 124 | core::string_view(p_, n_), | |||||
| 125 | query_chars, | 125 | query_chars, | |||||
| 126 | opt); | 126 | opt); | |||||
| HITCBC | 127 | 326 | increment(); | 127 | 326 | increment(); | ||
| HITCBC | 128 | 326 | } | 128 | 326 | } | ||
| 129 | 129 | |||||||
| 130 | inline | 130 | inline | |||||
| 131 | void | 131 | void | |||||
| HITCBC | 132 | 652 | query_string_iter:: | 132 | 652 | query_string_iter:: | ||
| 133 | increment() noexcept | 133 | increment() noexcept | |||||
| 134 | { | 134 | { | |||||
| HITCBC | 135 | 652 | p_ += n_; | 135 | 652 | p_ += n_; | ||
| HITCBC | 136 | 652 | if(p_ == s0.end()) | 136 | 652 | if(p_ == s0.end()) | ||
| 137 | { | 137 | { | |||||
| HITCBC | 138 | 338 | at_end_ = true; | 138 | 338 | at_end_ = true; | ||
| HITCBC | 139 | 338 | return; | 139 | 338 | return; | ||
| 140 | } | 140 | } | |||||
| HITCBC | 141 | 314 | ++p_; | 141 | 314 | ++p_; | ||
| HITCBC | 142 | 314 | core::string_view s(p_, s0.end() - p_); | 142 | 314 | core::string_view s(p_, s0.end() - p_); | ||
| HITCBC | 143 | 314 | auto pos = s.find_first_of('&'); | 143 | 314 | auto pos = s.find_first_of('&'); | ||
| HITCBC | 144 | 314 | if(pos != core::string_view::npos) | 144 | 314 | if(pos != core::string_view::npos) | ||
| MISUBC | 145 | ✗ | n_ = pos; | 145 | ✗ | n_ = pos; | ||
| 146 | else | 146 | else | |||||
| HITCBC | 147 | 314 | n_ = s.size(); | 147 | 314 | n_ = s.size(); | ||
| 148 | } | 148 | } | |||||
| 149 | 149 | |||||||
| 150 | //------------------------------------------------ | 150 | //------------------------------------------------ | |||||
| 151 | // | 151 | // | |||||
| 152 | // param_iter | 152 | // param_iter | |||||
| 153 | // | 153 | // | |||||
| 154 | //------------------------------------------------ | 154 | //------------------------------------------------ | |||||
| 155 | 155 | |||||||
| 156 | inline | 156 | inline | |||||
| HITCBC | 157 | 1176 | single_param_iter:: | 157 | 1180 | single_param_iter:: | ||
| 158 | single_param_iter( | 158 | single_param_iter( | |||||
| 159 | param_view const& p, | 159 | param_view const& p, | |||||
| HITCBC | 160 | 1176 | bool space_as_plus) noexcept | 160 | 1180 | bool space_as_plus) noexcept | ||
| 161 | : any_params_iter( | 161 | : any_params_iter( | |||||
| 162 | false, | 162 | false, | |||||
| 163 | p.key, | 163 | p.key, | |||||
| 164 | p.value) | 164 | p.value) | |||||
| HITCBC | 165 | 1176 | , has_value_(p.has_value) | 165 | 1180 | , has_value_(p.has_value) | ||
| HITCBC | 166 | 1176 | , space_as_plus_(space_as_plus) | 166 | 1180 | , space_as_plus_(space_as_plus) | ||
| 167 | { | 167 | { | |||||
| HITCBC | 168 | 1176 | } | 168 | 1180 | } | ||
| 169 | 169 | |||||||
| 170 | inline | 170 | inline | |||||
| 171 | void | 171 | void | |||||
| HITCBC | 172 | 1176 | single_param_iter:: | 172 | 1180 | single_param_iter:: | ||
| 173 | rewind() noexcept | 173 | rewind() noexcept | |||||
| 174 | { | 174 | { | |||||
| HITCBC | 175 | 1176 | at_end_ = false; | 175 | 1180 | at_end_ = false; | ||
| HITCBC | 176 | 1176 | } | 176 | 1180 | } | ||
| 177 | 177 | |||||||
| 178 | inline | 178 | inline | |||||
| 179 | bool | 179 | bool | |||||
| HITCBC | 180 | 2352 | single_param_iter:: | 180 | 2360 | single_param_iter:: | ||
| 181 | measure(std::size_t& n) noexcept | 181 | measure(std::size_t& n) noexcept | |||||
| 182 | { | 182 | { | |||||
| HITCBC | 183 | 2352 | if(at_end_) | 183 | 2360 | if(at_end_) | ||
| HITCBC | 184 | 1176 | return false; | 184 | 1180 | return false; | ||
| HITCBC | 185 | 1176 | encoding_opts opt; | 185 | 1180 | encoding_opts opt; | ||
| HITCBC | 186 | 1176 | opt.space_as_plus = space_as_plus_; | 186 | 1180 | opt.space_as_plus = space_as_plus_; | ||
| HITCBC | 187 | 1176 | n += encoded_size( | 187 | 1180 | n += encoded_size( | ||
| 188 | s0, | 188 | s0, | |||||
| 189 | detail::param_key_chars, | 189 | detail::param_key_chars, | |||||
| 190 | opt); | 190 | opt); | |||||
| HITCBC | 191 | 1176 | if(has_value_) | 191 | 1180 | if(has_value_) | ||
| 192 | { | 192 | { | |||||
| HITCBC | 193 | 1176 | ++n; // '=' | 193 | 1180 | ++n; // '=' | ||
| HITCBC | 194 | 1176 | n += encoded_size( | 194 | 1180 | n += encoded_size( | ||
| 195 | s1, | 195 | s1, | |||||
| 196 | detail::param_value_chars, | 196 | detail::param_value_chars, | |||||
| 197 | opt); | 197 | opt); | |||||
| 198 | } | 198 | } | |||||
| HITCBC | 199 | 1176 | at_end_ = true; | 199 | 1180 | at_end_ = true; | ||
| HITCBC | 200 | 1176 | return true; | 200 | 1180 | return true; | ||
| 201 | } | 201 | } | |||||
| 202 | 202 | |||||||
| 203 | inline | 203 | inline | |||||
| 204 | void | 204 | void | |||||
| HITCBC | 205 | 1176 | single_param_iter:: | 205 | 1180 | single_param_iter:: | ||
| 206 | copy( | 206 | copy( | |||||
| 207 | char*& dest, | 207 | char*& dest, | |||||
| 208 | char const* end) noexcept | 208 | char const* end) noexcept | |||||
| 209 | { | 209 | { | |||||
| HITCBC | 210 | 1176 | BOOST_ASSERT(! at_end_); | 210 | 1180 | BOOST_ASSERT(! at_end_); | ||
| HITCBC | 211 | 1176 | encoding_opts opt; | 211 | 1180 | encoding_opts opt; | ||
| HITCBC | 212 | 1176 | opt.space_as_plus = space_as_plus_; | 212 | 1180 | opt.space_as_plus = space_as_plus_; | ||
| HITCBC | 213 | 2352 | dest += encode( | 213 | 2360 | dest += encode( | ||
| 214 | dest, | 214 | dest, | |||||
| HITCBC | 215 | 1176 | end - dest, | 215 | 1180 | end - dest, | ||
| 216 | s0, | 216 | s0, | |||||
| 217 | detail::param_key_chars, | 217 | detail::param_key_chars, | |||||
| 218 | opt); | 218 | opt); | |||||
| HITCBC | 219 | 1176 | if (has_value_) | 219 | 1180 | if (has_value_) | ||
| 220 | { | 220 | { | |||||
| HITCBC | 221 | 1176 | *dest++ = '='; | 221 | 1180 | *dest++ = '='; | ||
| HITCBC | 222 | 1176 | dest += encode( | 222 | 1180 | dest += encode( | ||
| 223 | dest, | 223 | dest, | |||||
| HITCBC | 224 | 1176 | end - dest, | 224 | 1180 | end - dest, | ||
| 225 | s1, | 225 | s1, | |||||
| 226 | detail::param_value_chars, | 226 | detail::param_value_chars, | |||||
| 227 | opt); | 227 | opt); | |||||
| 228 | } | 228 | } | |||||
| HITCBC | 229 | 1176 | } | 229 | 1180 | } | ||
| 230 | 230 | |||||||
| 231 | //------------------------------------------------ | 231 | //------------------------------------------------ | |||||
| 232 | // | 232 | // | |||||
| 233 | // params_iter_base | 233 | // params_iter_base | |||||
| 234 | // | 234 | // | |||||
| 235 | //------------------------------------------------ | 235 | //------------------------------------------------ | |||||
| 236 | 236 | |||||||
| 237 | inline | 237 | inline | |||||
| 238 | void | 238 | void | |||||
| HITCBC | 239 | 70 | params_iter_base:: | 239 | 70 | params_iter_base:: | ||
| 240 | measure_impl( | 240 | measure_impl( | |||||
| 241 | std::size_t& n, | 241 | std::size_t& n, | |||||
| 242 | param_view const& p) noexcept | 242 | param_view const& p) noexcept | |||||
| 243 | { | 243 | { | |||||
| HITCBC | 244 | 70 | encoding_opts opt; | 244 | 70 | encoding_opts opt; | ||
| HITCBC | 245 | 70 | opt.space_as_plus = space_as_plus_; | 245 | 70 | opt.space_as_plus = space_as_plus_; | ||
| HITCBC | 246 | 70 | n += encoded_size( | 246 | 70 | n += encoded_size( | ||
| 247 | p.key, | 247 | p.key, | |||||
| 248 | detail::param_key_chars, | 248 | detail::param_key_chars, | |||||
| 249 | opt); | 249 | opt); | |||||
| HITCBC | 250 | 70 | if(p.has_value) | 250 | 70 | if(p.has_value) | ||
| 251 | { | 251 | { | |||||
| HITCBC | 252 | 58 | ++n; // '=' | 252 | 58 | ++n; // '=' | ||
| HITCBC | 253 | 58 | n += encoded_size( | 253 | 58 | n += encoded_size( | ||
| 254 | p.value, | 254 | p.value, | |||||
| 255 | detail::param_value_chars, | 255 | detail::param_value_chars, | |||||
| 256 | opt); | 256 | opt); | |||||
| 257 | } | 257 | } | |||||
| HITCBC | 258 | 70 | } | 258 | 70 | } | ||
| 259 | 259 | |||||||
| 260 | inline | 260 | inline | |||||
| 261 | void | 261 | void | |||||
| HITCBC | 262 | 70 | params_iter_base:: | 262 | 70 | params_iter_base:: | ||
| 263 | copy_impl( | 263 | copy_impl( | |||||
| 264 | char*& dest, | 264 | char*& dest, | |||||
| 265 | char const* end, | 265 | char const* end, | |||||
| 266 | param_view const& p) noexcept | 266 | param_view const& p) noexcept | |||||
| 267 | { | 267 | { | |||||
| HITCBC | 268 | 70 | encoding_opts opt; | 268 | 70 | encoding_opts opt; | ||
| HITCBC | 269 | 70 | opt.space_as_plus = space_as_plus_; | 269 | 70 | opt.space_as_plus = space_as_plus_; | ||
| HITCBC | 270 | 140 | dest += encode( | 270 | 140 | dest += encode( | ||
| 271 | dest, | 271 | dest, | |||||
| HITCBC | 272 | 70 | end - dest, | 272 | 70 | end - dest, | ||
| 273 | p.key, | 273 | p.key, | |||||
| 274 | detail::param_key_chars, | 274 | detail::param_key_chars, | |||||
| 275 | opt); | 275 | opt); | |||||
| HITCBC | 276 | 70 | if(p.has_value) | 276 | 70 | if(p.has_value) | ||
| 277 | { | 277 | { | |||||
| HITCBC | 278 | 58 | *dest++ = '='; | 278 | 58 | *dest++ = '='; | ||
| HITCBC | 279 | 58 | dest += encode( | 279 | 58 | dest += encode( | ||
| 280 | dest, | 280 | dest, | |||||
| HITCBC | 281 | 58 | end - dest, | 281 | 58 | end - dest, | ||
| 282 | p.value, | 282 | p.value, | |||||
| 283 | detail::param_value_chars, | 283 | detail::param_value_chars, | |||||
| 284 | opt); | 284 | opt); | |||||
| 285 | } | 285 | } | |||||
| HITCBC | 286 | 70 | } | 286 | 70 | } | ||
| 287 | 287 | |||||||
| 288 | //------------------------------------------------ | 288 | //------------------------------------------------ | |||||
| 289 | // | 289 | // | |||||
| 290 | // param_encoded_iter | 290 | // param_encoded_iter | |||||
| 291 | // | 291 | // | |||||
| 292 | //------------------------------------------------ | 292 | //------------------------------------------------ | |||||
| 293 | 293 | |||||||
| 294 | inline | 294 | inline | |||||
| HITCBC | 295 | 12 | param_encoded_iter:: | 295 | 12 | param_encoded_iter:: | ||
| 296 | param_encoded_iter( | 296 | param_encoded_iter( | |||||
| HITCBC | 297 | 12 | param_pct_view const& p) noexcept | 297 | 12 | param_pct_view const& p) noexcept | ||
| 298 | : any_params_iter( | 298 | : any_params_iter( | |||||
| 299 | false, | 299 | false, | |||||
| 300 | p.key, | 300 | p.key, | |||||
| 301 | p.value) | 301 | p.value) | |||||
| HITCBC | 302 | 12 | , has_value_(p.has_value) | 302 | 12 | , has_value_(p.has_value) | ||
| 303 | { | 303 | { | |||||
| HITCBC | 304 | 12 | } | 304 | 12 | } | ||
| 305 | 305 | |||||||
| 306 | inline | 306 | inline | |||||
| 307 | void | 307 | void | |||||
| HITCBC | 308 | 12 | param_encoded_iter:: | 308 | 12 | param_encoded_iter:: | ||
| 309 | rewind() noexcept | 309 | rewind() noexcept | |||||
| 310 | { | 310 | { | |||||
| HITCBC | 311 | 12 | at_end_ = false; | 311 | 12 | at_end_ = false; | ||
| HITCBC | 312 | 12 | } | 312 | 12 | } | ||
| 313 | 313 | |||||||
| 314 | inline | 314 | inline | |||||
| 315 | bool | 315 | bool | |||||
| HITCBC | 316 | 24 | param_encoded_iter:: | 316 | 24 | param_encoded_iter:: | ||
| 317 | measure(std::size_t& n) noexcept | 317 | measure(std::size_t& n) noexcept | |||||
| 318 | { | 318 | { | |||||
| HITCBC | 319 | 24 | if(at_end_) | 319 | 24 | if(at_end_) | ||
| HITCBC | 320 | 12 | return false; | 320 | 12 | return false; | ||
| HITCBC | 321 | 12 | n += detail::re_encoded_size_unsafe( | 321 | 12 | n += detail::re_encoded_size_unsafe( | ||
| 322 | s0, | 322 | s0, | |||||
| 323 | detail::param_key_chars); | 323 | detail::param_key_chars); | |||||
| HITCBC | 324 | 12 | if(has_value_) | 324 | 12 | if(has_value_) | ||
| HITCBC | 325 | 12 | n += detail::re_encoded_size_unsafe( | 325 | 12 | n += detail::re_encoded_size_unsafe( | ||
| 326 | s1, | 326 | s1, | |||||
| HITCBC | 327 | 12 | detail::param_value_chars) + 1; // for '=' | 327 | 12 | detail::param_value_chars) + 1; // for '=' | ||
| HITCBC | 328 | 12 | at_end_ = true; | 328 | 12 | at_end_ = true; | ||
| HITCBC | 329 | 12 | return true; | 329 | 12 | return true; | ||
| 330 | } | 330 | } | |||||
| 331 | 331 | |||||||
| 332 | inline | 332 | inline | |||||
| 333 | void | 333 | void | |||||
| HITCBC | 334 | 12 | param_encoded_iter:: | 334 | 12 | param_encoded_iter:: | ||
| 335 | copy( | 335 | copy( | |||||
| 336 | char*& dest, | 336 | char*& dest, | |||||
| 337 | char const* end) noexcept | 337 | char const* end) noexcept | |||||
| 338 | { | 338 | { | |||||
| HITCBC | 339 | 12 | detail::re_encode_unsafe( | 339 | 12 | detail::re_encode_unsafe( | ||
| 340 | dest, | 340 | dest, | |||||
| 341 | end, | 341 | end, | |||||
| 342 | s0, | 342 | s0, | |||||
| 343 | detail::param_key_chars); | 343 | detail::param_key_chars); | |||||
| HITCBC | 344 | 12 | if(has_value_) | 344 | 12 | if(has_value_) | ||
| 345 | { | 345 | { | |||||
| HITCBC | 346 | 12 | *dest++ = '='; | 346 | 12 | *dest++ = '='; | ||
| HITCBC | 347 | 12 | detail::re_encode_unsafe( | 347 | 12 | detail::re_encode_unsafe( | ||
| 348 | dest, | 348 | dest, | |||||
| 349 | end, | 349 | end, | |||||
| 350 | s1, | 350 | s1, | |||||
| 351 | detail::param_value_chars); | 351 | detail::param_value_chars); | |||||
| 352 | } | 352 | } | |||||
| HITCBC | 353 | 12 | } | 353 | 12 | } | ||
| 354 | 354 | |||||||
| 355 | 355 | |||||||
| 356 | //------------------------------------------------ | 356 | //------------------------------------------------ | |||||
| 357 | // | 357 | // | |||||
| 358 | // params_encoded_iter_base | 358 | // params_encoded_iter_base | |||||
| 359 | // | 359 | // | |||||
| 360 | //------------------------------------------------ | 360 | //------------------------------------------------ | |||||
| 361 | 361 | |||||||
| 362 | inline | 362 | inline | |||||
| 363 | void | 363 | void | |||||
| HITCBC | 364 | 51 | params_encoded_iter_base:: | 364 | 51 | params_encoded_iter_base:: | ||
| 365 | measure_impl( | 365 | measure_impl( | |||||
| 366 | std::size_t& n, | 366 | std::size_t& n, | |||||
| 367 | param_view const& p) noexcept | 367 | param_view const& p) noexcept | |||||
| 368 | { | 368 | { | |||||
| HITCBC | 369 | 51 | n += detail::re_encoded_size_unsafe( | 369 | 51 | n += detail::re_encoded_size_unsafe( | ||
| 370 | p.key, | 370 | p.key, | |||||
| 371 | detail::param_key_chars); | 371 | detail::param_key_chars); | |||||
| HITCBC | 372 | 51 | if(p.has_value) | 372 | 51 | if(p.has_value) | ||
| HITCBC | 373 | 42 | n += detail::re_encoded_size_unsafe( | 373 | 42 | n += detail::re_encoded_size_unsafe( | ||
| 374 | p.value, | 374 | p.value, | |||||
| HITCBC | 375 | 42 | detail::param_value_chars) + 1; // for '=' | 375 | 42 | detail::param_value_chars) + 1; // for '=' | ||
| HITCBC | 376 | 51 | } | 376 | 51 | } | ||
| 377 | 377 | |||||||
| 378 | inline | 378 | inline | |||||
| 379 | void | 379 | void | |||||
| HITCBC | 380 | 51 | params_encoded_iter_base:: | 380 | 51 | params_encoded_iter_base:: | ||
| 381 | copy_impl( | 381 | copy_impl( | |||||
| 382 | char*& dest, | 382 | char*& dest, | |||||
| 383 | char const* end, | 383 | char const* end, | |||||
| 384 | param_view const& p) noexcept | 384 | param_view const& p) noexcept | |||||
| 385 | { | 385 | { | |||||
| HITCBC | 386 | 51 | detail::re_encode_unsafe( | 386 | 51 | detail::re_encode_unsafe( | ||
| 387 | dest, | 387 | dest, | |||||
| 388 | end, | 388 | end, | |||||
| 389 | p.key, | 389 | p.key, | |||||
| 390 | detail::param_key_chars); | 390 | detail::param_key_chars); | |||||
| HITCBC | 391 | 51 | if(p.has_value) | 391 | 51 | if(p.has_value) | ||
| 392 | { | 392 | { | |||||
| HITCBC | 393 | 42 | *dest++ = '='; | 393 | 42 | *dest++ = '='; | ||
| HITCBC | 394 | 42 | detail::re_encode_unsafe( | 394 | 42 | detail::re_encode_unsafe( | ||
| 395 | dest, | 395 | dest, | |||||
| 396 | end, | 396 | end, | |||||
| 397 | p.value, | 397 | p.value, | |||||
| 398 | detail::param_value_chars); | 398 | detail::param_value_chars); | |||||
| 399 | } | 399 | } | |||||
| HITCBC | 400 | 51 | } | 400 | 51 | } | ||
| 401 | 401 | |||||||
| 402 | //------------------------------------------------ | 402 | //------------------------------------------------ | |||||
| 403 | // | 403 | // | |||||
| 404 | // param_value_iter | 404 | // param_value_iter | |||||
| 405 | // | 405 | // | |||||
| 406 | //------------------------------------------------ | 406 | //------------------------------------------------ | |||||
| 407 | 407 | |||||||
| 408 | inline | 408 | inline | |||||
| 409 | void | 409 | void | |||||
| HITCBC | 410 | 9 | param_value_iter:: | 410 | 9 | param_value_iter:: | ||
| 411 | rewind() noexcept | 411 | rewind() noexcept | |||||
| 412 | { | 412 | { | |||||
| HITCBC | 413 | 9 | at_end_ = false; | 413 | 9 | at_end_ = false; | ||
| HITCBC | 414 | 9 | } | 414 | 9 | } | ||
| 415 | 415 | |||||||
| 416 | inline | 416 | inline | |||||
| 417 | bool | 417 | bool | |||||
| HITCBC | 418 | 18 | param_value_iter:: | 418 | 18 | param_value_iter:: | ||
| 419 | measure( | 419 | measure( | |||||
| 420 | std::size_t& n) noexcept | 420 | std::size_t& n) noexcept | |||||
| 421 | { | 421 | { | |||||
| HITCBC | 422 | 18 | if(at_end_) | 422 | 18 | if(at_end_) | ||
| HITCBC | 423 | 9 | return false; | 423 | 9 | return false; | ||
| HITCBC | 424 | 9 | n += nk_; // skip key | 424 | 9 | n += nk_; // skip key | ||
| HITCBC | 425 | 9 | if(has_value_) | 425 | 9 | if(has_value_) | ||
| 426 | { | 426 | { | |||||
| HITCBC | 427 | 5 | encoding_opts opt; | 427 | 5 | encoding_opts opt; | ||
| HITCBC | 428 | 5 | opt.space_as_plus = false; | 428 | 5 | opt.space_as_plus = false; | ||
| HITCBC | 429 | 5 | n += encoded_size( | 429 | 5 | n += encoded_size( | ||
| 430 | s0, | 430 | s0, | |||||
| 431 | detail::param_value_chars, | 431 | detail::param_value_chars, | |||||
| HITCBC | 432 | 5 | opt) + 1; // for '=' | 432 | 5 | opt) + 1; // for '=' | ||
| 433 | } | 433 | } | |||||
| HITCBC | 434 | 9 | at_end_ = true; | 434 | 9 | at_end_ = true; | ||
| HITCBC | 435 | 9 | return true; | 435 | 9 | return true; | ||
| 436 | } | 436 | } | |||||
| 437 | 437 | |||||||
| 438 | inline | 438 | inline | |||||
| 439 | void | 439 | void | |||||
| HITCBC | 440 | 9 | param_value_iter:: | 440 | 9 | param_value_iter:: | ||
| 441 | copy(char*& it, char const* end) noexcept | 441 | copy(char*& it, char const* end) noexcept | |||||
| 442 | { | 442 | { | |||||
| HITCBC | 443 | 9 | it += nk_; // skip key | 443 | 9 | it += nk_; // skip key | ||
| HITCBC | 444 | 9 | if(! has_value_) | 444 | 9 | if(! has_value_) | ||
| HITCBC | 445 | 4 | return; | 445 | 4 | return; | ||
| HITCBC | 446 | 5 | *it++ = '='; | 446 | 5 | *it++ = '='; | ||
| HITCBC | 447 | 5 | encoding_opts opt; | 447 | 5 | encoding_opts opt; | ||
| HITCBC | 448 | 5 | opt.space_as_plus = false; | 448 | 5 | opt.space_as_plus = false; | ||
| HITCBC | 449 | 5 | it += encode( | 449 | 5 | it += encode( | ||
| 450 | it, | 450 | it, | |||||
| HITCBC | 451 | 5 | end - it, | 451 | 5 | end - it, | ||
| 452 | s0, | 452 | s0, | |||||
| 453 | detail::param_value_chars, | 453 | detail::param_value_chars, | |||||
| 454 | opt); | 454 | opt); | |||||
| 455 | } | 455 | } | |||||
| 456 | 456 | |||||||
| 457 | //------------------------------------------------ | 457 | //------------------------------------------------ | |||||
| 458 | // | 458 | // | |||||
| 459 | // param_encoded_value_iter | 459 | // param_encoded_value_iter | |||||
| 460 | // | 460 | // | |||||
| 461 | //------------------------------------------------ | 461 | //------------------------------------------------ | |||||
| 462 | 462 | |||||||
| 463 | inline | 463 | inline | |||||
| 464 | void | 464 | void | |||||
| HITCBC | 465 | 8 | param_encoded_value_iter:: | 465 | 8 | param_encoded_value_iter:: | ||
| 466 | rewind() noexcept | 466 | rewind() noexcept | |||||
| 467 | { | 467 | { | |||||
| HITCBC | 468 | 8 | at_end_ = false; | 468 | 8 | at_end_ = false; | ||
| HITCBC | 469 | 8 | } | 469 | 8 | } | ||
| 470 | 470 | |||||||
| 471 | inline | 471 | inline | |||||
| 472 | bool | 472 | bool | |||||
| HITCBC | 473 | 16 | param_encoded_value_iter:: | 473 | 16 | param_encoded_value_iter:: | ||
| 474 | measure( | 474 | measure( | |||||
| 475 | std::size_t& n) noexcept | 475 | std::size_t& n) noexcept | |||||
| 476 | { | 476 | { | |||||
| HITCBC | 477 | 16 | if(at_end_) | 477 | 16 | if(at_end_) | ||
| HITCBC | 478 | 8 | return false; | 478 | 8 | return false; | ||
| HITCBC | 479 | 8 | n += nk_; // skip key | 479 | 8 | n += nk_; // skip key | ||
| HITCBC | 480 | 8 | if(has_value_) | 480 | 8 | if(has_value_) | ||
| 481 | { | 481 | { | |||||
| HITCBC | 482 | 4 | n += detail::re_encoded_size_unsafe( | 482 | 4 | n += detail::re_encoded_size_unsafe( | ||
| 483 | s0, | 483 | s0, | |||||
| HITCBC | 484 | 4 | detail::param_value_chars) + 1; // for '=' | 484 | 4 | detail::param_value_chars) + 1; // for '=' | ||
| 485 | } | 485 | } | |||||
| HITCBC | 486 | 8 | at_end_ = true; | 486 | 8 | at_end_ = true; | ||
| HITCBC | 487 | 8 | return true; | 487 | 8 | return true; | ||
| 488 | } | 488 | } | |||||
| 489 | 489 | |||||||
| 490 | inline | 490 | inline | |||||
| 491 | void | 491 | void | |||||
| HITCBC | 492 | 8 | param_encoded_value_iter:: | 492 | 8 | param_encoded_value_iter:: | ||
| 493 | copy( | 493 | copy( | |||||
| 494 | char*& dest, | 494 | char*& dest, | |||||
| 495 | char const* end) noexcept | 495 | char const* end) noexcept | |||||
| 496 | { | 496 | { | |||||
| HITCBC | 497 | 8 | dest += nk_; // skip key | 497 | 8 | dest += nk_; // skip key | ||
| HITCBC | 498 | 8 | if(! has_value_) | 498 | 8 | if(! has_value_) | ||
| HITCBC | 499 | 4 | return; | 499 | 4 | return; | ||
| HITCBC | 500 | 4 | *dest++ = '='; | 500 | 4 | *dest++ = '='; | ||
| HITCBC | 501 | 4 | detail::re_encode_unsafe( | 501 | 4 | detail::re_encode_unsafe( | ||
| 502 | dest, | 502 | dest, | |||||
| 503 | end, | 503 | end, | |||||
| 504 | s0, | 504 | s0, | |||||
| 505 | detail::param_value_chars); | 505 | detail::param_value_chars); | |||||
| 506 | } | 506 | } | |||||
| 507 | 507 | |||||||
| 508 | } // detail | 508 | } // detail | |||||
| 509 | } // urls | 509 | } // urls | |||||
| 510 | } // boost | 510 | } // boost | |||||
| 511 | 511 | |||||||
| 512 | #endif | 512 | #endif | |||||