📄 tabrawbinblock.h
字号:
// tabrawbinblock.h: interface for the TABRawBinBlock class.///*--------------------------------------------------------------------- * class TABRawBinBlock * 读/写二进制块 $zgq * This is the base class used for all other data block types... it * contains all the base functions to handle binary data. *--------------------------------------------------------------------*/#ifndef TABRawBinBlock_H#define TABRawBinBlock_H#include "ugkglobal.h"class TABRawBinBlock {protected: FILE *m_fp; /* Associated file handle */ TABAccess m_eAccess; /* Read/Write access mode */ int m_nBlockType; UGKByte *m_pabyBuf; /* Buffer to contain the block's data */ int m_nBlockSize; /* Size of current block (and buffer) */ int m_nSizeUsed; /* Number of bytes used in buffer */ UGKBool m_bHardBlockSize;/* TRUE=Blocks MUST always be nSize bytes */ /* FALSE=last block may be less than nSize */ int m_nFileOffset; /* Location of current block in the file */ int m_nCurPos; /* Next byte to read from m_pabyBuf[] */ int m_nFirstBlockPtr;/* Size of file header when different from */ /* block size (used by GotoByteInFile()) */ //第一个块在文件中的位置 有可能并不是从0开始 int m_bModified; /* Used only to detect changes */public: TABRawBinBlock(TABAccess eAccessMode = TABRead, UGKBool bHardBlockSize = TRUE); virtual ~TABRawBinBlock(); virtual int ReadFromFile(FILE *fpSrc, int nOffset, int nSize = 512); virtual int CommitToFile(); virtual int InitBlockFromData(UGKByte *pabyBuf, int nSize, UGKBool bMakeCopy = TRUE, FILE *fpSrc = NULL, int nOffset = 0); virtual int InitNewBlock(FILE *fpSrc, int nBlockSize, int nFileOffset=0); int GetBlockType(); virtual int GetBlockClass() { return TAB_RAWBIN_BLOCK; }; UGKInt32 GetStartAddress() {return m_nFileOffset;}; virtual void Dump(FILE *fpOut = NULL); int GotoByteRel(int nOffset); int GotoByteInBlock(int nOffset); int GotoByteInFile(int nOffset); void SetFirstBlockPtr(int nOffset); int GetNumUnusedBytes(); int GetFirstUnusedByteOffset(); int GetCurAddress(); virtual int ReadBytes(int numBytes, UGKByte *pabyDstBuf); UGKByte ReadByte(); UGKInt16 ReadInt16(); UGKInt32 ReadInt32(); float ReadFloat(); double ReadDouble(); virtual int WriteBytes(int nBytesToWrite, UGKByte *pBuf); int WriteByte(UGKByte byValue); int WriteInt16(UGKInt16 n16Value); int WriteInt32(UGKInt32 n32Value); int WriteFloat(float fValue); int WriteDouble(double dValue); int WriteZeros(int nBytesToWrite); int WritePaddedString(int nFieldSize, const char *pszString); void SetModifiedFlag(UGKBool bModified) {m_bModified=bModified;}; UGKByte * GetCurDataPtr() { return (m_pabyBuf + m_nCurPos); } ;};TABRawBinBlock *TABCreateMAPBlockFromFile(FILE *fpSrc, int nOffset, int nSize = 512, UGKBool bHardBlockSize = TRUE, TABAccess eAccessMode = TABRead);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -