#pragma once #include using namespace std; class BitStream { public: BitStream(int bitSize = 0); BitStream(vector& buf, int bitSize); bool Create(int sizeInBits); void Attach(vector& buf, int sizeInBits); int Read(void *bitPtr, int countInBits); int Write(const void * bitPtr, int countInBits); int Seek(int offset, bool relative = false); int GetSize(); void ZeroPadToNextByte(); void * GetBuffer(int * sizeInBits = NULL); void ReleaseBuffer(int bitCount); void Clear(); protected: vector m_buf; int m_bufBits; int m_currentBitIndex; };