11#if __has_include("defs.h") 
   21  bitstream (std::iostream& str, 
unsigned int pack);
 
   27  int read (
size_t sz, 
bool is_signed = 
false);
 
   30  void write (
bool val);
 
   33  void write (
int val, 
size_t sz);
 
   42  virtual char encode (
unsigned char bits);
 
   45  virtual unsigned char decode (
char chr);
 
   60  return (bits & (1 << 
packing) - 1);
 
 
   70  return (chr & (1 << 
packing) - 1);
 
 
Read and write bit fields.
 
virtual unsigned char decode(char chr)
Decode bit field from a byte.
Definition bitstream.h:68
 
const unsigned int packing
number of used bits per byte
Definition bitstream.h:38
 
std::iostream & s
underlining (byte) stream
Definition bitstream.h:39
 
bitstream(std::iostream &str, unsigned int pack)
Constructor.
Definition bitstream.cpp:26
 
void write(bool val)
Write a bit to stream.
Definition bitstream.cpp:64
 
virtual char encode(unsigned char bits)
Encode bit field in a byte.
Definition bitstream.h:58
 
void flush()
If there are any leftover bits, encode them in one character and write them out to stream.
Definition bitstream.cpp:83
 
bool read()
Read the next bit.
Definition bitstream.cpp:41