100.00% Lines (62/62)
100.00% Functions (12/12)
| 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_SEGMENTS_ITER_HPP | 11 | #ifndef BOOST_URL_DETAIL_IMPL_ANY_SEGMENTS_ITER_HPP | |||||
| 12 | #define BOOST_URL_DETAIL_IMPL_ANY_SEGMENTS_ITER_HPP | 12 | #define BOOST_URL_DETAIL_IMPL_ANY_SEGMENTS_ITER_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/url/encode.hpp> | 14 | #include <boost/url/encode.hpp> | |||||
| 15 | #include <boost/url/rfc/pchars.hpp> | 15 | #include <boost/url/rfc/pchars.hpp> | |||||
| 16 | #include <boost/url/rfc/detail/charsets.hpp> | 16 | #include <boost/url/rfc/detail/charsets.hpp> | |||||
| 17 | #include <boost/url/detail/encode.hpp> | 17 | #include <boost/url/detail/encode.hpp> | |||||
| 18 | 18 | |||||||
| 19 | namespace boost { | 19 | namespace boost { | |||||
| 20 | namespace urls { | 20 | namespace urls { | |||||
| 21 | namespace detail { | 21 | namespace detail { | |||||
| 22 | 22 | |||||||
| 23 | //------------------------------------------------ | 23 | //------------------------------------------------ | |||||
| 24 | // | 24 | // | |||||
| 25 | // segment_iter | 25 | // segment_iter | |||||
| 26 | // | 26 | // | |||||
| 27 | //------------------------------------------------ | 27 | //------------------------------------------------ | |||||
| 28 | 28 | |||||||
| 29 | inline | 29 | inline | |||||
| HITCBC | 30 | 920 | segment_iter:: | 30 | 920 | segment_iter:: | ||
| 31 | segment_iter( | 31 | segment_iter( | |||||
| HITCBC | 32 | 920 | core::string_view s_) noexcept | 32 | 920 | core::string_view s_) noexcept | ||
| HITCBC | 33 | 920 | : any_segments_iter(s_) | 33 | 920 | : any_segments_iter(s_) | ||
| 34 | { | 34 | { | |||||
| HITCBC | 35 | 920 | front = s; | 35 | 920 | front = s; | ||
| HITCBC | 36 | 920 | fast_nseg = 1; | 36 | 920 | fast_nseg = 1; | ||
| HITCBC | 37 | 920 | } | 37 | 920 | } | ||
| 38 | 38 | |||||||
| 39 | inline | 39 | inline | |||||
| 40 | void | 40 | void | |||||
| HITCBC | 41 | 920 | segment_iter:: | 41 | 920 | segment_iter:: | ||
| 42 | rewind() noexcept | 42 | rewind() noexcept | |||||
| 43 | { | 43 | { | |||||
| HITCBC | 44 | 920 | at_end_ = false; | 44 | 920 | at_end_ = false; | ||
| HITCBC | 45 | 920 | } | 45 | 920 | } | ||
| 46 | 46 | |||||||
| 47 | inline | 47 | inline | |||||
| 48 | bool | 48 | bool | |||||
| HITCBC | 49 | 1840 | segment_iter:: | 49 | 1840 | segment_iter:: | ||
| 50 | measure( | 50 | measure( | |||||
| 51 | std::size_t& n) noexcept | 51 | std::size_t& n) noexcept | |||||
| 52 | { | 52 | { | |||||
| HITCBC | 53 | 1840 | if(at_end_) | 53 | 1840 | if(at_end_) | ||
| HITCBC | 54 | 920 | return false; | 54 | 920 | return false; | ||
| HITCBC | 55 | 920 | encoding_opts opt; | 55 | 920 | encoding_opts opt; | ||
| HITCBC | 56 | 920 | opt.space_as_plus = false; | 56 | 920 | opt.space_as_plus = false; | ||
| HITCBC | 57 | 920 | n += encoded_size( | 57 | 920 | n += encoded_size( | ||
| 58 | s, | 58 | s, | |||||
| HITCBC | 59 | 920 | encode_colons ? | 59 | 920 | encode_colons ? | ||
| 60 | nocolon_pchars : | 60 | nocolon_pchars : | |||||
| 61 | pchars, | 61 | pchars, | |||||
| 62 | opt); | 62 | opt); | |||||
| HITCBC | 63 | 920 | at_end_ = true; | 63 | 920 | at_end_ = true; | ||
| HITCBC | 64 | 920 | return true; | 64 | 920 | return true; | ||
| 65 | } | 65 | } | |||||
| 66 | 66 | |||||||
| 67 | inline | 67 | inline | |||||
| 68 | void | 68 | void | |||||
| HITCBC | 69 | 920 | segment_iter:: | 69 | 920 | segment_iter:: | ||
| 70 | copy( | 70 | copy( | |||||
| 71 | char*& dest, | 71 | char*& dest, | |||||
| 72 | char const* end) noexcept | 72 | char const* end) noexcept | |||||
| 73 | { | 73 | { | |||||
| HITCBC | 74 | 920 | encoding_opts opt; | 74 | 920 | encoding_opts opt; | ||
| HITCBC | 75 | 920 | opt.space_as_plus = false; | 75 | 920 | opt.space_as_plus = false; | ||
| HITCBC | 76 | 920 | dest += encode( | 76 | 920 | dest += encode( | ||
| 77 | dest, | 77 | dest, | |||||
| HITCBC | 78 | 920 | end - dest, | 78 | 920 | end - dest, | ||
| 79 | s, | 79 | s, | |||||
| HITCBC | 80 | 920 | encode_colons ? | 80 | 920 | encode_colons ? | ||
| 81 | nocolon_pchars : | 81 | nocolon_pchars : | |||||
| 82 | pchars, | 82 | pchars, | |||||
| 83 | opt); | 83 | opt); | |||||
| HITCBC | 84 | 920 | } | 84 | 920 | } | ||
| 85 | 85 | |||||||
| 86 | //------------------------------------------------ | 86 | //------------------------------------------------ | |||||
| 87 | // | 87 | // | |||||
| 88 | // segments_iter_base | 88 | // segments_iter_base | |||||
| 89 | // | 89 | // | |||||
| 90 | //------------------------------------------------ | 90 | //------------------------------------------------ | |||||
| 91 | 91 | |||||||
| 92 | inline | 92 | inline | |||||
| 93 | void | 93 | void | |||||
| HITCBC | 94 | 188 | segments_iter_base:: | 94 | 188 | segments_iter_base:: | ||
| 95 | measure_impl( | 95 | measure_impl( | |||||
| 96 | std::size_t& n, | 96 | std::size_t& n, | |||||
| 97 | core::string_view s, | 97 | core::string_view s, | |||||
| 98 | bool encode_colons) noexcept | 98 | bool encode_colons) noexcept | |||||
| 99 | { | 99 | { | |||||
| HITCBC | 100 | 188 | encoding_opts opt; | 100 | 188 | encoding_opts opt; | ||
| HITCBC | 101 | 188 | opt.space_as_plus = false; | 101 | 188 | opt.space_as_plus = false; | ||
| HITCBC | 102 | 188 | n += encoded_size( | 102 | 188 | n += encoded_size( | ||
| 103 | s, | 103 | s, | |||||
| 104 | encode_colons ? | 104 | encode_colons ? | |||||
| 105 | nocolon_pchars : | 105 | nocolon_pchars : | |||||
| 106 | pchars, | 106 | pchars, | |||||
| 107 | opt); | 107 | opt); | |||||
| HITCBC | 108 | 188 | } | 108 | 188 | } | ||
| 109 | 109 | |||||||
| 110 | inline | 110 | inline | |||||
| 111 | void | 111 | void | |||||
| HITCBC | 112 | 188 | segments_iter_base:: | 112 | 188 | segments_iter_base:: | ||
| 113 | copy_impl( | 113 | copy_impl( | |||||
| 114 | char*& dest, | 114 | char*& dest, | |||||
| 115 | char const* end, | 115 | char const* end, | |||||
| 116 | core::string_view s, | 116 | core::string_view s, | |||||
| 117 | bool encode_colons) noexcept | 117 | bool encode_colons) noexcept | |||||
| 118 | { | 118 | { | |||||
| HITCBC | 119 | 188 | encoding_opts opt; | 119 | 188 | encoding_opts opt; | ||
| HITCBC | 120 | 188 | opt.space_as_plus = false; | 120 | 188 | opt.space_as_plus = false; | ||
| HITCBC | 121 | 188 | dest += encode( | 121 | 188 | dest += encode( | ||
| 122 | dest, | 122 | dest, | |||||
| HITCBC | 123 | 188 | end - dest, | 123 | 188 | end - dest, | ||
| 124 | s, | 124 | s, | |||||
| 125 | encode_colons ? | 125 | encode_colons ? | |||||
| 126 | nocolon_pchars : | 126 | nocolon_pchars : | |||||
| 127 | pchars, | 127 | pchars, | |||||
| 128 | opt); | 128 | opt); | |||||
| HITCBC | 129 | 188 | } | 129 | 188 | } | ||
| 130 | 130 | |||||||
| 131 | //------------------------------------------------ | 131 | //------------------------------------------------ | |||||
| 132 | // | 132 | // | |||||
| 133 | // segment_encoded_iter | 133 | // segment_encoded_iter | |||||
| 134 | // | 134 | // | |||||
| 135 | //------------------------------------------------ | 135 | //------------------------------------------------ | |||||
| 136 | 136 | |||||||
| 137 | inline | 137 | inline | |||||
| HITCBC | 138 | 72 | segment_encoded_iter:: | 138 | 72 | segment_encoded_iter:: | ||
| 139 | segment_encoded_iter( | 139 | segment_encoded_iter( | |||||
| HITCBC | 140 | 72 | pct_string_view const& s_) noexcept | 140 | 72 | pct_string_view const& s_) noexcept | ||
| HITCBC | 141 | 72 | : any_segments_iter(s_) | 141 | 72 | : any_segments_iter(s_) | ||
| 142 | { | 142 | { | |||||
| HITCBC | 143 | 72 | front = s; | 143 | 72 | front = s; | ||
| HITCBC | 144 | 72 | fast_nseg = 1; | 144 | 72 | fast_nseg = 1; | ||
| HITCBC | 145 | 72 | } | 145 | 72 | } | ||
| 146 | 146 | |||||||
| 147 | inline | 147 | inline | |||||
| 148 | void | 148 | void | |||||
| HITCBC | 149 | 72 | segment_encoded_iter:: | 149 | 72 | segment_encoded_iter:: | ||
| 150 | rewind() noexcept | 150 | rewind() noexcept | |||||
| 151 | { | 151 | { | |||||
| HITCBC | 152 | 72 | at_end_ = false; | 152 | 72 | at_end_ = false; | ||
| HITCBC | 153 | 72 | } | 153 | 72 | } | ||
| 154 | 154 | |||||||
| 155 | inline | 155 | inline | |||||
| 156 | bool | 156 | bool | |||||
| HITCBC | 157 | 144 | segment_encoded_iter:: | 157 | 144 | segment_encoded_iter:: | ||
| 158 | measure( | 158 | measure( | |||||
| 159 | std::size_t& n) noexcept | 159 | std::size_t& n) noexcept | |||||
| 160 | { | 160 | { | |||||
| HITCBC | 161 | 144 | if(at_end_) | 161 | 144 | if(at_end_) | ||
| HITCBC | 162 | 72 | return false; | 162 | 72 | return false; | ||
| HITCBC | 163 | 72 | n += detail::re_encoded_size_unsafe( | 163 | 72 | n += detail::re_encoded_size_unsafe( | ||
| 164 | s, | 164 | s, | |||||
| HITCBC | 165 | 72 | encode_colons ? | 165 | 72 | encode_colons ? | ||
| 166 | nocolon_pchars : | 166 | nocolon_pchars : | |||||
| 167 | pchars); | 167 | pchars); | |||||
| HITCBC | 168 | 72 | at_end_ = true; | 168 | 72 | at_end_ = true; | ||
| HITCBC | 169 | 72 | return true; | 169 | 72 | return true; | ||
| 170 | } | 170 | } | |||||
| 171 | 171 | |||||||
| 172 | inline | 172 | inline | |||||
| 173 | void | 173 | void | |||||
| HITCBC | 174 | 72 | segment_encoded_iter:: | 174 | 72 | segment_encoded_iter:: | ||
| 175 | copy( | 175 | copy( | |||||
| 176 | char*& dest, | 176 | char*& dest, | |||||
| 177 | char const* end) noexcept | 177 | char const* end) noexcept | |||||
| 178 | { | 178 | { | |||||
| HITCBC | 179 | 72 | detail::re_encode_unsafe( | 179 | 72 | detail::re_encode_unsafe( | ||
| 180 | dest, | 180 | dest, | |||||
| 181 | end, | 181 | end, | |||||
| 182 | s, | 182 | s, | |||||
| HITCBC | 183 | 72 | encode_colons ? | 183 | 72 | encode_colons ? | ||
| 184 | nocolon_pchars : | 184 | nocolon_pchars : | |||||
| 185 | pchars); | 185 | pchars); | |||||
| HITCBC | 186 | 72 | } | 186 | 72 | } | ||
| 187 | 187 | |||||||
| 188 | //------------------------------------------------ | 188 | //------------------------------------------------ | |||||
| 189 | // | 189 | // | |||||
| 190 | // segments_encoded_iter_base | 190 | // segments_encoded_iter_base | |||||
| 191 | // | 191 | // | |||||
| 192 | //------------------------------------------------ | 192 | //------------------------------------------------ | |||||
| 193 | 193 | |||||||
| 194 | inline | 194 | inline | |||||
| 195 | void | 195 | void | |||||
| HITCBC | 196 | 425 | segments_encoded_iter_base:: | 196 | 425 | segments_encoded_iter_base:: | ||
| 197 | measure_impl( | 197 | measure_impl( | |||||
| 198 | std::size_t& n, | 198 | std::size_t& n, | |||||
| 199 | core::string_view s, | 199 | core::string_view s, | |||||
| 200 | bool encode_colons) noexcept | 200 | bool encode_colons) noexcept | |||||
| 201 | { | 201 | { | |||||
| HITCBC | 202 | 425 | n += detail::re_encoded_size_unsafe( | 202 | 425 | n += detail::re_encoded_size_unsafe( | ||
| 203 | s, | 203 | s, | |||||
| 204 | encode_colons ? | 204 | encode_colons ? | |||||
| 205 | nocolon_pchars : | 205 | nocolon_pchars : | |||||
| 206 | pchars); | 206 | pchars); | |||||
| HITCBC | 207 | 425 | } | 207 | 425 | } | ||
| 208 | 208 | |||||||
| 209 | inline | 209 | inline | |||||
| 210 | void | 210 | void | |||||
| HITCBC | 211 | 423 | segments_encoded_iter_base:: | 211 | 423 | segments_encoded_iter_base:: | ||
| 212 | copy_impl( | 212 | copy_impl( | |||||
| 213 | char*& dest, | 213 | char*& dest, | |||||
| 214 | char const* end, | 214 | char const* end, | |||||
| 215 | core::string_view s, | 215 | core::string_view s, | |||||
| 216 | bool encode_colons) noexcept | 216 | bool encode_colons) noexcept | |||||
| 217 | { | 217 | { | |||||
| HITCBC | 218 | 423 | detail::re_encode_unsafe( | 218 | 423 | detail::re_encode_unsafe( | ||
| 219 | dest, | 219 | dest, | |||||
| 220 | end, | 220 | end, | |||||
| 221 | s, | 221 | s, | |||||
| 222 | encode_colons ? | 222 | encode_colons ? | |||||
| 223 | nocolon_pchars : | 223 | nocolon_pchars : | |||||
| 224 | pchars); | 224 | pchars); | |||||
| HITCBC | 225 | 423 | } | 225 | 423 | } | ||
| 226 | 226 | |||||||
| 227 | } // detail | 227 | } // detail | |||||
| 228 | } // urls | 228 | } // urls | |||||
| 229 | } // boost | 229 | } // boost | |||||
| 230 | 230 | |||||||
| 231 | #endif | 231 | #endif | |||||