include/boost/url/impl/segments_encoded_base.hpp
100.0% Lines (58/58)
100.0% List of functions (21/21)
Functions (21)
Function
Calls
Lines
Blocks
boost::urls::segments_encoded_base::iterator::iterator(boost::urls::detail::segments_iter_impl const&)
:36
435x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::operator*() const
:58
4226x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::operator->() const
:64
21x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::operator++()
:70
2150x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::operator--()
:77
1707x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::operator++(int)
:84
652x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::operator--(int)
:92
21x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::operator==(boost::urls::segments_encoded_base::iterator const&) const
:100
791x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::operator!=(boost::urls::segments_encoded_base::iterator const&) const
:107
3942x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::iterator(boost::urls::detail::path_ref const&)
:117
2164x
100.0%
100.0%
boost::urls::segments_encoded_base::iterator::iterator(boost::urls::detail::path_ref const&, int)
:126
1800x
100.0%
100.0%
boost::urls::segments_encoded_base::segments_encoded_base(boost::urls::detail::path_ref const&)
:142
1608x
100.0%
100.0%
boost::urls::segments_encoded_base::buffer() const
:157
58x
100.0%
100.0%
boost::urls::segments_encoded_base::is_absolute() const
:165
508x
100.0%
100.0%
boost::urls::segments_encoded_base::empty() const
:173
719x
100.0%
100.0%
boost::urls::segments_encoded_base::size() const
:181
458x
100.0%
100.0%
boost::urls::segments_encoded_base::front() const
:189
102x
100.0%
86.0%
boost::urls::segments_encoded_base::back() const
:198
16x
100.0%
88.0%
boost::urls::segments_encoded_base::begin() const
:207
2164x
100.0%
100.0%
boost::urls::segments_encoded_base::end() const
:216
1800x
100.0%
100.0%
boost::urls::operator<<(std::ostream&, boost::urls::segments_encoded_base const&)
:227
15x
100.0%
100.0%
| Line | TLA | 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 | #include <ostream> | ||
| 17 | |||
| 18 | namespace boost { | ||
| 19 | namespace urls { | ||
| 20 | namespace detail { | ||
| 21 | struct segments_iter_access; | ||
| 22 | } | ||
| 23 | |||
| 24 | class segments_encoded_base::iterator | ||
| 25 | { | ||
| 26 | detail::segments_iter_impl it_; | ||
| 27 | |||
| 28 | friend class url_base; | ||
| 29 | friend class segments_encoded_base; | ||
| 30 | friend class segments_encoded_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 | 435x | iterator( | |
| 37 | detail::segments_iter_impl const& it) noexcept | ||
| 38 | 435x | : it_(it) | |
| 39 | { | ||
| 40 | 435x | } | |
| 41 | |||
| 42 | public: | ||
| 43 | using value_type = | ||
| 44 | segments_encoded_base::value_type; | ||
| 45 | using reference = | ||
| 46 | segments_encoded_base::reference; | ||
| 47 | using pointer = reference; | ||
| 48 | using difference_type = std::ptrdiff_t; | ||
| 49 | using iterator_category = | ||
| 50 | std::bidirectional_iterator_tag; | ||
| 51 | |||
| 52 | iterator() = default; | ||
| 53 | iterator(iterator const&) = default; | ||
| 54 | iterator& operator=( | ||
| 55 | iterator const&) = default; | ||
| 56 | |||
| 57 | reference | ||
| 58 | 4226x | operator*() const noexcept | |
| 59 | { | ||
| 60 | 4226x | return it_.dereference(); | |
| 61 | } | ||
| 62 | |||
| 63 | pointer | ||
| 64 | 21x | operator->() const noexcept | |
| 65 | { | ||
| 66 | 21x | return it_.dereference(); | |
| 67 | } | ||
| 68 | |||
| 69 | iterator& | ||
| 70 | 2150x | operator++() noexcept | |
| 71 | { | ||
| 72 | 2150x | it_.increment(); | |
| 73 | 2150x | return *this; | |
| 74 | } | ||
| 75 | |||
| 76 | iterator& | ||
| 77 | 1707x | operator--() noexcept | |
| 78 | { | ||
| 79 | 1707x | it_.decrement(); | |
| 80 | 1707x | return *this; | |
| 81 | } | ||
| 82 | |||
| 83 | iterator | ||
| 84 | 652x | operator++(int) noexcept | |
| 85 | { | ||
| 86 | 652x | auto tmp = *this; | |
| 87 | 652x | ++*this; | |
| 88 | 652x | return tmp; | |
| 89 | } | ||
| 90 | |||
| 91 | iterator | ||
| 92 | 21x | operator--(int) noexcept | |
| 93 | { | ||
| 94 | 21x | auto tmp = *this; | |
| 95 | 21x | --*this; | |
| 96 | 21x | return tmp; | |
| 97 | } | ||
| 98 | |||
| 99 | bool | ||
| 100 | 791x | operator==( | |
| 101 | iterator const& other) const noexcept | ||
| 102 | { | ||
| 103 | 791x | return it_.equal(other.it_); | |
| 104 | } | ||
| 105 | |||
| 106 | bool | ||
| 107 | 3942x | operator!=( | |
| 108 | iterator const& other) const noexcept | ||
| 109 | { | ||
| 110 | 3942x | return ! it_.equal(other.it_); | |
| 111 | } | ||
| 112 | }; | ||
| 113 | |||
| 114 | //------------------------------------------------ | ||
| 115 | |||
| 116 | inline | ||
| 117 | 2164x | segments_encoded_base:: | |
| 118 | iterator:: | ||
| 119 | iterator( | ||
| 120 | 2164x | detail::path_ref const& ref) noexcept | |
| 121 | 2164x | : it_(ref) | |
| 122 | { | ||
| 123 | 2164x | } | |
| 124 | |||
| 125 | inline | ||
| 126 | 1800x | segments_encoded_base:: | |
| 127 | iterator:: | ||
| 128 | iterator( | ||
| 129 | detail::path_ref const& ref, | ||
| 130 | 1800x | int) noexcept | |
| 131 | 1800x | : it_(ref, 0) | |
| 132 | { | ||
| 133 | 1800x | } | |
| 134 | |||
| 135 | //------------------------------------------------ | ||
| 136 | // | ||
| 137 | // segments_encoded_base | ||
| 138 | // | ||
| 139 | //------------------------------------------------ | ||
| 140 | |||
| 141 | inline | ||
| 142 | 1608x | segments_encoded_base:: | |
| 143 | segments_encoded_base( | ||
| 144 | 1608x | detail::path_ref const& ref) noexcept | |
| 145 | 1608x | : ref_(ref) | |
| 146 | { | ||
| 147 | 1608x | } | |
| 148 | |||
| 149 | //------------------------------------------------ | ||
| 150 | // | ||
| 151 | // Observers | ||
| 152 | // | ||
| 153 | //------------------------------------------------ | ||
| 154 | |||
| 155 | inline | ||
| 156 | pct_string_view | ||
| 157 | 58x | segments_encoded_base:: | |
| 158 | buffer() const noexcept | ||
| 159 | { | ||
| 160 | 58x | return ref_.buffer(); | |
| 161 | } | ||
| 162 | |||
| 163 | inline | ||
| 164 | bool | ||
| 165 | 508x | segments_encoded_base:: | |
| 166 | is_absolute() const noexcept | ||
| 167 | { | ||
| 168 | 508x | return ref_.buffer().starts_with('/'); | |
| 169 | } | ||
| 170 | |||
| 171 | inline | ||
| 172 | bool | ||
| 173 | 719x | segments_encoded_base:: | |
| 174 | empty() const noexcept | ||
| 175 | { | ||
| 176 | 719x | return ref_.nseg() == 0; | |
| 177 | } | ||
| 178 | |||
| 179 | inline | ||
| 180 | std::size_t | ||
| 181 | 458x | segments_encoded_base:: | |
| 182 | size() const noexcept | ||
| 183 | { | ||
| 184 | 458x | return ref_.nseg(); | |
| 185 | } | ||
| 186 | |||
| 187 | inline | ||
| 188 | pct_string_view | ||
| 189 | 102x | segments_encoded_base:: | |
| 190 | front() const noexcept | ||
| 191 | { | ||
| 192 | 102x | BOOST_ASSERT(! empty()); | |
| 193 | 102x | return *begin(); | |
| 194 | } | ||
| 195 | |||
| 196 | inline | ||
| 197 | pct_string_view | ||
| 198 | 16x | segments_encoded_base:: | |
| 199 | back() const noexcept | ||
| 200 | { | ||
| 201 | 16x | BOOST_ASSERT(! empty()); | |
| 202 | 16x | return *--end(); | |
| 203 | } | ||
| 204 | |||
| 205 | inline | ||
| 206 | auto | ||
| 207 | 2164x | segments_encoded_base:: | |
| 208 | begin() const noexcept -> | ||
| 209 | iterator | ||
| 210 | { | ||
| 211 | 2164x | return iterator(ref_); | |
| 212 | } | ||
| 213 | |||
| 214 | inline | ||
| 215 | auto | ||
| 216 | 1800x | segments_encoded_base:: | |
| 217 | end() const noexcept -> | ||
| 218 | iterator | ||
| 219 | { | ||
| 220 | 1800x | return iterator(ref_, 0); | |
| 221 | } | ||
| 222 | |||
| 223 | //------------------------------------------------ | ||
| 224 | |||
| 225 | inline | ||
| 226 | std::ostream& | ||
| 227 | 15x | operator<<( | |
| 228 | std::ostream& os, | ||
| 229 | segments_encoded_base const& ps) | ||
| 230 | { | ||
| 231 | 15x | os << ps.buffer(); | |
| 232 | 15x | return os; | |
| 233 | } | ||
| 234 | |||
| 235 | } // urls | ||
| 236 | } // boost | ||
| 237 | |||
| 238 | #endif | ||
| 239 |