boost::capy::basic_vector_dynamic_buffer

A dynamic buffer using an underlying vector.

Synopsis

class basic_vector_dynamic_buffer;

Description

This class adapts a std::vector of byte‐sized elements to satisfy the DynamicBuffer concept. The vector provides automatic memory management and growth.

Constraints

The element type T must be a fundamental type with sizeof( T ) == 1. This includes char, unsigned char, signed char, and similar byte‐sized fundamental types.

Example

std::vector<unsigned char> v;
vector_dynamic_buffer vb( &v );

// Write data
auto mb = vb.prepare( 100 );
std::memcpy( mb.data(), "hello", 5 );
vb.commit( 5 );

// Read data
auto data = vb.data();
// process data...
vb.consume( 5 );

Thread Safety

Distinct objects: Safe. Shared objects: Unsafe.

Types

Name

Description

const_buffers_type

The ConstBufferSequence type for readable bytes.

is_dynamic_buffer_adapter

Indicates this is a DynamicBuffer adapter over external storage.

mutable_buffers_type

The MutableBufferSequence type for writable bytes.

vector_type

The underlying vector type.

Member Functions

Name

Description

basic_vector_dynamic_buffer [constructor]

Constructors

~basic_vector_dynamic_buffer [destructor]

Destructor

operator= [deleted]

Copy assignment is deleted.

capacity

Return the number of writable bytes without reallocation.

commit

Move bytes from the output to the input sequence.

consume

Remove bytes from the beginning of the input sequence.

data

Return a buffer sequence representing the readable bytes.

max_size

Return the maximum number of bytes the buffer can hold.

prepare

Return a buffer sequence for writing.

size

Return the number of readable bytes.

Template Parameters

Name Description

T

The element type. Must be fundamental with sizeof 1.

Allocator

The allocator type for the vector.

See Also

flat_dynamic_buffer, circular_dynamic_buffer, string_dynamic_buffer

Created with MrDocs