2005-07-31 06:07:48 +00:00
|
|
|
#ifndef _INCLUDE_BINARY_H
|
|
|
|
#define _INCLUDE_BINARY_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "compat.h"
|
2005-08-01 19:56:54 +00:00
|
|
|
#include "amxxmodule.h"
|
2005-07-31 06:07:48 +00:00
|
|
|
|
|
|
|
class BinaryReader
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BinaryReader(FILE *fp);
|
|
|
|
//~BinaryReader();
|
|
|
|
public:
|
2008-03-04 19:06:39 +00:00
|
|
|
bool ReadUInt32(uint32_t& num);
|
|
|
|
bool ReadInt32(int32_t& num);
|
|
|
|
bool ReadUInt16(uint16_t& num);
|
|
|
|
bool ReadInt16(int16_t& num);
|
|
|
|
bool ReadUInt8(uint8_t& num);
|
|
|
|
bool ReadInt8(int8_t& num);
|
|
|
|
bool ReadChars(char buffer[], size_t chars);
|
2005-07-31 06:07:48 +00:00
|
|
|
private:
|
|
|
|
bool ReadAddr(void *buffer, size_t size);
|
|
|
|
private:
|
|
|
|
FILE *m_Fp;
|
|
|
|
};
|
|
|
|
|
|
|
|
class BinaryWriter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BinaryWriter() { m_Fp = NULL; }
|
|
|
|
BinaryWriter(FILE *fp);
|
|
|
|
public:
|
|
|
|
void SetFilePtr(FILE *fp) { m_Fp = fp; }
|
2008-03-04 19:06:39 +00:00
|
|
|
bool WriteUInt32(uint32_t num);
|
|
|
|
bool WriteInt32(int32_t num);
|
|
|
|
bool WriteUInt16(uint16_t num);
|
|
|
|
bool WriteInt16(int16_t num);
|
|
|
|
bool WriteUInt8(uint8_t num);
|
|
|
|
bool WriteInt8(int8_t num);
|
|
|
|
bool WriteChars(const char buffer[], size_t chars);
|
2005-07-31 06:07:48 +00:00
|
|
|
private:
|
|
|
|
bool WriteAddr(void *buffer, size_t size);
|
|
|
|
private:
|
|
|
|
FILE *m_Fp;
|
|
|
|
};
|
|
|
|
|
2005-08-02 09:48:06 +00:00
|
|
|
#endif //_INCLUDE_BINARY_H
|
|
|
|
|