📄 archive.h
字号:
/////////////////////////////////////////////////////////////////////////////
// Name: archive.h
// Copyright: wellgain
// Author: bet
// Date: 2003-10-10
// Description: the interface for class CArchive
/////////////////////////////////////////////////////////////////////////////
#ifndef _WG_ARCHIVE_H_
#define _WG_ARCHIVE_H_
#include <stdio.h>
/////////////////////////////////////////////////////////////////////////////
#define NO_ERROR 0
#define ERR_EOF -1
typedef unsigned int UINT;
//归档类
class CArchive
{
public:
enum Mode { store = 0, load = 1 };
enum seek_dir { beg=SEEK_SET, cur=SEEK_CUR, end=SEEK_END };
CArchive(FILE* pFile, CArchive::Mode nMode);
~CArchive();
// Attributes
inline bool IsLoading() const { return (m_nMode==load); }
inline bool IsStoring() const { return (m_nMode!=load); }
inline FILE* GetFile() const { return m_pFile; }
// Operations
UINT Read(void* lpBuf, UINT nLen);
UINT Write(const void* lpBuf, UINT nLen);
void WriteCount(UINT nCount);
UINT ReadCount();
void WriteString(char* lpsz);
char* ReadString(char* lpsz, UINT nMax);
long Tell() const;
void Flush();
int Seek(long offset, CArchive::seek_dir dir);
void Close();
// error operations
inline void Clear() { m_nErrorNo = NO_ERROR; }
inline int GetErrorNo() const { return m_nErrorNo; }
// ! operation, means are there errors
inline bool operator! () const { return (m_nErrorNo!=NO_ERROR); }
inline operator void *() const
{ if(m_nErrorNo==NO_ERROR) return (void*)this; return 0; }
// insertion operations
CArchive& operator<<(char ch);
CArchive& operator<<(bool b);
CArchive& operator<<(int i);
CArchive& operator<<(long l);
CArchive& operator<<(float f);
CArchive& operator<<(double d);
// extraction operations
CArchive& operator>>(char& ch);
CArchive& operator>>(bool& b);
CArchive& operator>>(int& i);
CArchive& operator>>(long& l);
CArchive& operator>>(float& f);
CArchive& operator>>(double& d);
protected:
CArchive();
// archive objects cannot be copied or assigned
CArchive(const CArchive& arSrc);
void operator=(const CArchive& arSrc);
private:
UINT m_nMode;
FILE* m_pFile;
int m_nErrorNo;
};
#endif //_WG_ARCHIVE_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -