ゴミ箱
buffers_adapter.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_BUFFERS_ADAPTER_HPP
11 #define BOOST_BEAST_BUFFERS_ADAPTER_HPP
12 
13 #include <boost/beast/config.hpp>
15 #include <boost/asio/buffer.hpp>
16 #include <type_traits>
17 
18 namespace boost {
19 namespace beast {
20 
35 template<class MutableBufferSequence>
37 {
39  "MutableBufferSequence requirements not met");
40 
41  using iter_type = typename MutableBufferSequence::const_iterator;
42 
44  iter_type begin_;
45  iter_type out_;
46  iter_type end_;
47  std::size_t max_size_;
48  std::size_t in_pos_ = 0; // offset in *begin_
49  std::size_t in_size_ = 0; // size of input sequence
50  std::size_t out_pos_ = 0; // offset in *out_
51  std::size_t out_end_ = 0; // output end offset
52 
53  template<class Deduced>
54  buffers_adapter(Deduced&& other,
55  std::size_t nbegin, std::size_t nout,
56  std::size_t nend)
57  : bs_(std::forward<Deduced>(other).bs_)
58  , begin_(std::next(bs_.begin(), nbegin))
59  , out_(std::next(bs_.begin(), nout))
60  , end_(std::next(bs_.begin(), nend))
61  , max_size_(other.max_size_)
62  , in_pos_(other.in_pos_)
63  , in_size_(other.in_size_)
64  , out_pos_(other.out_pos_)
65  , out_end_(other.out_end_)
66  {
67  }
68 
69 public:
70 #if BOOST_BEAST_DOXYGEN
71  using const_buffers_type = implementation_defined;
73 
75  using mutable_buffers_type = implementation_defined;
76 
77 #else
78  class const_buffers_type;
79 
81 
82 #endif
83 
86 
88  buffers_adapter(buffers_adapter const& other);
89 
92 
95 
102  explicit
104 
106  std::size_t
107  max_size() const
108  {
109  return max_size_;
110  }
111 
113  std::size_t
114  size() const
115  {
116  return in_size_;
117  }
118 
120  std::size_t
121  capacity() const
122  {
123  return max_size_;
124  }
125 
135  prepare(std::size_t n);
136 
142  void
143  commit(std::size_t n);
144 
149  const_buffers_type
150  data() const;
151 
153  void
154  consume(std::size_t n);
155 };
156 
157 } // beast
158 } // boost
159 
161 
162 #endif
void consume(std::size_t n)
Remove bytes from the input sequence.
Definition: buffers_adapter.ipp:474
std::size_t max_size() const
Returns the largest size output sequence possible.
Definition: buffers_adapter.hpp:107
Definition: async_result.hpp:20
mutable_buffers_type prepare(std::size_t n)
Definition: buffers_adapter.ipp:387
detail::buffers_helper< ConstBufferSequence > buffers(ConstBufferSequence const &b)
Definition: ostream.hpp:50
Definition: buffers_adapter.hpp:36
std::size_t size() const
Get the size of the input sequence.
Definition: buffers_adapter.hpp:114
Definition: buffers_adapter.ipp:167
void commit(std::size_t n)
Definition: buffers_adapter.ipp:427
std::size_t capacity() const
Returns the maximum sum of the sizes of the input sequence and output sequence the buffer can hold wi...
Definition: buffers_adapter.hpp:121
const_buffers_type data() const
Definition: buffers_adapter.ipp:466
buffers_adapter & operator=(buffers_adapter &&other)
Move assignment.
Definition: buffers_adapter.ipp:330
Definition: type_traits.hpp:96
BufferSequence< boost::asio::mutable_buffer > MutableBufferSequence
Definition: type_traits.hpp:282