-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileReader.h
49 lines (34 loc) · 890 Bytes
/
FileReader.h
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
//
// Created by Taemin Park on 1/12/16.
//
#ifndef ADV_COMPILER_FILEREADER_H
#define ADV_COMPILER_FILEREADER_H
#include <fstream>
#include <iostream>
#include "Helper.h"
#define LINEBUFSIZE 4096
using namespace std;
class FileReader {
public:
FileReader();
~FileReader(){
_fileReader = 0;
}
static FileReader* instance();
RC openFile(const std::string &fileName);
RC closeFile();
char GetSym();
void unGetSym();
void Error(std::string errorMsg);
bool isEndOfLine(){return currentLinePosition >= currentLineSize;}
unsigned getCurrentLine(){return currentLine;};
private:
static FileReader *_fileReader;
std::fstream fileStream;
char lineBuffer[LINEBUFSIZE];
//Position information
unsigned currentLinePosition;
size_t currentLineSize;
unsigned currentLine;
};
#endif //ADV_COMPILER_FILEREADER_H