bytewriter.h

来自「This is a little console mode utility pr」· C头文件 代码 · 共 55 行

H
55
字号
/***************************************************************************** 

  ByteWriter
  ----------

  Revisions: 002

  Class making your life easier if you have to write single bits to a buffer

  by yoda

  WWW:      y0da.cjb.net
  E-mail:   LordPE@gmx.net

  You are allowed to use this class in your own projects if you keep this
  trademark.

*****************************************************************************/

#pragma once

#include <windows.h>

//
// ByteWriter class
//
class ByteWriter
{
public:
	__declspec( property( get=GetWrittenByteCount ) ) DWORD m_cbWritten;

	ByteWriter(void);
	ByteWriter( void* pBuff, DWORD dwSize );
	~ByteWriter(void);

	void    InitVars();
	BOOL    Assign( void *pBuff, DWORD dwSize );
	DWORD   GetUnusedBitCount();
	DWORD   GetTotalBitCount();
	DWORD   GetWrittenByteCount();
	void    FinishWriting();
	BOOL    WriteBit( DWORD bit );
	BOOL    WriteByte( BYTE byte );
	BOOL    WriteWord( WORD word );
	BOOL    WriteDword( DWORD dword );
	BOOL    WriteBits( DWORD bits, DWORD dwBitCount );

protected:
	void*          pBuffer;
	DWORD          cbBuffer, dwBitsLeft, dwBitsTotal, dwIndex;
	BYTE           byCur;
	BYTE           byBits2Do;
};

typedef ByteWriter *PByteWriter;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?