Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 244 | chris | 1 | #ifndef __BUFFER_H__ |
| 2 | #define __BUFFER_H__ |
||
| 3 | |||
| 4 | #include <string> |
||
| 5 | #include "Common.h" |
||
| 6 | |||
| 7 | namespace Sexy |
||
| 8 | { |
||
| 9 | |||
| 10 | typedef std::vector<uchar> ByteVector; |
||
| 11 | |||
| 12 | class Buffer |
||
| 13 | { |
||
| 14 | public: |
||
| 15 | ByteVector mData; |
||
| 16 | int mDataBitSize; |
||
| 17 | mutable int mReadBitPos; |
||
| 18 | mutable int mWriteBitPos; |
||
| 19 | |||
| 20 | public: |
||
| 21 | Buffer(); |
||
| 22 | virtual ~Buffer(); |
||
| 23 | |||
| 24 | void SeekFront() const; |
||
| 25 | void Clear(); |
||
| 26 | |||
| 27 | void FromWebString(const std::string& theString); |
||
| 28 | void WriteByte(uchar theByte); |
||
| 29 | void WriteNumBits(int theNum, int theBits); |
||
| 30 | static int GetBitsRequired(int theNum, bool isSigned); |
||
| 31 | void WriteBoolean(bool theBool); |
||
| 32 | void WriteShort(short theShort); |
||
| 33 | void WriteLong(long theLong); |
||
| 34 | void WriteString(const std::string& theString); |
||
| 35 | void WriteUTF8String(const std::wstring& theString); |
||
| 36 | void WriteLine(const std::string& theString); |
||
| 37 | void WriteBuffer(const ByteVector& theBuffer); |
||
| 38 | void WriteBytes(const uchar* theByte, int theCount); |
||
| 39 | void SetData(const ByteVector& theBuffer); |
||
| 40 | void SetData(uchar* thePtr, int theCount); |
||
| 41 | |||
| 42 | std::string ToWebString() const; |
||
| 43 | std::wstring UTF8ToWideString() const; |
||
| 44 | uchar ReadByte() const; |
||
| 45 | int ReadNumBits(int theBits, bool isSigned) const; |
||
| 46 | bool ReadBoolean() const; |
||
| 47 | short ReadShort() const; |
||
| 48 | long ReadLong() const; |
||
| 49 | std::string ReadString() const; |
||
| 50 | std::wstring ReadUTF8String() const; |
||
| 51 | std::string ReadLine() const; |
||
| 52 | void ReadBytes(uchar* theData, int theLen) const; |
||
| 53 | void ReadBuffer(ByteVector* theByteVector) const; |
||
| 54 | |||
| 55 | const uchar* GetDataPtr() const; |
||
| 56 | int GetDataLen() const; |
||
| 57 | int GetDataLenBits() const; |
||
| 58 | ulong GetCRC32(ulong theSeed = 0) const; |
||
| 59 | |||
| 60 | bool AtEnd() const; |
||
| 61 | bool PastEnd() const; |
||
| 62 | }; |
||
| 63 | |||
| 64 | } |
||
| 65 | |||
| 66 | #endif //__BUFFER_H__ |