Adapt a basic_linear_buffer
to the DynamicBuffer requirements.
More...
#include <asioext/linear_buffer.hpp>
template<typename Allocator>
class asioext::dynamic_linear_buffer< Allocator >
Adapt a basic_linear_buffer
to the DynamicBuffer requirements.
◆ const_buffers_type
template<typename Allocator >
The type used to represent the input sequence as a list of buffers.
◆ mutable_buffers_type
template<typename Allocator >
The type used to represent the output sequence as a list of buffers.
◆ dynamic_linear_buffer()
template<typename Allocator >
Construct a dynamic buffer from a basic_linear_buffer
.
- Parameters
-
b | The basic_linear_buffer to be used as backing storage for the dynamic buffer. Any existing data in the buffer is treated as the dynamic buffer's input sequence. The object stores a reference to the buffer and the user is responsible for ensuring that the buffer object remains valid until the dynamic_linear_buffer object is destroyed. |
maximum_size | Specifies a maximum size for the buffer, in bytes. |
◆ capacity()
template<typename Allocator >
Get the current capacity of the dynamic buffer.
- Returns
- The current total capacity of the buffer, i.e. for both the input sequence and output sequence.
◆ commit()
template<typename Allocator >
Move bytes from the output sequence to the input sequence.
- Parameters
-
n | The number of bytes to append from the start of the output sequence to the end of the input sequence. The remainder of the output sequence is discarded. |
Requires a preceding call prepare(x)
where x >= n
, and no intervening operations that modify the input or output sequence.
- Note
- If
n
is greater than the size of the output sequence, the entire output sequence is moved to the input sequence and no error is issued.
◆ consume()
template<typename Allocator >
Remove characters from the input sequence.
Removes n
characters from the beginning of the input sequence.
- Note
- If
n
is greater than the size of the input sequence, the entire input sequence is consumed and no error is issued.
◆ data() [1/2]
template<typename Allocator >
Get a list of buffers that represents the input sequence.
- Returns
- An object of type
mutable_buffers_type
that satisfies ConstBufferSequence requirements, representing the memory in the input sequence.
- Note
- The returned object is invalidated by any
dynamic_linear_buffer
member function that modifies the input sequence or output sequence.
◆ data() [2/2]
template<typename Allocator >
Get a list of buffers that represents the input sequence.
- Returns
- An object of type
const_buffers_type
that satisfies ConstBufferSequence requirements, representing the memory in the input sequence.
- Note
- The returned object is invalidated by any
dynamic_linear_buffer
member function that modifies the input sequence or output sequence.
◆ max_size()
template<typename Allocator >
Get the maximum size of the dynamic buffer.
- Returns
- The allowed maximum of the sum of the sizes of the input sequence and output sequence.
◆ prepare() [1/2]
template<typename Allocator >
Get a list of buffers that represents the output sequence, with the given size.
Ensures that the output sequence can accommodate n
bytes, resizing the storage object as necessary.
- Parameters
-
n | Total number of bytes the output sequence has to accomodate. |
- Returns
- An object of type
mutable_buffers_type
that satisfies MutableBufferSequence requirements, representing memory at the start of the output sequence of size n
.
- Exceptions
-
- Note
- The returned object is invalidated by any
basic_linear_buffer
member function that modifies the input sequence or output sequence.
◆ prepare() [2/2]
template<typename Allocator >
Get a list of buffers that represents the output sequence, with the given size.
Ensures that the output sequence can accommodate n
bytes, resizing the storage object as necessary.
- Parameters
-
n | Total number of bytes the output sequence has to accomodate. |
ec | Set to indicate what error occurred. If no error occurred, the object is reset. |
- Returns
- An object of type
mutable_buffers_type
that satisfies MutableBufferSequence requirements, representing memory at the start of the output sequence of size n
.
- Note
- The returned object is invalidated by any
basic_linear_buffer
member function that modifies the input sequence or output sequence.
-
This function is not part of the DynamicBuffer requirements.
◆ size()
template<typename Allocator >
Get the size of the input sequence.