-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilePosition.cpp
More file actions
50 lines (49 loc) · 1.07 KB
/
FilePosition.cpp
File metadata and controls
50 lines (49 loc) · 1.07 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
#include "FilePosition.hpp"
FilePosition::FilePosition() {
line = 1;
col = 1;
}
FilePosition::FilePosition(unsigned int l, unsigned int c) {
line = l;
col = c;
}
std::vector<unsigned int> FilePosition::getAbsolute() {
return std::vector<unsigned int>(line, col);
}
unsigned int FilePosition::getLine(){
return line;
}
unsigned int FilePosition::getCol(){
return col;
}
void FilePosition::setLine(unsigned int l) {
line = l;
}
void FilePosition::setCol(unsigned int pos) {
col = pos;
}
unsigned int FilePosition::operator++(int) {
col++;
return this->col;
}
void FilePosition::newLine() {
col = 1;
line++;
}
std::string FilePosition::toString() {
std::stringstream ss;
ss << "[" << line << ", " << col << "]";
return ss.str();
}
bool FilePosition::operator==(FilePosition rhs) {
if (this->line == rhs.line &&
this->col == rhs.col
) return true;
return false;
}
bool FilePosition::operator!=(FilePosition rhs) {
if (this->line != rhs.line ||
this->col != rhs.col
) return true;
return false;
}