Output bit stream. More...
Public Member Functions | |
obitstream (FILE *file, int buffersize=DEFAULT_IOBUFFER_SIZE) | |
Start obitstream using a FILE ptr to an open file. | |
obitstream (const char *filename, int buffersize=DEFAULT_IOBUFFER_SIZE) | |
Start outputbitstream by filename. | |
void | writebits (uint32_t data, int nbits) |
Write data to the buffer. | |
void | writestring (const char *str, bool write_trailing_null=false) |
Write 8-bit character strings to the buffer. | |
template<typename T > | |
void | writeword (const T data) |
Write all the bits of a word. | |
void | write_unary (unsigned int value) |
virtual void | print () const |
Print buffer contents. | |
virtual void | close () |
Close the output stream by flushing and closing the FILE *. | |
void | windup () |
Put the current word to the buffer with upper 0 bits as needed. | |
void | flush (bool flush_trailing_bits) |
Flush the write buffer and reset for more data. |
Output bit stream.
Allows you to write data one bit at a time with buffered writing.
void obitstream::flush | ( | bool | flush_trailing_bits | ) |
Flush the write buffer and reset for more data.
Do we need to flush even the partial words, as at EOF?
References bitstream::bitptr, bitstream::buf_used, bitstream::buffer_base, bitstream::buffptr, and bitstream::fp.
Referenced by close(), and writebits().
void obitstream::writebits | ( | uint32_t | data32, | |
int | nbits | |||
) |
Write data to the buffer.
nbits | Number of bits to use | |
data | Data to write (in the lowest nbits bits). |
References bitstream::beyondbuffer, bitstream::bitptr, bitstream::Bits_per_word, bitstream::buffptr, and flush().
Referenced by mexp_golomb_write(), windup(), writestring(), and writeword().
void obitstream::writestring | ( | const char * | str, | |
bool | write_trailing_null = false | |||
) |
Write 8-bit character strings to the buffer.
str | The string to write. 0-terminated | |
write_trailing_null | Whether to put the 0 terminator to the output. |
References writebits().
void obitstream::writeword | ( | const T | data | ) | [inline] |