1/*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef BIT_BUFFER_H
6#define BIT_BUFFER_H
7
8
9#include <SupportDefs.h>
10
11#include <Array.h>
12
13
14class BitBuffer {
15public:
16								BitBuffer();
17								~BitBuffer();
18
19			bool				AddBytes(const void* data, size_t size);
20			bool				AddBits(const void* data, uint64 bitSize,
21									uint32 bitOffset = 0);
22			bool				AddZeroBits(uint64 bitSize);
23
24			uint8*				Bytes() const	{ return fBytes.Elements(); }
25			size_t				Size() const	{ return fBytes.Size(); }
26			size_t				BitSize() const
27									{ return Size() * 8 - fMissingBits; }
28
29private:
30			struct BitReader;
31
32private:
33			Array<uint8>		fBytes;
34			uint8				fMissingBits;
35};
36
37
38#endif	// BIT_BUFFER_H
39