File: Buffer.h

package info (click to toggle)
libtuxcap 1.4.0.dfsg2-1.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,172 kB
  • ctags: 5,897
  • sloc: cpp: 43,203; ansic: 3,095; python: 774; objc: 242; makefile: 100; xml: 87
file content (67 lines) | stat: -rw-r--r-- 1,760 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef __BUFFER_H__
#define __BUFFER_H__

#include <string>
#include "Common.h"

namespace Sexy
{

typedef std::vector<uchar> ByteVector;

class Buffer
{
public:
	ByteVector				mData;
	int						mDataBitSize;
	mutable int				mReadBitPos;
	mutable int				mWriteBitPos;	

public:
	Buffer();
	virtual ~Buffer();
			
	void					SeekFront() const;
	void					Clear();

	void					FromWebString(const std::string& theString);
	void					WriteByte(uchar theByte);
	void					WriteNumBits(int theNum, int theBits);
	static int				GetBitsRequired(int theNum, bool isSigned);
	void					WriteBoolean(bool theBool);
	void					WriteShort(short theShort);
	void					WriteLong(int32_t theLong);
	void					WriteString(const std::string& theString);
	void					WriteUTF8String(const std::wstring& theString);
	void					WriteLine(const std::string& theString);	
	void					WriteBuffer(const ByteVector& theBuffer);
	void					WriteBytes(const uchar* theByte, int theCount);
	void					SetData(const ByteVector& theBuffer);
	void					SetData(uchar* thePtr, int theCount);

	std::string				ToWebString() const;
	std::wstring			UTF8ToWideString() const;
	uchar					ReadByte() const;
	int						ReadNumBits(int theBits, bool isSigned) const;
	bool					ReadBoolean() const;
	short					ReadShort() const;
	int32_t					ReadLong() const;
	std::string				ReadString() const;	
	std::wstring			ReadUTF8String() const;
	std::string				ReadLine() const;
	void					ReadBytes(uchar* theData, int theLen) const;
	void					ReadBuffer(ByteVector* theByteVector) const;

	const uchar*			GetDataPtr() const;
	int						GetDataLen() const;	
	int						GetDataLenBits() const;
	uint32_t					GetCRC32(uint32_t theSeed = 0) const;

	bool					AtEnd() const;
	bool					PastEnd() const;
};

}

#endif //__BUFFER_H__