include/boost/url/impl/segments_encoded_base.hpp
100.0% Lines (25/25)
100.0% Functions (9/9)
-% Branches (0/0)
include/boost/url/impl/segments_encoded_base.hpp
| Line | 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_ENCODED_BASE_HPP | |
| 12 | #define BOOST_URL_IMPL_SEGMENTS_ENCODED_BASE_HPP | |
| 13 | ||
| 14 | #include <boost/url/detail/segments_iter_impl.hpp> | |
| 15 | #include <boost/assert.hpp> | |
| 16 | ||
| 17 | namespace boost { | |
| 18 | namespace urls { | |
| 19 | namespace detail { | |
| 20 | struct segments_iter_access; | |
| 21 | } | |
| 22 | ||
| 23 | class segments_encoded_base::iterator | |
| 24 | { | |
| 25 | detail::segments_iter_impl it_; | |
| 26 | ||
| 27 | friend class url_base; | |
| 28 | friend class segments_encoded_base; | |
| 29 | friend class segments_encoded_ref; | |
| 30 | friend struct detail::segments_iter_access; | |
| 31 | ||
| 32 | iterator(detail::path_ref const&) noexcept; | |
| 33 | iterator(detail::path_ref const&, int) noexcept; | |
| 34 | ||
| 35 | 387 | iterator( |
| 36 | detail::segments_iter_impl const& it) noexcept | |
| 37 | 387 | : it_(it) |
| 38 | { | |
| 39 | 387 | } |
| 40 | ||
| 41 | public: | |
| 42 | using value_type = | |
| 43 | segments_encoded_base::value_type; | |
| 44 | using reference = | |
| 45 | segments_encoded_base::reference; | |
| 46 | using pointer = reference; | |
| 47 | using difference_type = std::ptrdiff_t; | |
| 48 | using iterator_category = | |
| 49 | std::bidirectional_iterator_tag; | |
| 50 | ||
| 51 | iterator() = default; | |
| 52 | iterator(iterator const&) = default; | |
| 53 | iterator& operator=( | |
| 54 | iterator const&) = default; | |
| 55 | ||
| 56 | reference | |
| 57 | 3924 | operator*() const noexcept |
| 58 | { | |
| 59 | 3924 | return it_.dereference(); |
| 60 | } | |
| 61 | ||
| 62 | pointer | |
| 63 | 21 | operator->() const noexcept |
| 64 | { | |
| 65 | 21 | return it_.dereference(); |
| 66 | } | |
| 67 | ||
| 68 | iterator& | |
| 69 | 2010 | operator++() noexcept |
| 70 | { | |
| 71 | 2010 | it_.increment(); |
| 72 | 2010 | return *this; |
| 73 | } | |
| 74 | ||
| 75 | iterator& | |
| 76 | 1512 | operator--() noexcept |
| 77 | { | |
| 78 | 1512 | it_.decrement(); |
| 79 | 1512 | return *this; |
| 80 | } | |
| 81 | ||
| 82 | iterator | |
| 83 | 600 | operator++(int) noexcept |
| 84 | { | |
| 85 | 600 | auto tmp = *this; |
| 86 | 600 | ++*this; |
| 87 | 600 | return tmp; |
| 88 | } | |
| 89 | ||
| 90 | iterator | |
| 91 | 21 | operator--(int) noexcept |
| 92 | { | |
| 93 | 21 | auto tmp = *this; |
| 94 | 21 | --*this; |
| 95 | 21 | return tmp; |
| 96 | } | |
| 97 | ||
| 98 | bool | |
| 99 | 707 | operator==( |
| 100 | iterator const& other) const noexcept | |
| 101 | { | |
| 102 | 707 | return it_.equal(other.it_); |
| 103 | } | |
| 104 | ||
| 105 | bool | |
| 106 | 3546 | operator!=( |
| 107 | iterator const& other) const noexcept | |
| 108 | { | |
| 109 | 3546 | return ! it_.equal(other.it_); |
| 110 | } | |
| 111 | }; | |
| 112 | ||
| 113 | } // urls | |
| 114 | } // boost | |
| 115 | ||
| 116 | #endif | |
| 117 |