Wrapper for output streams that provides bitwise writing functionality.
More...
#include <BitOStream.hpp>
Wrapper for output streams that provides bitwise writing functionality.
Bits are written into a buffer byte, which is written to the output when it is either filled or when a flush is explicitly requested.
Definition at line 17 of file BitOStream.hpp.
◆ BitOStream() [1/2]
Constructs a bitwise output stream.
- Parameters
-
output | The underlying output stream. |
Definition at line 43 of file BitOStream.hpp.
◆ BitOStream() [2/2]
tdc::io::BitOStream::BitOStream |
( |
Output & |
output | ) |
|
|
inline |
Constructs a bitwise output stream.
- Parameters
-
output | The underlying output. |
Definition at line 50 of file BitOStream.hpp.
◆ ~BitOStream()
tdc::io::BitOStream::~BitOStream |
( |
| ) |
|
|
inline |
◆ tellp()
auto tdc::io::BitOStream::tellp |
( |
| ) |
-> decltype(m_stream.tellp()) |
|
inline |
Returns the output position indicator of the underlying stream, which should equal the amount of bytes written to it.
Note that this value does not include bits that have not yet been flushed.
- Returns
- the output position indicator of the underlying stream
Definition at line 73 of file BitOStream.hpp.
◆ write_bit()
void tdc::io::BitOStream::write_bit |
( |
bool |
set | ) |
|
|
inline |
Writes a single bit to the output.
- Parameters
-
set | The bit value (0 or 1). |
Definition at line 79 of file BitOStream.hpp.
◆ write_compressed_int()
template<typename T >
void tdc::io::BitOStream::write_compressed_int |
( |
T |
v, |
|
|
size_t |
b = 7 |
|
) |
| |
|
inline |
Writes a compressed integer to the input.
The compressed form of an integer n
is achieved by splitting up the bit representation of n
in blocks of width b
. For each non-zero block (in little endian order), a bit flag and the block itself is written.
The flag is set to 1 if there is another block after the current one, and otherwise set to 0 to mark the block as the last one.
- Template Parameters
-
The | integer type to write. |
- Parameters
-
v | The integer to write. |
b | The block width in bits. The default is 7 bits. |
Definition at line 151 of file BitOStream.hpp.
◆ write_elias_delta()
template<typename value_t >
void tdc::io::BitOStream::write_elias_delta |
( |
value_t |
v | ) |
|
|
inline |
◆ write_elias_gamma()
template<typename value_t >
void tdc::io::BitOStream::write_elias_gamma |
( |
value_t |
v | ) |
|
|
inline |
◆ write_int()
template<class T >
void tdc::io::BitOStream::write_int |
( |
T |
value, |
|
|
size_t |
bits = sizeof(T) * CHAR_BIT |
|
) |
| |
|
inline |
Writes the bit representation of an integer in MSB first order to the output.
- Template Parameters
-
The | type of integer to write. |
- Parameters
-
value | The integer to write. |
bits | The amount of low bits of the value to write. By default, this equals the bit width of type T . |
Definition at line 98 of file BitOStream.hpp.
◆ write_ternary()
template<typename value_t >
void tdc::io::BitOStream::write_ternary |
( |
value_t |
v | ) |
|
|
inline |
◆ write_unary()
template<typename value_t >
void tdc::io::BitOStream::write_unary |
( |
value_t |
v | ) |
|
|
inline |
The documentation for this class was generated from the following file: