include/boost/url/impl/segments_base.hpp
100.0% Lines (25/25)
100.0% Functions (8/8)
100.0% Branches (1/1)
include/boost/url/impl/segments_base.hpp
| Line | Branch | Hits | Source Code |
|---|---|---|---|
| 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_IMPL_SEGMENTS_BASE_HPP | ||
| 12 | #define BOOST_URL_IMPL_SEGMENTS_BASE_HPP | ||
| 13 | |||
| 14 | #include <boost/url/detail/segments_iter_impl.hpp> | ||
| 15 | #include <boost/url/encoding_opts.hpp> | ||
| 16 | #include <boost/assert.hpp> | ||
| 17 | #include <iterator> | ||
| 18 | |||
| 19 | namespace boost { | ||
| 20 | namespace urls { | ||
| 21 | namespace detail { | ||
| 22 | struct segments_iter_access; | ||
| 23 | } | ||
| 24 | |||
| 25 | class segments_base::iterator | ||
| 26 | { | ||
| 27 | detail::segments_iter_impl it_; | ||
| 28 | |||
| 29 | friend class segments_base; | ||
| 30 | friend class segments_ref; | ||
| 31 | friend struct detail::segments_iter_access; | ||
| 32 | |||
| 33 | iterator(detail::path_ref const&) noexcept; | ||
| 34 | iterator(detail::path_ref const&, int) noexcept; | ||
| 35 | |||
| 36 | 157 | iterator( | |
| 37 | detail::segments_iter_impl const& it) noexcept | ||
| 38 | 157 | : it_(it) | |
| 39 | { | ||
| 40 | 157 | } | |
| 41 | |||
| 42 | public: | ||
| 43 | using value_type = segments_base::value_type; | ||
| 44 | using reference = segments_base::reference; | ||
| 45 | using pointer = reference; | ||
| 46 | using difference_type = | ||
| 47 | segments_base::difference_type; | ||
| 48 | using iterator_category = | ||
| 49 | std::bidirectional_iterator_tag; | ||
| 50 | |||
| 51 | iterator() = default; | ||
| 52 | iterator(iterator const&) = default; | ||
| 53 | iterator& operator=( | ||
| 54 | iterator const&) noexcept = default; | ||
| 55 | |||
| 56 | reference | ||
| 57 | 876 | operator*() const | |
| 58 | { | ||
| 59 | 876 | encoding_opts opt; | |
| 60 | 876 | opt.space_as_plus = false; | |
| 61 |
1/1✓ Branch 3 taken 876 times.
|
876 | return it_.dereference().decode(opt); |
| 62 | } | ||
| 63 | |||
| 64 | // the return value is too expensive | ||
| 65 | pointer operator->() const = delete; | ||
| 66 | |||
| 67 | iterator& | ||
| 68 | 852 | operator++() noexcept | |
| 69 | { | ||
| 70 | 852 | it_.increment(); | |
| 71 | 852 | return *this; | |
| 72 | } | ||
| 73 | |||
| 74 | iterator& | ||
| 75 | 72 | operator--() noexcept | |
| 76 | { | ||
| 77 | 72 | it_.decrement(); | |
| 78 | 72 | return *this; | |
| 79 | } | ||
| 80 | |||
| 81 | iterator | ||
| 82 | 48 | operator++(int) noexcept | |
| 83 | { | ||
| 84 | 48 | auto tmp = *this; | |
| 85 | 48 | ++*this; | |
| 86 | 48 | return tmp; | |
| 87 | } | ||
| 88 | |||
| 89 | iterator | ||
| 90 | 21 | operator--(int) noexcept | |
| 91 | { | ||
| 92 | 21 | auto tmp = *this; | |
| 93 | 21 | --*this; | |
| 94 | 21 | return tmp; | |
| 95 | } | ||
| 96 | |||
| 97 | bool | ||
| 98 | 66 | operator==( | |
| 99 | iterator const& other) const noexcept | ||
| 100 | { | ||
| 101 | 66 | return it_.equal(other.it_); | |
| 102 | } | ||
| 103 | |||
| 104 | bool | ||
| 105 | 932 | operator!=( | |
| 106 | iterator const& other) const noexcept | ||
| 107 | { | ||
| 108 | 932 | return ! it_.equal(other.it_); | |
| 109 | } | ||
| 110 | }; | ||
| 111 | |||
| 112 | } // urls | ||
| 113 | } // boost | ||
| 114 | |||
| 115 | #endif | ||
| 116 |