-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.cpp
More file actions
59 lines (48 loc) · 1.12 KB
/
parser.cpp
File metadata and controls
59 lines (48 loc) · 1.12 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
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
vector<string> split(string data, string token)
{
vector<string> output;
size_t pos = string::npos; // size_t to avoid improbable overflow
do
{
pos = data.find(token);
output.push_back(data.substr(0, pos));
if (string::npos != pos)
data = data.substr(pos + token.size());
} while (string::npos != pos);
return output;
}
typedef vector<string> vectorstr;
int main () {
ifstream prob("Testcase.txt");
string buff;
vector<vectorstr> hasilParse;
if (prob.is_open()) {
prob >> buff; //READ
if (buff == "Ruangan") { //PARSE RUANGAN
prob >> buff;
while (buff.compare("Jadwal") != 0) {
hasilParse.push_back(split(buff, ";"));
prob >> buff;
}
}
do { //PARSE JADWAL
prob >> buff;
// cout << buff << endl;
hasilParse.push_back(split(buff, ";"));
} while (!prob.eof());
}
for (int i = 0; i < hasilParse.size(); ++i)
{
for (int j = 0; j < hasilParse[i].size(); ++j)
{
cout << hasilParse[i][j] << endl;
}
}
prob.close();
return 0;
}