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

📄 textfile.h

📁 unix,linux下编译。用于蛋白质
💻 H
字号:
#ifndef	TextFile_h
#define TextFile_h

#include <stdio.h>

struct TEXTFILEPOS
	{
	unsigned uOffset;
	unsigned uLineNr;
	unsigned uColNr;
	};

const unsigned TextFileBufferSize = 256;

class TextFile
	{
private:
// no default c'tor, not implemented
	TextFile();

public:
	virtual ~TextFile();

	TextFile(const char szFileName[], bool bWrite = false);
	TextFile(FILE *ptrFile, const char *ptrFileName = "-");
	void Close() { fclose(m_ptrFile); m_ptrFile = 0; }

	bool GetLine(char szLine[], unsigned uBytes);
	bool GetTrimLine(char szLine[], unsigned uBytes);
	void GetLineX(char szLine[], unsigned uBytes);

	bool GetToken(char szToken[], unsigned uBytes, const char szCharTokens[] = "{}");
	void GetTokenX(char szToken[], unsigned uBytes, const char szCharTokens[] = "{}");

	void Skip();
	void SkipLine();
	void SkipWhite();
	bool SkipWhiteX();
	void Rewind();
	TEXTFILEPOS GetPos();
	void SetPos(TEXTFILEPOS Pos);
	bool GetChar(char &c);
	void GetCharX(char &c);
	void GetNonblankChar(char &c);

	unsigned GetLineNr() { return m_uLineNr; }

	void PutString(const char szLine[]);
	void PutFormat(const char szFormat[], ...);
	void PutChar(char c);

	const char *GetFileName() { return m_ptrName; }

	void PushBack(int c) { m_cPushedBack = c; }

	FILE *GetStdioFile() const { return m_ptrFile; }

private:
	void Init(FILE *ptrFile, const char *ptrFileName);

private:
	FILE *m_ptrFile;
	unsigned m_uLineNr;
	unsigned m_uColNr;
	char *m_ptrName;
	bool m_bLastCharWasEOL;
	int m_cPushedBack;
	};

#endif // TextFile_h

⌨️ 快捷键说明

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