class
BufferedBitstreamWriter
Wraps a Bitstream and a DataStream.
Buffers the written data in the bitstream and then on request flushes the data into the data stream.
Public
Constructors
BufferedBitstreamWriter
Constructs a new instance of the object.
Methods
WriteBits
Writes bits from the provided buffer into the stream at the current cursor location and advances the cursor.
- data
- Buffer to write the data from. Must have enough capacity to store bits.
- count
- Number of bits to write.
Returns: Number of bits written.
WriteBytes
Writes bytes from the provided buffer into the stream at the current cursor location and advances the cursor.
- data
- Buffer to write the data from. Must have enough capacity to store bytes.
- count
- Number of bytes to write.
Returns: Number of bytes written.
WriteVarInt
Encodes a 32-bit integer value as a base-128 varint and writes it to the stream.
Write is performed at the current cursor location and advances the cursor. Varints are a method of serializing integers using one or more bytes, where smaller values use less bytes. Returns the number of bits written.
Align
Aligns the read/write cursor to a byte boundary. determines the alignment in bytes.
Note the requested alignment might not be achieved if count > 1 and it would move the cursor past the capacity of the buffer, as the cursor will be clamped to buffer end regardless of alignment.
Returns number of bits skipped due to alignment.
Flush
Flushes the write buffer to the output stream if a certain buffer length is reached.