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