| Home | Libraries | People | FAQ | More

#### basic_multi_buffer

A dynamic buffer providing sequences of variable length.

##### Synopsis

Defined in header `<boost/beast/core/multi_buffer.hpp>`

    template<
        class Allocator>
    class basic_multi_buffer

##### Types

Name | Description
--- | ---
allocator_type | The type of allocator used.
const_buffers_type | The ConstBufferSequence used to represent the readable bytes.
mutable_buffers_type | The MutableBufferSequence used to represent the writable bytes.
mutable_data_type | The MutableBufferSequence used to represent the readable bytes.

##### Member Functions

Name | Description
--- | ---
basic_multi_buffer | Constructor. Move Constructor. Copy Constructor.
capacity | Return the maximum number of bytes, both readable and writable, that can be held without requiring an allocation.
cdata | Returns a constant buffer sequence representing the readable bytes.
clear | Set the size of the readable and writable bytes to zero.
commit | Append writable bytes to the readable bytes.
consume | Remove bytes from beginning of the readable bytes.
data | Returns a constant buffer sequence representing the readable bytes. Returns a mutable buffer sequence representing the readable bytes.
get_allocator | Returns a copy of the allocator used.
max_size | Set the maximum allowed capacity. Return the maximum number of bytes, both readable and writable, that can ever be held.
operator= | Move Assignment. Copy Assignment.
prepare | Returns a mutable buffer sequence representing writable bytes.
reserve | Guarantee a minimum capacity.
shrink_to_fit | Reallocate the buffer to fit the readable bytes exactly.
size | Returns the number of readable bytes.
~basic_multi_buffer | Destructor.

##### Friends

Name | Description
--- | ---
swap | Exchange two dynamic buffers.

##### Description

A dynamic buffer encapsulates memory storage that may be automatically resized as required, where the memory is divided into two regions: readable bytes followed by writable bytes. These memory regions are internal to the dynamic buffer, but direct access to the elements is provided to permit them to be efficiently used with I/O operations. The implementation uses a sequence of one or more byte arrays of varying sizes to represent the readable and writable bytes. Additional byte array objects are appended to the sequence to accommodate changes in the desired size. The behavior and implementation of this container is most similar to `std::deque`. Objects of this type meet the requirements of DynamicBuffer and have the following additional properties:

- A mutable buffer sequence representing the readable bytes is returned by `basic_multi_buffer::data` when `this` is non-const.
- Buffer sequences representing the readable and writable bytes, returned by `basic_multi_buffer::data` and `basic_multi_buffer::prepare`, may have length greater than one.
- A configurable maximum size may be set upon construction and adjusted afterwards. Calls to `basic_multi_buffer::prepare` that would exceed this size will throw `std::length_error`.
- Sequences previously obtained using `basic_multi_buffer::data` remain valid after calls to `basic_multi_buffer::prepare` or `basic_multi_buffer::commit`.

##### Template Parameters

Type | Description
--- | ---
`Allocator` | The allocator to use for managing memory.

Convenience header `<boost/beast/core.hpp>`