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