forked from cheyuanl/json_query_cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
30 lines (25 loc) · 737 Bytes
/
main.cpp
File metadata and controls
30 lines (25 loc) · 737 Bytes
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
#include <iostream>
#include <string>
#include "graph_storage.hpp"
using namespace std;
int main() {
unique_ptr<Storage> js(new GraphStorage());
string line;
while (getline(cin, line)) {
size_t space_pos = line.find(" ");
const string &op = line.substr(0, space_pos);
const string &data = line.substr(space_pos + 1, line.size());
if (op == "get") {
for (const string &s : js->get(data)) {
cout << s << endl;
}
} else if (op == "add") {
js->add(data);
} else if (op == "delete") {
js->del(data);
} else {
throw invalid_argument("Invalid input format.");
}
}
return 0;
}