ゴミ箱
consuming_buffers.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9 
10 #ifndef BOOST_BEAST_CONSUMING_BUFFERS_HPP
11 #define BOOST_BEAST_CONSUMING_BUFFERS_HPP
12 
13 #include <boost/beast/config.hpp>
15 #include <boost/asio/buffer.hpp>
16 #include <boost/optional.hpp>
17 #include <cstdint>
18 #include <iterator>
19 #include <type_traits>
20 #include <utility>
21 
22 namespace boost {
23 namespace beast {
24 
39 template<class BufferSequence>
41 {
42  using buffers_type =
43  typename std::decay<BufferSequence>::type;
44 
45  using iter_type =
46  typename buffers_type::const_iterator;
47 
48  BufferSequence bs_;
49  iter_type begin_;
50  std::size_t skip_ = 0;
51 
52  template<class Deduced>
53  consuming_buffers(Deduced&& other, std::size_t dist)
54  : bs_(std::forward<Deduced>(other).bs_)
55  , begin_(std::next(bs_.begin(), dist))
56  , skip_(other.skip_)
57  {
58  }
59 
60 public:
68 #if BOOST_BEAST_DOXYGEN
69  using value_type = implementation_defined;
70 #else
71  using value_type = typename std::conditional<
72  std::is_convertible<typename
73  std::iterator_traits<iter_type>::value_type,
74  boost::asio::mutable_buffer>::value,
75  boost::asio::mutable_buffer,
76  boost::asio::const_buffer>::type;
77 #endif
78 
79 #if BOOST_BEAST_DOXYGEN
80  using const_iterator = implementation_defined;
82 
83 #else
84  class const_iterator;
85 
86 #endif
87 
90 
93 
96 
102  explicit
103  consuming_buffers(BufferSequence const& buffers);
104 
112  template<class... Args>
113  consuming_buffers(boost::in_place_init_t, Args&&... args);
114 
117 
120 
122  BufferSequence const&
123  get() const
124  {
125  return bs_;
126  }
127 
129  const_iterator
130  begin() const;
131 
133  const_iterator
134  end() const;
135 
142  void
143  consume(std::size_t amount);
144 };
145 
146 } // beast
147 } // boost
148 
150 
151 #endif
const_iterator end() const
Get a bidirectional iterator to one past the last element.
Definition: consuming_buffers.ipp:210
Definition: async_result.hpp:20
detail::buffers_helper< ConstBufferSequence > buffers(ConstBufferSequence const &b)
Definition: ostream.hpp:50
Definition: consuming_buffers.hpp:40
typename std::conditional< std::is_convertible< typename std::iterator_traits< iter_type >::value_type, boost::asio::mutable_buffer >::value, boost::asio::mutable_buffer, boost::asio::const_buffer >::type value_type
Definition: consuming_buffers.hpp:76
const_iterator begin() const
Get a bidirectional iterator to the first element.
Definition: consuming_buffers.ipp:200
void consume(std::size_t amount)
Definition: consuming_buffers.ipp:219
consuming_buffers()
Constructor.
Definition: consuming_buffers.ipp:119
consuming_buffers & operator=(consuming_buffers &&)
Assignment.
Definition: consuming_buffers.ipp:171