File: textfile.h

package info (click to toggle)
muscle 3.52-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,196 kB
  • ctags: 1,763
  • sloc: cpp: 21,335; xml: 185; makefile: 104
file content (68 lines) | stat: -rw-r--r-- 1,512 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#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 = "-");

	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();
	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