⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileopt.h

📁 设计模式:工厂模式、单例模式的基本实现
💻 H
字号:
#ifndef _FILEOPT_H
#define _FILEOPT_H

#include <fstream>
using namespace std;

class CFileOpt
{
private:
	fstream m_pFile;
	string m_strFileName;
	bool m_bRead;

	CFileOpt();
	~CFileOpt();

	int Init(string strFileName, bool bRead, bool bBinary = true);
	void FInit();

public:
	static CFileOpt* NewObj(string strFileName, bool bRead, bool bBinary = true);
	static void DelObj(CFileOpt* pObj);
	int WriteLine(string strText);

	bool IsRead(){return m_bRead;}
	CFileOpt& operator<<(int nIn);
	CFileOpt& operator<<(float fIn);
	CFileOpt& operator<<(double dIn);
	CFileOpt& operator<<(char chIn);
	CFileOpt& operator<<(string strIn);

	CFileOpt& operator>>(int &nIn);
	CFileOpt& operator>>(float &fIn);
	CFileOpt& operator>>(double &dIn);
	CFileOpt& operator>>(char &chIn);
	CFileOpt& operator>>(string &strIn);
};

#endif

⌨️ 快捷键说明

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