97.38% Lines (223/229) 100.00% Functions (35/35)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2   // Copyright (c) 2022 Vinnie Falco (vinnie.falco@gmail.com) 2   // Copyright (c) 2022 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_URL_IMPL_HPP 11   #ifndef BOOST_URL_DETAIL_IMPL_URL_IMPL_HPP
12   #define BOOST_URL_DETAIL_IMPL_URL_IMPL_HPP 12   #define BOOST_URL_DETAIL_IMPL_URL_IMPL_HPP
13   13  
14   #include <boost/url/detail/config.hpp> 14   #include <boost/url/detail/config.hpp>
15   #include <boost/url/detail/memcpy.hpp> 15   #include <boost/url/detail/memcpy.hpp>
16   #include <boost/url/detail/path.hpp> 16   #include <boost/url/detail/path.hpp>
17   #include <boost/url/detail/url_impl.hpp> 17   #include <boost/url/detail/url_impl.hpp>
18   #include <boost/url/scheme.hpp> 18   #include <boost/url/scheme.hpp>
19   #include <boost/assert.hpp> 19   #include <boost/assert.hpp>
20   #include <cstring> 20   #include <cstring>
21   21  
22   namespace boost { 22   namespace boost {
23   namespace urls { 23   namespace urls {
24   namespace detail { 24   namespace detail {
25   25  
26   //------------------------------------------------ 26   //------------------------------------------------
27   // 27   //
28   // url_impl 28   // url_impl
29   // 29   //
30   //------------------------------------------------ 30   //------------------------------------------------
31   31  
32   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 32   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
33   void 33   void
HITCBC 34   7235 url_impl:: 34   7235 url_impl::
35   apply_scheme( 35   apply_scheme(
36   core::string_view s) noexcept 36   core::string_view s) noexcept
37   { 37   {
HITCBC 38   7235 scheme_ = string_to_scheme(s); 38   7235 scheme_ = string_to_scheme(s);
HITCBC 39   7235 set_size(id_scheme, s.size() + 1); 39   7235 set_size(id_scheme, s.size() + 1);
HITCBC 40   7235 } 40   7235 }
41   41  
42   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 42   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
43   void 43   void
HITCBC 44   423 url_impl:: 44   423 url_impl::
45   apply_userinfo( 45   apply_userinfo(
46   pct_string_view const& user, 46   pct_string_view const& user,
47   pct_string_view const* pass) noexcept 47   pct_string_view const* pass) noexcept
48   { 48   {
49   // this function is for 49   // this function is for
50   // authority_view_rule only 50   // authority_view_rule only
HITCBC 51   423 BOOST_ASSERT(from_ == from::authority); 51   423 BOOST_ASSERT(from_ == from::authority);
52   52  
53   // userinfo 53   // userinfo
HITCBC 54   423 set_size(id_user, user.size()); 54   423 set_size(id_user, user.size());
HITCBC 55   423 decoded_[id_user] = 55   423 decoded_[id_user] =
HITCBC 56   423 detail::to_size_type( 56   423 detail::to_size_type(
57   user.decoded_size()); 57   user.decoded_size());
HITCBC 58   423 if(pass) 58   423 if(pass)
59   { 59   {
HITCBC 60   286 set_size(id_pass, 60   286 set_size(id_pass,
HITCBC 61   286 pass->size() + 2); 61   286 pass->size() + 2);
HITCBC 62   286 decoded_[id_pass] = 62   286 decoded_[id_pass] =
HITCBC 63   286 detail::to_size_type( 63   286 detail::to_size_type(
64   pass->decoded_size()); 64   pass->decoded_size());
65   } 65   }
66   else 66   else
67   { 67   {
68   // trailing '@' 68   // trailing '@'
HITCBC 69   137 set_size(id_pass, 1 ); 69   137 set_size(id_pass, 1 );
70   } 70   }
HITCBC 71   423 } 71   423 }
72   72  
73   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 73   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
74   void 74   void
HITCBC 75   6613 url_impl:: 75   6613 url_impl::
76   apply_host( 76   apply_host(
77   host_type ht, 77   host_type ht,
78   pct_string_view s, 78   pct_string_view s,
79   unsigned char const* addr) noexcept 79   unsigned char const* addr) noexcept
80   { 80   {
81   // this function is for 81   // this function is for
82   // authority_view_rule only 82   // authority_view_rule only
HITCBC 83   6613 BOOST_ASSERT(from_ == from::authority); 83   6613 BOOST_ASSERT(from_ == from::authority);
84   84  
85   // host, port 85   // host, port
HITCBC 86   6613 host_type_ = ht; 86   6613 host_type_ = ht;
HITCBC 87   6613 set_size(id_host, s.size()); 87   6613 set_size(id_host, s.size());
HITCBC 88   6613 decoded_[id_host] = 88   6613 decoded_[id_host] =
HITCBC 89   6613 detail::to_size_type( 89   6613 detail::to_size_type(
90   s.decoded_size()); 90   s.decoded_size());
91   detail::memcpy( 91   detail::memcpy(
HITCBC 92   6613 ip_addr_, 92   6613 ip_addr_,
93   addr, 93   addr,
94   sizeof(ip_addr_)); 94   sizeof(ip_addr_));
HITCBC 95   6613 } 95   6613 }
96   96  
97   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 97   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
98   void 98   void
HITCBC 99   378 url_impl:: 99   378 url_impl::
100   apply_port( 100   apply_port(
101   core::string_view s, 101   core::string_view s,
102   unsigned short pn) noexcept 102   unsigned short pn) noexcept
103   { 103   {
104   // this function is for 104   // this function is for
105   // authority_view_rule only 105   // authority_view_rule only
HITCBC 106   378 BOOST_ASSERT(from_ == from::authority); 106   378 BOOST_ASSERT(from_ == from::authority);
107   107  
HITCBC 108   378 port_number_ = pn; 108   378 port_number_ = pn;
HITCBC 109   378 set_size(id_port, 1 + s.size()); 109   378 set_size(id_port, 1 + s.size());
HITCBC 110   378 } 110   378 }
111   111  
112   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 112   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
113   void 113   void
HITCBC 114   6541 url_impl:: 114   6541 url_impl::
115   apply_authority( 115   apply_authority(
116   url_impl const& a) noexcept 116   url_impl const& a) noexcept
117   { 117   {
HITCBC 118   6541 BOOST_ASSERT(from_ != from::authority); 118   6541 BOOST_ASSERT(from_ != from::authority);
119   119  
120   // userinfo 120   // userinfo
HITCBC 121   6541 set_size(id_user, 121   6541 set_size(id_user,
HITCBC 122   6541 a.len(id_user) + 122   6541 a.len(id_user) +
HITCBC 123   6541 (from_ == from::authority ? 0 : 2)); 123   6541 (from_ == from::authority ? 0 : 2));
HITCBC 124   6541 set_size(id_pass, a.len(id_pass)); 124   6541 set_size(id_pass, a.len(id_pass));
HITCBC 125   6541 decoded_[id_user] = a.decoded_[id_user]; 125   6541 decoded_[id_user] = a.decoded_[id_user];
HITCBC 126   6541 decoded_[id_pass] = a.decoded_[id_pass]; 126   6541 decoded_[id_pass] = a.decoded_[id_pass];
127   127  
128   // host, port 128   // host, port
HITCBC 129   6541 host_type_ = a.host_type_; 129   6541 host_type_ = a.host_type_;
HITCBC 130   6541 port_number_ = a.port_number_; 130   6541 port_number_ = a.port_number_;
HITCBC 131   6541 set_size(id_host, a.len(id_host)); 131   6541 set_size(id_host, a.len(id_host));
HITCBC 132   6541 set_size(id_port, a.len(id_port)); 132   6541 set_size(id_port, a.len(id_port));
133   detail::memcpy( 133   detail::memcpy(
HITCBC 134   6541 ip_addr_, 134   6541 ip_addr_,
HITCBC 135   6541 a.ip_addr_, 135   6541 a.ip_addr_,
136   sizeof(ip_addr_)); 136   sizeof(ip_addr_));
HITCBC 137   6541 decoded_[id_host] = a.decoded_[id_host]; 137   6541 decoded_[id_host] = a.decoded_[id_host];
HITCBC 138   6541 } 138   6541 }
139   139  
140   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 140   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
141   void 141   void
HITCBC 142   19839 url_impl:: 142   19843 url_impl::
143   apply_path( 143   apply_path(
144   pct_string_view s, 144   pct_string_view s,
145   std::size_t nseg) noexcept 145   std::size_t nseg) noexcept
146   { 146   {
HITCBC 147   19839 set_size(id_path, s.size()); 147   19843 set_size(id_path, s.size());
HITCBC 148   19839 decoded_[id_path] = 148   19843 decoded_[id_path] =
HITCBC 149   19839 detail::to_size_type( 149   19843 detail::to_size_type(
150   s.decoded_size()); 150   s.decoded_size());
HITCBC 151   19839 nseg_ = detail::to_size_type( 151   19843 nseg_ = detail::to_size_type(
152   detail::path_segments(s, nseg)); 152   detail::path_segments(s, nseg));
HITCBC 153   19839 } 153   19843 }
154   154  
155   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 155   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
156   void 156   void
HITCBC 157   4568 url_impl:: 157   4572 url_impl::
158   apply_query( 158   apply_query(
159   pct_string_view s, 159   pct_string_view s,
160   std::size_t n) noexcept 160   std::size_t n) noexcept
161   { 161   {
HITCBC 162   4568 nparam_ = detail::to_size_type(n); 162   4572 nparam_ = detail::to_size_type(n);
HITCBC 163   4568 set_size(id_query, 1 + s.size()); 163   4572 set_size(id_query, 1 + s.size());
HITCBC 164   4568 decoded_[id_query] = 164   4572 decoded_[id_query] =
HITCBC 165   4568 detail::to_size_type( 165   4572 detail::to_size_type(
166   s.decoded_size()); 166   s.decoded_size());
HITCBC 167   4568 } 167   4572 }
168   168  
169   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 169   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
170   void 170   void
HITCBC 171   1242 url_impl:: 171   1242 url_impl::
172   apply_frag( 172   apply_frag(
173   pct_string_view s) noexcept 173   pct_string_view s) noexcept
174   { 174   {
HITCBC 175   1242 set_size(id_frag, s.size() + 1); 175   1242 set_size(id_frag, s.size() + 1);
HITCBC 176   1242 decoded_[id_frag] = 176   1242 decoded_[id_frag] =
HITCBC 177   1242 detail::to_size_type( 177   1242 detail::to_size_type(
178   s.decoded_size()); 178   s.decoded_size());
HITCBC 179   1242 } 179   1242 }
180   180  
181   // return length of [first, last) 181   // return length of [first, last)
182   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 182   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
183   std::size_t 183   std::size_t
HITCBC 184   52168 url_impl:: 184   52188 url_impl::
185   len( 185   len(
186   int first, 186   int first,
187   int last) const noexcept 187   int last) const noexcept
188   { 188   {
HITCBC 189   52168 BOOST_ASSERT(first <= last); 189   52188 BOOST_ASSERT(first <= last);
HITCBC 190   52168 BOOST_ASSERT(last <= id_end); 190   52188 BOOST_ASSERT(last <= id_end);
HITCBC 191   52168 return offset(last) - offset(first); 191   52188 return offset(last) - offset(first);
192   } 192   }
193   193  
194   // return length of part 194   // return length of part
195   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 195   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
196   std::size_t 196   std::size_t
HITCBC 197   790604 url_impl:: 197   791466 url_impl::
198   len(int id) const noexcept 198   len(int id) const noexcept
199   { 199   {
200   return id == id_end 200   return id == id_end
HITCBC 201   1581208 ? zero_ 201   1582932 ? zero_
HITCBC 202   790604 : ( offset(id + 1) - 202   791466 : ( offset(id + 1) -
HITCBC 203   1581208 offset(id) ); 203   1582932 offset(id) );
204   } 204   }
205   205  
206   // return offset of id 206   // return offset of id
207   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 207   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
208   std::size_t 208   std::size_t
HITCBC 209   2095046 url_impl:: 209   2098424 url_impl::
210   offset(int id) const noexcept 210   offset(int id) const noexcept
211   { 211   {
212   return 212   return
213   id == id_scheme 213   id == id_scheme
HITCBC 214   2095046 ? zero_ 214   2098424 ? zero_
HITCBC 215   2095046 : offset_[id]; 215   2098424 : offset_[id];
216   } 216   }
217   217  
218   // return id as string 218   // return id as string
219   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 219   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
220   core::string_view 220   core::string_view
HITCBC 221   157073 url_impl:: 221   157386 url_impl::
222   get(int id) const noexcept 222   get(int id) const noexcept
223   { 223   {
224   return { 224   return {
HITCBC 225   157073 cs_ + offset(id), len(id) }; 225   157386 cs_ + offset(id), len(id) };
226   } 226   }
227   227  
228   // return [first, last) as string 228   // return [first, last) as string
229   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 229   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
230   core::string_view 230   core::string_view
HITCBC 231   1186 url_impl:: 231   1586 url_impl::
232   get(int first, 232   get(int first,
233   int last) const noexcept 233   int last) const noexcept
234   { 234   {
HITCBC 235   1186 return { cs_ + offset(first), 235   1586 return { cs_ + offset(first),
HITCBC 236   1186 offset(last) - offset(first) }; 236   1586 offset(last) - offset(first) };
237   } 237   }
238   238  
239   // return id as pct-string 239   // return id as pct-string
240   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 240   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
241   pct_string_view 241   pct_string_view
HITCBC 242   3406 url_impl:: 242   3406 url_impl::
243   pct_get( 243   pct_get(
244   int id) const noexcept 244   int id) const noexcept
245   { 245   {
HITCBC 246   3406 return make_pct_string_view_unsafe( 246   3406 return make_pct_string_view_unsafe(
HITCBC 247   3406 cs_ + offset(id), 247   3406 cs_ + offset(id),
248   len(id), 248   len(id),
HITCBC 249   6812 decoded_[id]); 249   6812 decoded_[id]);
250   } 250   }
251   251  
252   // return [first, last) as pct-string 252   // return [first, last) as pct-string
253   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 253   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
254   pct_string_view 254   pct_string_view
HITCBC 255   130 url_impl:: 255   130 url_impl::
256   pct_get( 256   pct_get(
257   int first, 257   int first,
258   int last) const noexcept 258   int last) const noexcept
259   { 259   {
HITCBC 260   130 auto const pos = offset(first); 260   130 auto const pos = offset(first);
HITCBC 261   130 std::size_t n = 0; 261   130 std::size_t n = 0;
HITCBC 262   420 for(auto i = first; i < last;) 262   420 for(auto i = first; i < last;)
HITCBC 263   290 n += decoded_[i++]; 263   290 n += decoded_[i++];
HITCBC 264   130 return make_pct_string_view_unsafe( 264   130 return make_pct_string_view_unsafe(
HITCBC 265   130 cs_ + pos, 265   130 cs_ + pos,
HITCBC 266   130 offset(last) - pos, 266   130 offset(last) - pos,
HITCBC 267   130 n); 267   130 n);
268   } 268   }
269   269  
270   //------------------------------------------------ 270   //------------------------------------------------
271   271  
272   // change id to size n 272   // change id to size n
273   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 273   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
274   void 274   void
HITCBC 275   73269 url_impl:: 275   73283 url_impl::
276   set_size( 276   set_size(
277   int id, 277   int id,
278   std::size_t n) noexcept 278   std::size_t n) noexcept
279   { 279   {
HITCBC 280   73269 auto const cur = len(id); 280   73283 auto const cur = len(id);
HITCBC 281   73269 if(n >= cur) 281   73283 if(n >= cur)
282   { 282   {
HITCBC 283   71881 auto const d = n - cur; 283   71893 auto const d = n - cur;
HITCBC 284   71881 for(auto i = id + 1; 284   71893 for(auto i = id + 1;
HITCBC 285   402852 i <= id_end; ++i) 285   402892 i <= id_end; ++i)
HITCBC 286   330971 offset_[i] += detail::to_size_type(d); 286   330999 offset_[i] += detail::to_size_type(d);
HITCBC 287   71881 return; 287   71893 return;
288   } 288   }
HITCBC 289   1388 auto const d = cur - n; 289   1390 auto const d = cur - n;
HITCBC 290   1388 for(auto i = id + 1; 290   1390 for(auto i = id + 1;
HITCBC 291   5580 i <= id_end; ++i) 291   5586 i <= id_end; ++i)
HITCBC 292   4192 offset_[i] -= detail::to_size_type(d); 292   4196 offset_[i] -= detail::to_size_type(d);
293   } 293   }
294   294  
295   // trim id to size n, 295   // trim id to size n,
296   // moving excess into id+1 296   // moving excess into id+1
297   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 297   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
298   void 298   void
HITCBC 299   1914 url_impl:: 299   1914 url_impl::
300   split( 300   split(
301   int id, 301   int id,
302   std::size_t n) noexcept 302   std::size_t n) noexcept
303   { 303   {
HITCBC 304   1914 BOOST_ASSERT(id < id_end - 1); 304   1914 BOOST_ASSERT(id < id_end - 1);
305   //BOOST_ASSERT(n <= len(id)); 305   //BOOST_ASSERT(n <= len(id));
HITCBC 306   1914 offset_[id + 1] = detail::to_size_type( 306   1914 offset_[id + 1] = detail::to_size_type(
HITCBC 307   1914 offset(id) + n); 307   1914 offset(id) + n);
HITCBC 308   1914 } 308   1914 }
309   309  
310   // add n to [first, last] 310   // add n to [first, last]
311   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 311   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
312   void 312   void
HITCBC 313   2944 url_impl:: 313   2944 url_impl::
314   adjust_right( 314   adjust_right(
315   int first, 315   int first,
316   int last, 316   int last,
317   std::size_t n) noexcept 317   std::size_t n) noexcept
318   { 318   {
HITCBC 319   2944 for(int i = first; 319   2944 for(int i = first;
HITCBC 320   17615 i <= last; ++i) 320   17615 i <= last; ++i)
HITCBC 321   14671 offset_[i] += detail::to_size_type(n); 321   14671 offset_[i] += detail::to_size_type(n);
HITCBC 322   2944 } 322   2944 }
323   323  
324   // remove n from [first, last] 324   // remove n from [first, last]
325   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 325   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
326   void 326   void
HITCBC 327   2408 url_impl:: 327   2408 url_impl::
328   adjust_left( 328   adjust_left(
329   int first, 329   int first,
330   int last, 330   int last,
331   std::size_t n) noexcept 331   std::size_t n) noexcept
332   { 332   {
HITCBC 333   2408 for(int i = first; 333   2408 for(int i = first;
HITCBC 334   12133 i <= last; ++i) 334   12133 i <= last; ++i)
HITCBC 335   9725 offset_[i] -= detail::to_size_type(n); 335   9725 offset_[i] -= detail::to_size_type(n);
HITCBC 336   2408 } 336   2408 }
337   337  
338   // set [first, last) offset 338   // set [first, last) offset
339   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE 339   BOOST_URL_CXX20_CONSTEXPR_OR_INLINE
340   void 340   void
HITCBC 341   5333 url_impl:: 341   5333 url_impl::
342   collapse( 342   collapse(
343   int first, 343   int first,
344   int last, 344   int last,
345   std::size_t n) noexcept 345   std::size_t n) noexcept
346   { 346   {
HITCBC 347   5333 for(int i = first + 1; 347   5333 for(int i = first + 1;
HITCBC 348   6674 i < last; ++i) 348   6674 i < last; ++i)
HITCBC 349   1341 offset_[i] = detail::to_size_type(n); 349   1341 offset_[i] = detail::to_size_type(n);
HITCBC 350   5333 } 350   5333 }
351   351  
352   352  
353   //------------------------------------------------ 353   //------------------------------------------------
354   // 354   //
355   // path_ref 355   // path_ref
356   // 356   //
357   //------------------------------------------------ 357   //------------------------------------------------
358   358  
359   inline 359   inline
HITCBC 360   10630 path_ref:: 360   10630 path_ref::
361   path_ref( 361   path_ref(
HITCBC 362   10630 url_impl const& impl) noexcept 362   10630 url_impl const& impl) noexcept
363   { 363   {
HITCBC 364   10630 if(impl.from_ == url_impl::from::url) 364   10630 if(impl.from_ == url_impl::from::url)
365   { 365   {
HITCBC 366   10054 impl_ = &impl; 366   10054 impl_ = &impl;
367   } 367   }
368   else 368   else
369   { 369   {
HITCBC 370   576 core::string_view s = impl.get(id_path); 370   576 core::string_view s = impl.get(id_path);
HITCBC 371   576 data_ = s.data(); 371   576 data_ = s.data();
HITCBC 372   576 size_ = s.size(); 372   576 size_ = s.size();
HITCBC 373   576 nseg_ = impl.nseg_; 373   576 nseg_ = impl.nseg_;
HITCBC 374   576 dn_ = impl.decoded_[id_path]; 374   576 dn_ = impl.decoded_[id_path];
375   } 375   }
HITCBC 376   10630 } 376   10630 }
377   377  
378   inline 378   inline
HITCBC 379   242 path_ref:: 379   242 path_ref::
380   path_ref( 380   path_ref(
381   core::string_view s, 381   core::string_view s,
382   std::size_t dn, 382   std::size_t dn,
HITCBC 383   242 std::size_t nseg) noexcept 383   242 std::size_t nseg) noexcept
HITCBC 384   484 : data_(s.data()) 384   484 : data_(s.data())
HITCBC 385   242 , size_(s.size()) 385   242 , size_(s.size())
HITCBC 386   242 , nseg_(nseg) 386   242 , nseg_(nseg)
HITCBC 387   242 , dn_(dn) 387   242 , dn_(dn)
388   { 388   {
HITCBC 389   242 } 389   242 }
390   390  
391   inline 391   inline
392   pct_string_view 392   pct_string_view
HITCBC 393   12827 path_ref:: 393   12827 path_ref::
394   buffer() const noexcept 394   buffer() const noexcept
395   { 395   {
HITCBC 396   12827 if(impl_) 396   12827 if(impl_)
HITCBC 397   10336 return make_pct_string_view_unsafe( 397   10336 return make_pct_string_view_unsafe(
HITCBC 398   10336 impl_->cs_ + 398   10336 impl_->cs_ +
HITCBC 399   10336 impl_->offset(id_path), 399   10336 impl_->offset(id_path),
HITCBC 400   10336 impl_->len(id_path), 400   10336 impl_->len(id_path),
HITCBC 401   20672 impl_->decoded_[id_path]); 401   20672 impl_->decoded_[id_path]);
HITCBC 402   2491 return make_pct_string_view_unsafe( 402   2491 return make_pct_string_view_unsafe(
HITCBC 403   2491 data_, size_, dn_); 403   2491 data_, size_, dn_);
404   } 404   }
405   405  
406   inline 406   inline
407   std::size_t 407   std::size_t
HITCBC 408   35941 path_ref:: 408   35941 path_ref::
409   size() const noexcept 409   size() const noexcept
410   { 410   {
HITCBC 411   35941 if(impl_) 411   35941 if(impl_)
HITCBC 412   34354 return impl_->len(id_path); 412   34354 return impl_->len(id_path);
HITCBC 413   1587 return size_; 413   1587 return size_;
414   } 414   }
415   415  
416   inline 416   inline
417   char const* 417   char const*
HITCBC 418   51008 path_ref:: 418   51008 path_ref::
419   data() const noexcept 419   data() const noexcept
420   { 420   {
HITCBC 421   51008 if(impl_) 421   51008 if(impl_)
HITCBC 422   42130 return impl_->cs_ + 422   42130 return impl_->cs_ +
HITCBC 423   42130 impl_->offset(id_path); 423   42130 impl_->offset(id_path);
HITCBC 424   8878 return data_; 424   8878 return data_;
425   } 425   }
426   426  
427   inline 427   inline
428   char const* 428   char const*
HITCBC 429   18787 path_ref:: 429   18787 path_ref::
430   end() const noexcept 430   end() const noexcept
431   { 431   {
HITCBC 432   18787 if(impl_) 432   18787 if(impl_)
HITCBC 433   16050 return impl_->cs_ + 433   16050 return impl_->cs_ +
HITCBC 434   16050 impl_->offset(id_query); 434   16050 impl_->offset(id_query);
HITCBC 435   2737 return data_ + size_; 435   2737 return data_ + size_;
436   } 436   }
437   437  
438   inline 438   inline
439   std::size_t 439   std::size_t
HITCBC 440   44272 path_ref:: 440   44272 path_ref::
441   nseg() const noexcept 441   nseg() const noexcept
442   { 442   {
HITCBC 443   44272 if(impl_) 443   44272 if(impl_)
HITCBC 444   40398 return impl_->nseg_; 444   40398 return impl_->nseg_;
HITCBC 445   3874 return nseg_; 445   3874 return nseg_;
446   } 446   }
447   447  
448   inline 448   inline
449   std::size_t 449   std::size_t
HITCBC 450   17377 path_ref:: 450   17377 path_ref::
451   decoded_size() const noexcept 451   decoded_size() const noexcept
452   { 452   {
HITCBC 453   17377 if(impl_) 453   17377 if(impl_)
HITCBC 454   16588 return impl_->decoded_[id_path]; 454   16588 return impl_->decoded_[id_path];
HITCBC 455   789 return dn_; 455   789 return dn_;
456   } 456   }
457   457  
458   //------------------------------------------------ 458   //------------------------------------------------
459   // 459   //
460   // query_ref 460   // query_ref
461   // 461   //
462   //------------------------------------------------ 462   //------------------------------------------------
463   463  
464   inline 464   inline
HITCBC 465   3333 query_ref:: 465   3333 query_ref::
466   query_ref( 466   query_ref(
467   core::string_view s, 467   core::string_view s,
468   std::size_t dn, 468   std::size_t dn,
HITCBC 469   3333 std::size_t nparam) noexcept 469   3333 std::size_t nparam) noexcept
HITCBC 470   6666 : data_(s.data()) 470   6666 : data_(s.data())
HITCBC 471   3333 , size_(s.size()) 471   3333 , size_(s.size())
HITCBC 472   3333 , nparam_(nparam) 472   3333 , nparam_(nparam)
HITCBC 473   3333 , dn_(dn) 473   3333 , dn_(dn)
474   { 474   {
HITCBC 475   3333 } 475   3333 }
476   476  
477   inline 477   inline
HITCBC 478   8962 query_ref:: 478   8977 query_ref::
479   query_ref( 479   query_ref(
HITCBC 480   8962 url_impl const& impl) noexcept 480   8977 url_impl const& impl) noexcept
481   { 481   {
HITCBC 482   8962 if(impl.from_ == url_impl::from::url) 482   8977 if(impl.from_ == url_impl::from::url)
483   { 483   {
HITCBC 484   8831 impl_ = &impl; 484   8846 impl_ = &impl;
485   } 485   }
486   else 486   else
487   { 487   {
HITCBC 488   131 core::string_view s = impl.get(id_query); 488   131 core::string_view s = impl.get(id_query);
HITCBC 489   131 if (!s.empty()) 489   131 if (!s.empty())
490   { 490   {
HITCBC 491   125 s.remove_prefix(1); 491   125 s.remove_prefix(1);
HITCBC 492   125 question_mark_ = true; 492   125 question_mark_ = true;
493   } 493   }
HITCBC 494   131 data_ = s.data(); 494   131 data_ = s.data();
HITCBC 495   131 size_ = s.size(); 495   131 size_ = s.size();
HITCBC 496   131 nparam_ = impl.nparam_; 496   131 nparam_ = impl.nparam_;
HITCBC 497   131 dn_ = impl.decoded_[id_query]; 497   131 dn_ = impl.decoded_[id_query];
498   } 498   }
HITCBC 499   8962 } 499   8977 }
500   500  
501   inline 501   inline
502   pct_string_view 502   pct_string_view
HITCBC 503   24 query_ref:: 503   24 query_ref::
504   buffer() const noexcept 504   buffer() const noexcept
505   { 505   {
HITCBC 506   24 if(impl_) 506   24 if(impl_)
507   { 507   {
HITCBC 508   2 auto pos = impl_->offset_[id_query]; 508   2 auto pos = impl_->offset_[id_query];
HITCBC 509   2 auto pos1 = impl_->offset_[id_frag]; 509   2 auto pos1 = impl_->offset_[id_frag];
HITCBC 510   2 if(pos < pos1) 510   2 if(pos < pos1)
511   { 511   {
MISUBC 512   ++pos; // no '?' 512   ++pos; // no '?'
MISUBC 513   return make_pct_string_view_unsafe( 513   return make_pct_string_view_unsafe(
MISUBC 514   impl_->cs_ + pos, 514   impl_->cs_ + pos,
MISUBC 515   pos1 - pos, 515   pos1 - pos,
MISUBC 516   impl_->decoded_[id_query]); 516   impl_->decoded_[id_query]);
517   } 517   }
518   // empty 518   // empty
HITCBC 519   2 return make_pct_string_view_unsafe( 519   2 return make_pct_string_view_unsafe(
HITCBC 520   2 impl_->cs_ + pos, 520   2 impl_->cs_ + pos,
521   0, 521   0,
HITCBC 522   2 0); 522   2 0);
523   } 523   }
524   // no '?' 524   // no '?'
HITCBC 525   22 return make_pct_string_view_unsafe( 525   22 return make_pct_string_view_unsafe(
HITCBC 526   22 data_, size_, dn_); 526   22 data_, size_, dn_);
527   } 527   }
528   528  
529   // with '?' 529   // with '?'
530   inline 530   inline
531   std::size_t 531   std::size_t
HITCBC 532   32286 query_ref:: 532   32311 query_ref::
533   size() const noexcept 533   size() const noexcept
534   { 534   {
HITCBC 535   32286 if(impl_) 535   32311 if(impl_)
HITCBC 536   28517 return impl_->len(id_query); 536   28542 return impl_->len(id_query);
HITCBC 537   3769 if(size_ > 0) 537   3769 if(size_ > 0)
HITCBC 538   3727 return size_ + 1; 538   3727 return size_ + 1;
HITCBC 539   42 return question_mark_; 539   42 return question_mark_;
540   } 540   }
541   541  
542   // no '?' 542   // no '?'
543   inline 543   inline
544   char const* 544   char const*
HITCBC 545   19117 query_ref:: 545   19129 query_ref::
546   begin() const noexcept 546   begin() const noexcept
547   { 547   {
HITCBC 548   19117 if(impl_) 548   19129 if(impl_)
549   { 549   {
550   // using the offset array here 550   // using the offset array here
HITCBC 551   15173 auto pos = impl_->offset_[id_query]; 551   15185 auto pos = impl_->offset_[id_query];
HITCBC 552   15173 auto pos1 = impl_->offset_[id_frag]; 552   15185 auto pos1 = impl_->offset_[id_frag];
HITCBC 553   15173 if(pos < pos1) 553   15185 if(pos < pos1)
HITCBC 554   15173 return impl_->cs_ + pos + 1; // no '?' 554   15185 return impl_->cs_ + pos + 1; // no '?'
555   // empty 555   // empty
MISUBC 556   return impl_->cs_ + pos; 556   return impl_->cs_ + pos;
557   } 557   }
HITCBC 558   3944 return data_; 558   3944 return data_;
559   559  
560   } 560   }
561   561  
562   inline 562   inline
563   char const* 563   char const*
HITCBC 564   10123 query_ref:: 564   10134 query_ref::
565   end() const noexcept 565   end() const noexcept
566   { 566   {
HITCBC 567   10123 if(impl_) 567   10134 if(impl_)
HITCBC 568   8590 return impl_->cs_ + 568   8601 return impl_->cs_ +
HITCBC 569   8590 impl_->offset(id_frag); 569   8601 impl_->offset(id_frag);
HITCBC 570   1533 return data_ + size_; 570   1533 return data_ + size_;
571   } 571   }
572   572  
573   inline 573   inline
574   std::size_t 574   std::size_t
HITCBC 575   48601 query_ref:: 575   48628 query_ref::
576   nparam() const noexcept 576   nparam() const noexcept
577   { 577   {
HITCBC 578   48601 if(impl_) 578   48628 if(impl_)
HITCBC 579   42461 return impl_->nparam_; 579   42488 return impl_->nparam_;
HITCBC 580   6140 return nparam_; 580   6140 return nparam_;
581   } 581   }
582   582  
583   } // detail 583   } // detail
584   } // urls 584   } // urls
585   } // boost 585   } // boost
586   586  
587   #endif 587   #endif