class dynamic_buffer#

template<typename Container>
class dynamic_buffer#

An adapter that turns Container into a type that satisfies net::DynamicBuffer concept.

DESCRIPTION

An adapter that turns Container into a type that satisfies net::DynamicBuffer concept. Note that Container must use contiguous storage.

              readable    writable
|-----------|-----------|-----------|-----------|-----------|
0        roffset     woffset     c.size()  c.capacity()    limit

Public Functions

inline dynamic_buffer()#

Construct a dynamic_buffer with maximum capacity of Container::max_size().

inline dynamic_buffer(std::size_t limit)#

Construct a dynamic_buffer with maximum capacity of std::size_t limit.

inline dynamic_buffer(Container container)#

Construct a dynamic_buffer with existing container.

inline auto cdata() const -> const_buffers_type#

Get a constant buffer sequence representing readable bytes.

inline auto data() const -> const_buffers_type#

Get a constant buffer sequence representing readable bytes.

inline auto data() -> mutable_buffers_type#

Get a mutable buffer sequence representing readable bytes.

inline void consume(std::size_t n)#

Remove bytes starting from the beginning of readable bytes.

inline auto prepare(std::size_t n) -> mutable_buffers_type#

Get a mutable buffer sequence representing writable bytes.

inline void commit(std::size_t n)#

Convert writable bytes into readable bytes.

inline auto size() const noexcept -> std::size_t#

Get the number of readable bytes.

inline auto max_size() const noexcept -> std::size_t#

Get the maximum allowed of the capacity.

inline auto capacity() const noexcept -> std::size_t#

Get the capacity.

inline auto release() -> Container#

Release the underlying Container instance.

DESCRIPTION

Release the underlying Container instance, which only contains readable bytes.