11 #ifndef ASIO_DETAIL_CONSUMING_BUFFERS_HPP 12 #define ASIO_DETAIL_CONSUMING_BUFFERS_HPP 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 30 template <
typename Buffer,
typename Buffer_Iterator>
58 Buffer_Iterator begin_remainder, Buffer_Iterator end_remainder,
60 : at_end_(max_size > 0 ? at_end : true),
61 first_(
buffer(first, max_size)),
62 begin_remainder_(begin_remainder),
63 end_remainder_(end_remainder),
78 return &dereference();
115 if (begin_remainder_ == end_remainder_
123 first_ =
buffer(*begin_remainder_++, max_size_ - offset_);
130 if (at_end_ && other.at_end_)
132 return !at_end_ && !other.at_end_
134 == buffer_cast<const void*>(other.first_)
136 && begin_remainder_ == other.begin_remainder_
137 && end_remainder_ == other.end_remainder_;
140 const Buffer& dereference()
const 147 Buffer_Iterator begin_remainder_;
148 Buffer_Iterator end_remainder_;
150 std::size_t max_size_;
154 template <
typename Buffer,
typename Buffers>
168 at_end_(buffers_.
begin() == buffers_.
end()),
169 begin_remainder_(buffers_.
begin()),
170 max_size_((
std::numeric_limits<
std::size_t>::max)())
174 first_ = *buffers_.begin();
181 : buffers_(other.buffers_),
182 at_end_(other.at_end_),
183 first_(other.first_),
184 begin_remainder_(buffers_.
begin()),
185 max_size_(other.max_size_)
187 typename Buffers::const_iterator first = other.buffers_.begin();
188 typename Buffers::const_iterator second = other.begin_remainder_;
189 std::advance(begin_remainder_, std::distance(first, second));
195 buffers_ = other.buffers_;
196 at_end_ = other.at_end_;
197 first_ = other.first_;
198 begin_remainder_ = buffers_.begin();
199 typename Buffers::const_iterator first = other.buffers_.begin();
200 typename Buffers::const_iterator second = other.begin_remainder_;
201 std::advance(begin_remainder_, std::distance(first, second));
202 max_size_ = other.max_size_;
210 begin_remainder_, buffers_.end(), max_size_);
222 max_size_ = max_size;
229 while (size > 0 && !at_end_)
234 if (begin_remainder_ == buffers_.end())
237 first_ = *begin_remainder_++;
241 first_ = first_ + size;
249 if (begin_remainder_ == buffers_.end())
252 first_ = *begin_remainder_++;
260 typename Buffers::const_iterator begin_remainder_;
261 std::size_t max_size_;
266 template <
typename Buffer>
292 #endif // ASIO_DETAIL_CONSUMING_BUFFERS_HPP const_iterator end() const
void consume(std::size_t)
const Buffer * operator->() const
void consume(std::size_t size)
const Buffer & operator*() const
SocketService Iterator begin
const_iterator begin() const
friend bool operator==(const consuming_buffers_iterator &a, const consuming_buffers_iterator &b)
mutable_buffers_1 buffer(const mutable_buffer &b)
Create a new modifiable buffer from an existing buffer.
asio::basic_streambuf< Allocator > & b
std::size_t buffer_size(const mutable_buffer &b)
Get the number of bytes in a modifiable buffer.
void prepare(std::size_t)
PointerToPodType buffer_cast(const mutable_buffer &b)
Cast a non-modifiable buffer to a specified pointer to POD type.
void prepare(std::size_t max_size)
const MutableBufferSequence & buffers
consuming_buffers(const consuming_buffers &other)
consuming_buffers_iterator operator++(int)
friend bool operator!=(const consuming_buffers_iterator &a, const consuming_buffers_iterator &b)
consuming_buffers_iterator & operator++()
consuming_buffers_iterator< Buffer, typename Buffers::const_iterator > const_iterator
consuming_buffers & operator=(const consuming_buffers &other)
consuming_buffers(const asio::null_buffers &)
std::forward_iterator_tag iterator_category
The iterator category.
std::ptrdiff_t difference_type
The type used for the distance between two iterators.
Buffer value_type
The type of the value pointed to by the iterator.
SocketService Iterator Iterator end
consuming_buffers_iterator()
consuming_buffers(const Buffers &buffers)
const Buffer & reference
The type of the result of applying operator*() to the iterator.
consuming_buffers_iterator(bool at_end, const Buffer &first, Buffer_Iterator begin_remainder, Buffer_Iterator end_remainder, std::size_t max_size)
const Buffer * pointer
The type of the result of applying operator->() to the iterator.