#pragma once

#include <vector>

using namespace std;

class BitStream
{
public:
	BitStream(int bitSize = 0);
	BitStream(vector<unsigned char>& buf, int bitSize);
	

	bool Create(int sizeInBits);
	void Attach(vector<unsigned char>& 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<unsigned char> m_buf;
	int m_bufBits;
	int m_currentBitIndex;
};
