#include <bit_stream_writer.hpp>
|
| BitStream (std::streambuf *stream_buffer, byte_type starting_position) noexcept |
|
template<detail::BitStreamInteger DataType> |
DataType | bit_mask (const DataType bits) |
|
std::streambuf * | m_stream_buffer |
|
buffer_type | m_buffer {0} |
|
byte_type | m_position {0} |
|
Implementation of the BitStream interface for writing to a binary stream.
Bits are written to an in-memory byte buffer until that buffer is full, at which point that buffer is flushed to the stream. When done writing, callers should invoke the finish() method to flush the BitStream header and any bytes remaining in the buffer.
- Author
- Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
- Version
- July 7, 2019
◆ BitStreamWriter()
fly::BitStreamWriter::BitStreamWriter |
( |
std::ostream & |
stream | ) |
|
|
explicitnoexcept |
Constructor. Write the header byte onto the stream.
- Parameters
-
stream | The stream to write binary data into. |
◆ finish()
bool fly::BitStreamWriter::finish |
( |
| ) |
|
If needed, zero-fill the byte buffer, flush it to the stream, and update the header byte.
- Returns
- True if the stream remains in a good state.
◆ write_bits()
template<detail::BitStreamInteger DataType>
void fly::BitStreamWriter::write_bits |
( |
DataType |
bits, |
|
|
byte_type |
size |
|
) |
| |
Write a number of bits to the byte buffer. The least-significant bits in the provided data type will be written, starting from the position pointed to by the provided number of bits.
Flush the buffer to the stream if it is filled during this operation.
- Template Parameters
-
DataType | The data type storing the bits to write. |
- Parameters
-
bits | The bits to write. |
size | The number of bits to write. |
◆ write_byte()
void fly::BitStreamWriter::write_byte |
( |
byte_type |
byte | ) |
|
Write a full byte to the byte buffer.
Flush the buffer to the stream if it is filled during this operation.
- Parameters
-
◆ write_word()
void fly::BitStreamWriter::write_word |
( |
word_type |
word | ) |
|
Write a multibyte word to the byte buffer.
Flush the buffer to the stream if it is filled during this operation.
- Parameters
-
The documentation for this class was generated from the following files: