Subversion Repositories spk

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 cycrow 1
/***************************************************************************** 
2
 
3
  ByteReader
4
  ----------
5
 
6
  Class making your life easier if you have to read single bits from a buffer
7
 
8
  by yoda
9
 
10
  WWW:      y0da.cjb.net
11
  E-mail:   LordPE@gmx.net
12
 
13
  You are allowed to use this class in your own projects if you keep this
14
  trademark.
15
 
16
*****************************************************************************/
17
 
18
#pragma once
19
 
20
#include <windows.h>
21
 
22
//
23
// ByteReader class
24
//
25
class ByteReader
26
{
27
public:
28
	ByteReader(void);
29
	ByteReader( void* pBuff, DWORD dwSize );
30
	~ByteReader(void);
31
 
32
	void    InitVars();
33
	BOOL    Assign( void *pBuff, DWORD dwSize );
34
	DWORD   GetUnusedBitCount();
35
	DWORD   GetTotalBitCount();
36
	DWORD   GetReadByteCount();
37
	BYTE    ReadBit();
38
	BYTE    ReadByte();
39
	WORD    ReadWord();
40
	DWORD   ReadDword();
41
	DWORD   ReadBits( DWORD dwBitCount );
42
 
43
protected:
44
	void*          pBuffer;
45
	DWORD          cbBuffer, dwBitsLeft, dwBitsTotal, dwIndex;
46
	BYTE           byCur;
47
	BYTE           byBits2Do;
48
};
49
 
50
typedef ByteReader *PByteReader;