mcrl2::utilities::obitstream

Include file:

#include "mcrl2/utilities/bitstream.h
class mcrl2::utilities::obitstream

A bitstream provides per bit writing of data to any stream (including stdout).

Internally uses bitpacking and buffering for compact and efficient IO.

Private attributes

unsigned int mcrl2::utilities::obitstream::bits_in_buffer

how many bits in are used in the buffer.

std::uint8_t mcrl2::utilities::obitstream::integer_buffer

Reserved space to store an n byte integer.

std::ostream &mcrl2::utilities::obitstream::stream
std::bitset<128> mcrl2::utilities::obitstream::write_buffer

Buffer that is filled starting from bit 127 when writing.

Public member functions

obitstream(std::ostream &stream)

Provides the stream on which the write function operate.

void write_bits(std::size_t value, unsigned int num_of_bits)

Write the num_of_bits least significant bits in descending order from value.

Parameters:

  • value Variable that contains the bits.
  • num_of_bits Number of bits to write to the output stream.
void write_integer(std::size_t value)

Write the given value to the output stream.

Uses most significant bit encoding.

void write_string(const std::string &string)

Write the given string to the output stream.

Encoded in bits using <length, string>

~obitstream()

Private member functions

void flush()

Flush the remaining bits in the buffer to the output stream.

Note that this aligns it to the next byte, e.g. when bits_in_buffer is 6 then two zero bits are added redundantly.

void write(const std::uint8_t *buffer, std::size_t size)

Writes size bytes from the given buffer.