#include #ifndef BITSTREAM #define BITSTREAM class ibitstream { private: // read bits from byte int count; // last byte from stream uint8_t cache; // Input stream std::basic_istream &is; public: ibitstream(std::basic_istream &is) : count(-1), cache('\0'), is(is) {}; // Get n bits from stream; at most - 32 int getbits(size_t n); }; class obitstream { private: // written bits to byte int count; // last byte from stream uint8_t cache; std::basic_ostream &os; public: obitstream(std::basic_ostream &os) : count(0), cache(0), os(os) {}; // Get n bits from stream; at most - 32 void writebits(short bits, size_t n); void flush(); }; #endif