-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharff_scanner.h
More file actions
executable file
·110 lines (87 loc) · 2.38 KB
/
Copy patharff_scanner.h
File metadata and controls
executable file
·110 lines (87 loc) · 2.38 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef __INCLUDED_ARFF_SCANNER_H__
#define __INCLUDED_ARFF_SCANNER_H__
/**
* @file arff_scanner.h
* @brief Contains the 'ArffScanner' class
*/
#include <stdio.h>
#include <string>
#include "arff_utils.h"
/**
* @class ArffScanner arff_scanner.h
* @brief Class responsible for reading the 'arff' file
*
* This class assumes linux-style newlines!
*/
class ArffScanner
{
public:
/**
* @brief Constructor
* @param _file file to be read
*/
ArffScanner(const std::string& _file);
/**
* @brief Destructor
*/
~ArffScanner();
/**
* @brief Return the next character in the stream
* @return character
*/
char next();
/**
* @brief Returns the currently read char from the file
* @return current character
*/
char current() const;
/**
* @brief Returns the previously read char from the file
* @return previous character
*/
char previous() const;
/**
* @brief Returns the current line position
* @return current line
*/
int64 line() const;
/**
* @brief Returns the current column position
* @return current column
*/
int64 column() const;
/**
* @brief Whether the file has reached end or not
* @return true if end-of-file, else false
*/
bool eof() const;
/**
* @brief Give a nice error message along with file,line,col info
* @param msg actual error message to be prepended with the above info
* @return prepended 'meaningful' error message
*/
std::string err_msg(const std::string& msg) const;
/**
* @brief Checks whether the given character is newline or not
* @param c the character
* @return true if the character is newline, else false
*/
bool is_newline(char c) const;
/** new-line character */
static const char NEWLINE;
private:
/** file being read */
std::string m_file;
/** current line being read */
int64 m_line;
/** current position in the row being read */
int64 m_col;
/** current character read from the file */
char m_char;
/** previous character read from the file */
char m_prev_char;
/** file pointer */
FILE* m_fp;
};
/* DO NOT WRITE ANYTHING BELOW THIS LINE!!! */
#endif // __INCLUDED_ARFF_SCANNER_H__