Home
Base module

DynamicBitWriter

Class for reading/writing dynamically resizable binary streams.

DynamicBitWriter

#include <icy/buffer.h>
class DynamicBitWriter

Defined in src/base/include/icy/buffer.h:596

Inherits: BitWriter

Class for reading/writing dynamically resizable binary streams.

Note that when using the constructor with the Buffer reference as an argument, the writer will dynamically expand the given buffer when writing passed the buffer capacity. All other cases will throw a std::out_of_range error when writing past the buffer capacity.

List of all members

NameKindOwner
DynamicBitWriterfunctionDeclared here
DynamicBitWriterfunctionDeclared here
~DynamicBitWriterfunctionDeclared here
putfunctionDeclared here
updatefunctionDeclared here
_buffervariableDeclared here
_offsetvariableDeclared here
operator<<friendInherited from BitWriter
BitWriterfunctionInherited from BitWriter
BitWriterfunctionInherited from BitWriter
BitWriterfunctionInherited from BitWriter
~BitWriterfunctionInherited from BitWriter
putfunctionInherited from BitWriter
putfunctionInherited from BitWriter
putU8functionInherited from BitWriter
putU16functionInherited from BitWriter
putU24functionInherited from BitWriter
putU32functionInherited from BitWriter
putU64functionInherited from BitWriter
updatefunctionInherited from BitWriter
updatefunctionInherited from BitWriter
updateU8functionInherited from BitWriter
updateU16functionInherited from BitWriter
updateU24functionInherited from BitWriter
updateU32functionInherited from BitWriter
updateU64functionInherited from BitWriter
seekfunctionInherited from BitWriter
skipfunctionInherited from BitWriter
limitfunctionInherited from BitWriter
positionfunctionInherited from BitWriter
availablefunctionInherited from BitWriter
beginfunctionInherited from BitWriter
currentfunctionInherited from BitWriter
beginfunctionInherited from BitWriter
currentfunctionInherited from BitWriter
orderfunctionInherited from BitWriter
toStringfunctionInherited from BitWriter
_positionvariableInherited from BitWriter
_limitvariableInherited from BitWriter
_ordervariableInherited from BitWriter
_bytesvariableInherited from BitWriter
initfunctionInherited from BitWriter

Inherited from BitWriter

KindNameDescription
friendoperator<< inline
functionBitWriterConstructs a [BitWriter](icy-BitWriter.html#bitwriter) over a raw byte array with a fixed capacity.
functionBitWriterConstructs a [BitWriter](icy-BitWriter.html#bitwriter) backed by a Buffer. Writes are bounded by the buffer's capacity; use [DynamicBitWriter](#dynamicbitwriter) for auto-resize.
functionBitWriterConstructs a [BitWriter](icy-BitWriter.html#bitwriter) over a [MutableBuffer](icy-MutableBuffer.html#mutablebuffer-6) with a fixed capacity.
function~BitWriter virtual
functionput virtualAppend bytes to the buffer. Throws a std::out_of_range exception if reading past the limit.
functionputAppends the contents of a string. Throws std::out_of_range if capacity is exceeded.
functionputU8Appends an unsigned 8-bit integer. Throws std::out_of_range if capacity is exceeded.
functionputU16Appends an unsigned 16-bit integer with byte-order conversion. Throws std::out_of_range if capacity is exceeded.
functionputU24Appends the low 24 bits of a 32-bit integer with byte-order conversion. Throws std::out_of_range if capacity is exceeded.
functionputU32Appends an unsigned 32-bit integer with byte-order conversion. Throws std::out_of_range if capacity is exceeded.
functionputU64Appends an unsigned 64-bit integer with byte-order conversion. Throws std::out_of_range if capacity is exceeded.
functionupdate virtualUpdate a byte range. Throws a std::out_of_range exception if reading past the limit.
functionupdateOverwrites a previously written string at the given absolute position.
functionupdateU8Overwrites a uint8_t at the given absolute position.
functionupdateU16Overwrites a uint16_t at the given absolute position, with byte-order conversion.
functionupdateU24Overwrites 3 bytes (low 24 bits of val) at the given absolute position, with byte-order conversion.
functionupdateU32Overwrites a uint32_t at the given absolute position, with byte-order conversion.
functionupdateU64Overwrites a uint64_t at the given absolute position, with byte-order conversion.
functionseekSet position pointer to absolute position. Throws a std::out_of_range exception if the value exceeds the limit.
functionskipSet position pointer to relative position. Throws a std::out_of_range exception if the value exceeds the limit.
functionlimit constReturns the write limit.
functionposition const inlineReturns the current write position.
functionavailable constReturns the number of elements between the current write position and the limit.
functionbegin inlineReturns a pointer to the start of the write buffer.
functioncurrent inlineReturns a pointer to the current write position.
functionbegin const inlineReturns a const pointer to the start of the write buffer.
functioncurrent const inlineReturns a const pointer to the current write position.
functionorder const inlineReturns the byte order used for multi-byte integer writes.
functiontoStringReturns all bytes written so far as a std::string.
variable_position
variable_limit
variable_order
variable_bytes
functioninit virtual

Public Methods

ReturnNameDescription
DynamicBitWriterConstructs a [DynamicBitWriter](#dynamicbitwriter) backed by a dynamically resizable Buffer. The buffer is expanded automatically as data is written.
DynamicBitWriterConstructs a [DynamicBitWriter](#dynamicbitwriter) that inserts data starting at a specific iterator position.
voidput virtual overrideAppend bytes to the buffer. Throws a std::out_of_range exception if reading past the limit.
boolupdate virtual overrideUpdate a byte range. Throws a std::out_of_range exception if reading past the limit.

DynamicBitWriter

DynamicBitWriter(Buffer & buf, ByteOrder order = ByteOrder::Network)

Defined in src/base/include/icy/buffer.h:603

Constructs a [DynamicBitWriter](#dynamicbitwriter) backed by a dynamically resizable Buffer. The buffer is expanded automatically as data is written.

Parameters

  • buf Buffer to write into; expanded as needed.

  • order Byte order used for multi-byte integer writes.


DynamicBitWriter

DynamicBitWriter(Buffer & buf, Buffer::iterator offset, ByteOrder order = ByteOrder::Network)

Defined in src/base/include/icy/buffer.h:609

Constructs a [DynamicBitWriter](#dynamicbitwriter) that inserts data starting at a specific iterator position.

Parameters

  • buf Buffer to write into; expanded as needed.

  • offset Iterator into buf indicating the insertion start point.

  • order Byte order used for multi-byte integer writes.


put

virtual override

virtual void put(const char * val, size_t len) override

Defined in src/base/include/icy/buffer.h:614

Append bytes to the buffer. Throws a std::out_of_range exception if reading past the limit.

Reimplements

update

virtual override

virtual bool update(const char * val, size_t len, size_t pos) override

Defined in src/base/include/icy/buffer.h:618

Update a byte range. Throws a std::out_of_range exception if reading past the limit.

Reimplements

Protected Attributes

ReturnNameDescription
Buffer &_buffer
size_t_offset

_buffer

Buffer & _buffer

Defined in src/base/include/icy/buffer.h:621


_offset

size_t _offset

Defined in src/base/include/icy/buffer.h:622