File indexing completed on 2025-01-18 09:53:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_URL_IMPL_SEGMENTS_BASE_HPP
0012 #define BOOST_URL_IMPL_SEGMENTS_BASE_HPP
0013
0014 #include <boost/url/detail/segments_iter_impl.hpp>
0015 #include <boost/assert.hpp>
0016 #include <iterator>
0017
0018 namespace boost {
0019 namespace urls {
0020
0021 class segments_base::iterator
0022 {
0023 detail::segments_iter_impl it_;
0024
0025 friend class segments_base;
0026 friend class segments_ref;
0027
0028 iterator(detail::path_ref const&) noexcept;
0029 iterator(detail::path_ref const&, int) noexcept;
0030
0031 iterator(
0032 detail::segments_iter_impl const& it) noexcept
0033 : it_(it)
0034 {
0035 }
0036
0037 public:
0038 using value_type = segments_base::value_type;
0039 using reference = segments_base::reference;
0040 using pointer = reference;
0041 using difference_type =
0042 segments_base::difference_type;
0043 using iterator_category =
0044 std::bidirectional_iterator_tag;
0045
0046 iterator() = default;
0047 iterator(iterator const&) = default;
0048 iterator& operator=(
0049 iterator const&) noexcept = default;
0050
0051 BOOST_URL_DECL
0052 reference
0053 operator*() const;
0054
0055
0056 pointer operator->() const = delete;
0057
0058 iterator&
0059 operator++() noexcept
0060 {
0061 it_.increment();
0062 return *this;
0063 }
0064
0065 iterator&
0066 operator--() noexcept
0067 {
0068 it_.decrement();
0069 return *this;
0070 }
0071
0072 iterator
0073 operator++(int) noexcept
0074 {
0075 auto tmp = *this;
0076 ++*this;
0077 return tmp;
0078 }
0079
0080 iterator
0081 operator--(int) noexcept
0082 {
0083 auto tmp = *this;
0084 --*this;
0085 return tmp;
0086 }
0087
0088 bool
0089 operator==(
0090 iterator const& other) const noexcept
0091 {
0092 return it_.equal(other.it_);
0093 }
0094
0095 bool
0096 operator!=(
0097 iterator const& other) const noexcept
0098 {
0099 return ! it_.equal(other.it_);
0100 }
0101 };
0102
0103
0104
0105 inline
0106 std::string
0107 segments_base::
0108 front() const noexcept
0109 {
0110 BOOST_ASSERT(! empty());
0111 return *begin();
0112 }
0113
0114 inline
0115 std::string
0116 segments_base::
0117 back() const noexcept
0118 {
0119 BOOST_ASSERT(! empty());
0120 return *--end();
0121 }
0122
0123 }
0124 }
0125
0126 #endif