Struct BufWriterParts

Struct Documentation

struct BufWriterParts

The fundamental parts of a BufWriter. This struct can be constructed either from a BufWriter itself or manually from its raw writer.

It consists of an arbitrary, flushable/extendable buffer type (e.g. a std::string), a cursor into the buffer (that describes its base address and length of the free segment) and a function to flush the buffer (i.e. to either flush to io or extend the buffer). During usage callers must update the cursor to reflect the current start of the spare capacity and remaining length. When the remaining length reaches zero, flush must be called using the provided buffer and cursor. Its task is to somehow make more buffer room and then adjust the cursor to point to the new spare room.

See implementation of write_str (below) for a practical usage example

Public Functions

BufWriterParts() = delete
BufWriterParts(BufWriterParts const&) noexcept = default
BufWriterParts(BufWriterParts&&) noexcept = default
BufWriterParts &operator=(BufWriterParts const&) noexcept = default
BufWriterParts &operator=(BufWriterParts&&) noexcept = default
~BufWriterParts() noexcept = default
template<BufWriter W>
inline BufWriterParts(W &w) noexcept
inline BufWriterParts(void *buffer, char **cursor, size_t *remaining_size, FlushFunc flush) noexcept

Public Members

void *buffer
char **write_area
size_t *write_area_size
FlushFunc flush