boost::capy::basic_string_dynamic_buffer

A dynamic buffer backed by a std::basic_string.

Synopsis

template<
    class CharT,
    class Traits = std::char_traits<CharT>,
    class Allocator = std::allocator<CharT>>
class basic_string_dynamic_buffer;

Description

This adapter wraps an externally‐owned string and exposes it through the DynamicBuffer interface. Readable bytes occupy the front of the string; writable bytes are appended by prepare and made readable by commit.

The wrapped string must outlive this adapter. Calls to prepare, commit, and consume invalidate previously returned buffer views.

Thread Safety

Distinct objects: Safe. Shared objects: Unsafe.

Example

std::string s;
auto buf = dynamic_buffer( s, 4096 );
auto mb = buf.prepare( 100 );
// fill mb with data...
buf.commit( 100 );
// buf.data() now has 100 readable bytes
buf.consume( 50 );

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.

string_type

The underlying string type.

Member Functions

Name

Description

basic_string_dynamic_buffer [constructor]

Constructors

~basic_string_dynamic_buffer [destructor]

Destroy the buffer.

operator= [deleted]

Copy assignment is deleted.

capacity

Return the number of writable bytes without reallocation.

commit

Move bytes from the writable to the readable area.

consume

Remove bytes from the beginning of the readable area.

data

Return a buffer sequence representing the readable bytes.

max_size

Return the maximum number of bytes the buffer can hold.

prepare

Prepare writable space of at least n bytes.

size

Return the number of readable bytes.

Non-Member Functions

Name

Description

dynamic_buffer

Create a dynamic buffer from a string.

Template Parameters

Name Description

CharT

The character type.

Traits

The character traits type.

Allocator

The allocator type.

See Also

DynamicBuffer, string_dynamic_buffer, dynamic_buffer

Created with MrDocs