File indexing completed on 2025-01-18 09:29:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_DETAIL_BUFFERS_RANGE_ADAPTOR_HPP
0011 #define BOOST_BEAST_DETAIL_BUFFERS_RANGE_ADAPTOR_HPP
0012
0013 #include <boost/beast/core/buffer_traits.hpp>
0014 #include <iterator>
0015 #include <type_traits>
0016
0017 namespace boost {
0018 namespace beast {
0019 namespace detail {
0020
0021 template<class BufferSequence>
0022 class buffers_range_adaptor
0023 {
0024 BufferSequence b_;
0025
0026 public:
0027 #if BOOST_BEAST_DOXYGEN
0028 using value_type = __see_below__;
0029 #else
0030 using value_type = buffers_type<BufferSequence>;
0031 #endif
0032
0033 class const_iterator
0034 {
0035 friend class buffers_range_adaptor;
0036
0037 using iter_type =
0038 buffers_iterator_type<BufferSequence>;
0039
0040 iter_type it_{};
0041
0042 const_iterator(iter_type const& it)
0043 : it_(it)
0044 {
0045 }
0046
0047 public:
0048 using value_type = typename
0049 buffers_range_adaptor::value_type;
0050 using pointer = value_type const*;
0051 using reference = value_type;
0052 using difference_type = std::ptrdiff_t;
0053 using iterator_category =
0054 std::bidirectional_iterator_tag;
0055
0056 const_iterator() = default;
0057
0058 bool
0059 operator==(const_iterator const& other) const
0060 {
0061 return it_ == other.it_;
0062 }
0063
0064 bool
0065 operator!=(const_iterator const& other) const
0066 {
0067 return !(*this == other);
0068 }
0069
0070 reference
0071 operator*() const
0072 {
0073 return *it_;
0074 }
0075
0076 pointer
0077 operator->() const = delete;
0078
0079 const_iterator&
0080 operator++()
0081 {
0082 ++it_;
0083 return *this;
0084 }
0085
0086 const_iterator
0087 operator++(int)
0088 {
0089 auto temp = *this;
0090 ++(*this);
0091 return temp;
0092 }
0093
0094 const_iterator&
0095 operator--()
0096 {
0097 --it_;
0098 return *this;
0099 }
0100
0101 const_iterator
0102 operator--(int)
0103 {
0104 auto temp = *this;
0105 --(*this);
0106 return temp;
0107 }
0108 };
0109
0110 explicit
0111 buffers_range_adaptor(BufferSequence const& b)
0112 : b_(b)
0113 {
0114 }
0115
0116 const_iterator
0117 begin() const noexcept
0118 {
0119 return {net::buffer_sequence_begin(b_)};
0120 }
0121
0122 const_iterator
0123 end() const noexcept
0124 {
0125 return {net::buffer_sequence_end(b_)};
0126 }
0127 };
0128
0129 }
0130 }
0131 }
0132
0133 #endif