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

📄 iokit.h

📁 粗糙集应用软件
💻 H
字号:
//-------------------------------------------------------------------
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================

#ifndef __IOKIT_H__
#define __IOKIT_H__

#include <copyright.h>

#include <kernel/system/stdlib.h>

#include <kernel/basic/types.h>

//-------------------------------------------------------------------
// Class prototypes.
//===================================================================

class fstream;
class ifstream;
class ofstream;
class String;

//-------------------------------------------------------------------
// Class.........: IOKit
// Author........: Aleksander 豩rn
// Date..........:
// Description...:
// Revisions.....:
//===================================================================

class IOKit {
protected:

	//- Static variables...............................................
	static unsigned int  buffersize_; // The size of the buffer.
	static char         *buffer_;     // The buffer itself.

protected:

	//- Buffer methods.................................................
	static bool          AllocateBuffer(unsigned int buffersize);

public:

	//- Buffer methods.................................................
	static unsigned int  GetBuffersize() {return buffersize_;}
	static bool          SetBuffersize(unsigned int buffersize) {return AllocateBuffer(buffersize);}

	//- Initialization.................................................
	static bool          Open(ifstream &stream, const String &filename);
	static bool          Open(ofstream &stream, const String &filename, bool append = false);

	//- Cleaning up....................................................
	static bool          Close(ifstream &stream);
	static bool          Close(ofstream &stream);

  //- Load from stream...............................................
  static bool          Load(ifstream &stream, String &string, bool delimiters = true);
  static bool          Load(ifstream &stream, int &i, bool delimiters = true);
#if 1
  static bool          Load(ifstream &stream, bool &b, bool delimiters = true);
#endif
  static bool          Load(ifstream &stream, float &f, bool delimiters = true);
  static bool          Load(ifstream &stream, char &c, bool delimiters = true);

	static bool          LoadLine(ifstream &stream, String &line, int *counter = NULL, char symbol = '%', bool trim = true);

  //- Save to stream.................................................
  static bool          Save(ofstream &stream, const String &string, bool delimiters = true);
  static bool          Save(ofstream &stream, int i, bool delimiters = true);
  static bool          Save(ofstream &stream, unsigned int i, bool delimiters = true);
#if 1
  static bool          Save(ofstream &stream, bool b, bool delimiters = true);
#endif
  static bool          Save(ofstream &stream, float f, bool delimiters = true);
  static bool          Save(ofstream &stream, char c, bool delimiters = true);

	//- Querying.......................................................
	static bool          Exists(const String &filename);
	static bool          IsEOF(ifstream &stream);
	static bool          IsOpen(fstream &stream);

};

#endif

⌨️ 快捷键说明

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