ゴミ箱
buffered_read_stream.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_BUFFERED_READ_STREAM_HPP
11 #define BOOST_BEAST_BUFFERED_READ_STREAM_HPP
12 
13 #include <boost/beast/config.hpp>
18 #include <boost/asio/buffer.hpp>
19 #include <boost/asio/io_service.hpp>
20 #include <cstdint>
21 #include <utility>
22 
23 namespace boost {
24 namespace beast {
25 
91 template<class Stream, class DynamicBuffer>
93 {
95  "DynamicBuffer requirements not met");
96 
97  template<class Buffers, class Handler>
98  class read_some_op;
99 
100  DynamicBuffer buffer_;
101  std::size_t capacity_ = 0;
102  Stream next_layer_;
103 
104 public:
106  using buffer_type = DynamicBuffer;
107 
109  using next_layer_type =
110  typename std::remove_reference<Stream>::type;
111 
113  using lowest_layer_type =
115 
122 
129 
134  template<class... Args>
135  explicit
136  buffered_read_stream(Args&&... args);
137 
141  {
142  return next_layer_;
143  }
144 
146  next_layer_type const&
147  next_layer() const
148  {
149  return next_layer_;
150  }
151 
155  {
156  return next_layer_.lowest_layer();
157  }
158 
160  lowest_layer_type const&
161  lowest_layer() const
162  {
163  return next_layer_.lowest_layer();
164  }
165 
167  boost::asio::io_service&
169  {
170  return next_layer_.get_io_service();
171  }
172 
180  DynamicBuffer&
182  {
183  return buffer_;
184  }
185 
187  DynamicBuffer const&
188  buffer() const
189  {
190  return buffer_;
191  }
192 
208  void
209  capacity(std::size_t size)
210  {
211  capacity_ = size;
212  }
213 
226  template<class MutableBufferSequence>
227  std::size_t
229 
242  template<class MutableBufferSequence>
243  std::size_t
244  read_some(MutableBufferSequence const& buffers,
245  error_code& ec);
246 
270  template<class MutableBufferSequence, class ReadHandler>
271 #if BOOST_BEAST_DOXYGEN
272  void_or_deduced
273 #else
275 #endif
276  async_read_some(MutableBufferSequence const& buffers,
277  ReadHandler&& handler);
278 
291  template<class ConstBufferSequence>
292  std::size_t
294  {
296  "SyncWriteStream requirements not met");
297  return next_layer_.write_some(buffers);
298  }
299 
312  template<class ConstBufferSequence>
313  std::size_t
315  error_code& ec)
316  {
318  "SyncWriteStream requirements not met");
319  return next_layer_.write_some(buffers, ec);
320  }
321 
345  template<class ConstBufferSequence, class WriteHandler>
346 #if BOOST_BEAST_DOXYGEN
347  void_or_deduced
348 #else
350 #endif
351  async_write_some(ConstBufferSequence const& buffers,
352  WriteHandler&& handler);
353 };
354 
355 } // beast
356 } // boost
357 
359 
360 #endif
BufferSequence< boost::asio::const_buffer > ConstBufferSequence
Definition: type_traits.hpp:280
StreamHandler WriteHandler
Definition: type_traits.hpp:357
next_layer_type & next_layer()
Get a reference to the next layer.
Definition: buffered_read_stream.hpp:140
StreamHandler ReadHandler
Definition: type_traits.hpp:356
Definition: async_result.hpp:20
DynamicBuffer buffer_type
The type of the internal buffer.
Definition: buffered_read_stream.hpp:106
lowest_layer_type & lowest_layer()
Get a reference to the lowest layer.
Definition: buffered_read_stream.hpp:154
detail::buffers_helper< ConstBufferSequence > buffers(ConstBufferSequence const &b)
Definition: ostream.hpp:50
async_return_type< ReadHandler, void(error_code)> async_read_some(MutableBufferSequence const &buffers, ReadHandler &&handler)
DynamicBuffer & buffer()
Definition: buffered_read_stream.hpp:181
T type
Definition: type_traits.hpp:302
async_return_type< WriteHandler, void(error_code)> async_write_some(ConstBufferSequence const &buffers, WriteHandler &&handler)
buffered_read_stream(buffered_read_stream &&)=default
lowest_layer_type const & lowest_layer() const
Get a const reference to the lowest layer.
Definition: buffered_read_stream.hpp:161
boost::system::error_code error_code
The type of error code used by the library.
Definition: error.hpp:21
std::size_t read_some(MutableBufferSequence const &buffers)
Definition: buffered_read_stream.ipp:174
Definition: type_traits.hpp:479
buffered_read_stream & operator=(buffered_read_stream &&)=default
typename get_lowest_layer< next_layer_type >::type lowest_layer_type
The type of the lowest layer.
Definition: buffered_read_stream.hpp:114
void capacity(std::size_t size)
Definition: buffered_read_stream.hpp:209
Definition: type_traits.hpp:134
std::size_t write_some(ConstBufferSequence const &buffers, error_code &ec)
Definition: buffered_read_stream.hpp:314
DynamicBuffer const & buffer() const
Access the internal buffer.
Definition: buffered_read_stream.hpp:188
next_layer_type const & next_layer() const
Get a const reference to the next layer.
Definition: buffered_read_stream.hpp:147
Definition: buffered_read_stream.hpp:92
typename std::remove_reference< Stream >::type next_layer_type
The type of the next layer.
Definition: buffered_read_stream.hpp:110
typename beast::async_result< typename std::decay< CompletionToken >::type, Signature >::return_type async_return_type
Definition: async_result.hpp:204
std::size_t write_some(ConstBufferSequence const &buffers)
Definition: buffered_read_stream.hpp:293
boost::asio::io_service & get_io_service()
Get the io_service associated with the object.
Definition: buffered_read_stream.hpp:168
BufferSequence< boost::asio::mutable_buffer > MutableBufferSequence
Definition: type_traits.hpp:282