template<typename Allocator, typename growth_strategy>
aes70::buffer class

Template parameters
Allocator - The allocator to use. Allocator::value_type must be uint8_t.
growth_strategy

A buffer class which is used for buffering both incoming and outgoing packets.

Constructors, destructors, conversion operators

buffer()
buffer(buffer&& other)

Public functions

auto operator=(buffer&& other) -> buffer&
auto is_empty() -> bool
auto write_pointer() -> void*
auto read_pointer() -> void*
auto size() -> size_t
auto capacity() -> size_t
auto reserve(size_t n, bool exact = false) -> AES70_WARN_UNUSED_RESULT bool
template<typename T>
auto append(T* src, size_t n) -> AES70_WARN_UNUSED_RESULT bool
template<typename T>
auto append(T* src, T* src_end) -> AES70_WARN_UNUSED_RESULT bool
void clear()
auto discard(size_t n) -> AES70_WARN_UNUSED_RESULT bool
template<typename T>
auto discard(T* ptr) -> AES70_WARN_UNUSED_RESULT bool

Function documentation

template<typenameAllocator, typenamegrowth_strategy>
aes70::buffer<Allocator, growth_strategy>::buffer()

Creates an empty buffer.

template<typenameAllocator, typenamegrowth_strategy>
aes70::buffer<Allocator, growth_strategy>::buffer(buffer&& other)

Creates a buffer with the content of another buffer. The other buffer will be empty afterwards.

template<typenameAllocator, typenamegrowth_strategy>
buffer& aes70::buffer<Allocator, growth_strategy>::operator=(buffer&& other)

Move assigns a buffer. The other buffer will be empty afterwards.

template<typenameAllocator, typenamegrowth_strategy>
bool aes70::buffer<Allocator, growth_strategy>::is_empty()

Returns true if the buffer contains no data.

template<typenameAllocator, typenamegrowth_strategy>
void* aes70::buffer<Allocator, growth_strategy>::write_pointer()

Returns a pointer to the end of the data in the buffer. This may be nullptr if the buffer is empty.

template<typenameAllocator, typenamegrowth_strategy>
void* aes70::buffer<Allocator, growth_strategy>::read_pointer()

Returns a pointer to the beginning of the data in the buffer. This may be nullptr if the buffer is empty.

template<typenameAllocator, typenamegrowth_strategy>
size_t aes70::buffer<Allocator, growth_strategy>::size()

Returns the number of bytes currently stored in the buffer.

template<typenameAllocator, typenamegrowth_strategy>
size_t aes70::buffer<Allocator, growth_strategy>::capacity()

Returns the capacity, i.e. the number of bytes currently allocated.

template<typenameAllocator, typenamegrowth_strategy>
AES70_WARN_UNUSED_RESULT bool aes70::buffer<Allocator, growth_strategy>::reserve(size_t n, bool exact = false)

Returns Returns false on allocation failure.

Allocate space for at least n bytes.

template<typenameAllocator, typenamegrowth_strategy> template<typename T>
AES70_WARN_UNUSED_RESULT bool aes70::buffer<Allocator, growth_strategy>::append(T* src, size_t n)

Returns Returns false on allocation failure.

Append some data.

template<typenameAllocator, typenamegrowth_strategy> template<typename T>
AES70_WARN_UNUSED_RESULT bool aes70::buffer<Allocator, growth_strategy>::append(T* src, T* src_end)

Returns Returns false on allocation failure.

Append some data.

template<typenameAllocator, typenamegrowth_strategy>
void aes70::buffer<Allocator, growth_strategy>::clear()

Clears all data from the buffer.

template<typenameAllocator, typenamegrowth_strategy>
AES70_WARN_UNUSED_RESULT bool aes70::buffer<Allocator, growth_strategy>::discard(size_t n)

Returns Returns false on failure.

Discard n bytes of data at the front.

template<typenameAllocator, typenamegrowth_strategy> template<typename T>
AES70_WARN_UNUSED_RESULT bool aes70::buffer<Allocator, growth_strategy>::discard(T* ptr)

Returns Returns false on failure.

Discards all data until ptr.