100.00% Lines (7/7) 100.00% Functions (3/3)
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) 2022 Alan de Freitas (alandefreitas@gmail.com) 3   // Copyright (c) 2022 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_SEGMENTS_ITER_IMPL_HPP 11   #ifndef BOOST_URL_DETAIL_SEGMENTS_ITER_IMPL_HPP
12   #define BOOST_URL_DETAIL_SEGMENTS_ITER_IMPL_HPP 12   #define BOOST_URL_DETAIL_SEGMENTS_ITER_IMPL_HPP
13   13  
14   #include <boost/url/detail/parts_base.hpp> 14   #include <boost/url/detail/parts_base.hpp>
15   #include <boost/url/detail/url_impl.hpp> 15   #include <boost/url/detail/url_impl.hpp>
16   #include <boost/core/detail/string_view.hpp> 16   #include <boost/core/detail/string_view.hpp>
17   #include <string> 17   #include <string>
18   18  
19   namespace boost { 19   namespace boost {
20   namespace urls { 20   namespace urls {
21   namespace detail { 21   namespace detail {
22   22  
23   struct BOOST_SYMBOL_VISIBLE segments_iter_impl 23   struct BOOST_SYMBOL_VISIBLE segments_iter_impl
24   : private parts_base 24   : private parts_base
25   { 25   {
26   path_ref ref; // parent path data the iterator aliases 26   path_ref ref; // parent path data the iterator aliases
27   std::size_t pos = 0; // encoded offset of current segment start 27   std::size_t pos = 0; // encoded offset of current segment start
28   std::size_t next = 0; // encoded offset one past current segment 28   std::size_t next = 0; // encoded offset one past current segment
29   std::size_t index = 0; // segment index within the parent path 29   std::size_t index = 0; // segment index within the parent path
30   std::size_t dn = 0; // decoded length of current segment 30   std::size_t dn = 0; // decoded length of current segment
31   std::size_t decoded_prefix = 0; // decoded chars preceding current segment 31   std::size_t decoded_prefix = 0; // decoded chars preceding current segment
32   private: 32   private:
33   pct_string_view s_; 33   pct_string_view s_;
34   public: 34   public:
35   35  
36   segments_iter_impl() = default; 36   segments_iter_impl() = default;
37   segments_iter_impl( 37   segments_iter_impl(
38   segments_iter_impl const&) noexcept = default; 38   segments_iter_impl const&) noexcept = default;
39   segments_iter_impl& operator=( 39   segments_iter_impl& operator=(
40   segments_iter_impl const&) noexcept = default; 40   segments_iter_impl const&) noexcept = default;
41   41  
42   // begin 42   // begin
43   segments_iter_impl( 43   segments_iter_impl(
44   detail::path_ref const&) noexcept; 44   detail::path_ref const&) noexcept;
45   45  
46   // end 46   // end
47   segments_iter_impl( 47   segments_iter_impl(
48   detail::path_ref const&, 48   detail::path_ref const&,
49   int) noexcept; 49   int) noexcept;
50   50  
51   // at index 51   // at index
52   segments_iter_impl( 52   segments_iter_impl(
53   url_impl const& u_, 53   url_impl const& u_,
54   std::size_t pos_, 54   std::size_t pos_,
55   std::size_t i_) noexcept; 55   std::size_t i_) noexcept;
56   56  
57   void update() noexcept; 57   void update() noexcept;
58   58  
59   void 59   void
60   increment() noexcept; 60   increment() noexcept;
61   61  
62   void 62   void
63   decrement() noexcept; 63   decrement() noexcept;
64   64  
65   pct_string_view 65   pct_string_view
HITCBC 66   12408 dereference() const noexcept 66   12408 dereference() const noexcept
67   { 67   {
HITCBC 68   12408 return s_; 68   12408 return s_;
69   } 69   }
70   70  
71   std::size_t 71   std::size_t
HITCBC 72   24 decoded_prefix_size() const noexcept 72   24 decoded_prefix_size() const noexcept
73   { 73   {
HITCBC 74   24 return decoded_prefix; 74   24 return decoded_prefix;
75   } 75   }
76   76  
77   bool 77   bool
HITCBC 78   18703 equal( 78   18703 equal(
79   segments_iter_impl const& other) const noexcept 79   segments_iter_impl const& other) const noexcept
80   { 80   {
HITCBC 81   18703 BOOST_ASSERT(ref.alias_of(other.ref)); 81   18703 BOOST_ASSERT(ref.alias_of(other.ref));
HITCBC 82   18703 return index == other.index; 82   18703 return index == other.index;
83   } 83   }
84   }; 84   };
85   85  
86   } // detail 86   } // detail
87   } // urls 87   } // urls
88   } // boost 88   } // boost
89   89  
90   #include <boost/url/detail/impl/segments_iter_impl.hpp> 90   #include <boost/url/detail/impl/segments_iter_impl.hpp>
91   91  
92   #endif 92   #endif