Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

DynamicBuffer

A dynamic buffer encapsulates memory storage that may be automatically resized as required, where the memory is divided into an input sequence followed by an output sequence. 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, such as the send or receive operations of a socket. Data written to the output sequence of a dynamic buffer object is appended to the input sequence of the same object.

The interface to this concept is intended to permit the following implementation strategies:

Associated With
Requirements

Table 1.42. Valid expressions

Expression

Type

Semantics, Pre/Post-conditions

D::const_buffers_type

T

This type represents the memory associated with the input sequence.

D::mutable_buffers_type

U

This type represents the memory associated with the output sequence.

c.size()

std::size_t

Returns the size, in bytes, of the input sequence.

c.max_size()

std::size_t

Returns the permitted maximum of the sum of the sizes of the input sequence and output sequence.

c.capacity()

std::size_t

Returns the maximum sum of the sizes of the input sequence and output sequence that the dynamic buffer can hold without requiring reallocation.

c.data()

D::const_buffers_type

Returns a constant buffer sequence u that represents the memory associated with the input sequence, and where buffer_size(u) == size().

a.prepare(n)

D::mutable_buffers_type

Returns a mutable buffer sequence u representing the output sequence, and where buffer_size(u) == n. The dynamic buffer reallocates memory as required. All constant or mutable buffer sequences previously obtained using data() or prepare() are invalidated.

Throws: length_error if size() + n exceeds max_size().

a.commit(n)

Appends n bytes from the start of the output sequence to the end of the input sequence. The remainder of the output sequence is discarded. If n is greater than the size of the output sequence, the entire output sequence is appended to the input sequence. All constant or mutable buffer sequences previously obtained using data() or prepare() are invalidated.

a.consume(n)

Removes n bytes from beginning of the input sequence. If n is greater than the size of the input sequence, the entire input sequence is removed. All constant or mutable buffer sequences previously obtained using data() or prepare() are invalidated.


Models

PrevUpHomeNext