-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.cpp
54 lines (49 loc) · 1.1 KB
/
index.cpp
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
#include "index.h"
index::index() {
key = "-"; //* é usado na remoção, trocar um dos
pos = 0;
//bytes = 0;
}
index::index(char* input) {
key = strtok(input, "_");
pos = std::stoi(strtok(NULL, "_"));
}
index::index(std::string& input) {
std::stringstream s(input);
std::string temp;
std::getline(s, temp, '_');
key = temp;
std::getline(s, temp);
pos = std::stoi(temp);
}
index::~index() {
//
}
index::index(char* input, int tell) {
std::stringstream s(input);
std::string temp;
pos = tell;
//s.seekg(0, std::ios::end);
//bytes = s.tellg();
//s.seekg(0, std::ios::beg);
getline(s, temp, ';');
key = temp;
}
index::index(std::string input, int tell) {
pos = tell;
key = input;
}
std::ostream& operator <<(std::ostream& out, const index& i) {
out << i.key << '_' << i.pos;
return out;
}
std::istream& operator >>(std::istream& in, index& i) {
in >> i.key;
in >> i.pos;
//i.bytes = (1 + i.key.length() + sizeof(i.pos)); //likely wrong
return in;
}
bool operator ==(const index& l, const index& r) {
if (l.key == r.key and l.pos == r.pos /*and l.bytes == r.bytes*/) { return true; }
return false;
}