|
| buffered_read_stream (buffered_read_stream &&)=default |
|
buffered_read_stream & | operator= (buffered_read_stream &&)=default |
|
template<class... Args> |
| buffered_read_stream (Args &&...args) |
|
next_layer_type & | next_layer () |
| Get a reference to the next layer. More...
|
|
next_layer_type const & | next_layer () const |
| Get a const reference to the next layer. More...
|
|
lowest_layer_type & | lowest_layer () |
| Get a reference to the lowest layer. More...
|
|
lowest_layer_type const & | lowest_layer () const |
| Get a const reference to the lowest layer. More...
|
|
boost::asio::io_service & | get_io_service () |
| Get the io_service associated with the object. More...
|
|
DynamicBuffer & | buffer () |
|
DynamicBuffer const & | buffer () const |
| Access the internal buffer. More...
|
|
void | capacity (std::size_t size) |
|
template<class MutableBufferSequence > |
std::size_t | read_some (MutableBufferSequence const &buffers) |
|
template<class MutableBufferSequence > |
std::size_t | read_some (MutableBufferSequence const &buffers, error_code &ec) |
|
template<class MutableBufferSequence , class ReadHandler > |
async_return_type< ReadHandler, void(error_code)> | async_read_some (MutableBufferSequence const &buffers, ReadHandler &&handler) |
|
template<class ConstBufferSequence > |
std::size_t | write_some (ConstBufferSequence const &buffers) |
|
template<class ConstBufferSequence > |
std::size_t | write_some (ConstBufferSequence const &buffers, error_code &ec) |
|
template<class ConstBufferSequence , class WriteHandler > |
async_return_type< WriteHandler, void(error_code)> | async_write_some (ConstBufferSequence const &buffers, WriteHandler &&handler) |
|
template<class ConstBufferSequence , class WriteHandler > |
auto | async_write_some (ConstBufferSequence const &buffers, WriteHandler &&handler) -> async_return_type< WriteHandler, void(error_code)> |
|
template<class MutableBufferSequence , class ReadHandler > |
auto | async_read_some (MutableBufferSequence const &buffers, ReadHandler &&handler) -> async_return_type< ReadHandler, void(error_code)> |
|
template<class Stream, class DynamicBuffer>
class boost::beast::buffered_read_stream< Stream, DynamicBuffer >
A Stream with attached DynamicBuffer to buffer reads.
This wraps a Stream implementation so that calls to write are passed through to the underlying stream, while calls to read will first consume the input sequence stored in a DynamicBuffer which is part of the object.
The use-case for this class is different than that of the boost::asio::buffered_readstream
. It is designed to facilitate the use of boost::asio::read_until
, and to allow buffers acquired during detection of handshakes to be made transparently available to callers. A hypothetical implementation of the buffered version of boost::asio::ssl::stream::async_handshake
could make use of this wrapper.
Uses:
- Transparently leave untouched input acquired in calls to
boost::asio::read_until
behind for subsequent callers.
- "Preload" a stream with handshake input data acquired from other sources.
Example:
template<class DynamicBuffer>
void process_http_message(
buffered_read_stream<DynamicBuffer>& stream)
{
std::size_t bytes_transferred =
boost::asio::read_until(
stream.next_layer(), stream.buffer(), "\r\n\r\n");
bytes_transferred, stream.buffer().data());
...
stream.buffer().consume(bytes_transferred);
}
- Template Parameters
-
Stream | The type of stream to wrap. |
DynamicBuffer | The type of stream buffer to use. |
template<class Stream , class DynamicBuffer >
Set the maximum buffer size.
This changes the maximum size of the internal buffer used to hold read data. No bytes are discarded by this call. If the buffer size is set to zero, no more data will be buffered.
Thread safety: The caller is responsible for making sure the call is made from the same implicit or explicit strand.
- Parameters
-
size | The number of bytes in the read buffer. |
- Note
- This is a soft limit. If the new maximum size is smaller than the amount of data in the buffer, no bytes are discarded.
template<class Stream , class DynamicBuffer >
template<class MutableBufferSequence >
Read some data from the stream.
This function is used to read data from the stream. The function call will block until one or more bytes of data has been read successfully, or until an error occurs.
- Parameters
-
buffers | One or more buffers into which the data will be read. |
- Returns
- The number of bytes read.
- Exceptions
-
system_error | Thrown on failure. |
template<class Stream , class DynamicBuffer >
template<class ConstBufferSequence >
Write some data to the stream.
This function is used to write data to the stream. The function call will block until one or more bytes of the data has been written successfully, or until an error occurs.
- Parameters
-
buffers | One or more data buffers to be written to the stream. |
- Returns
- The number of bytes written.
- Exceptions
-
system_error | Thrown on failure. |