-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
71 lines (68 loc) · 2.1 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
//#include <boost/variant.hpp>
#include "source/TableNode.h"
using namespace std;
//using namespace boost;
//
int main() {
auto* globalPtr = new TableNode();
while (globalPtr != nullptr) {
char nextChar;
cin >> nextChar;
if (nextChar == '{') {
globalPtr = globalPtr->addChild();
} else if (nextChar == '}') {
globalPtr = globalPtr->deleteSelf();
} else if (nextChar == 'a') {
string id;
cout << "Please Id : ";
cin >> id;
int* valuePtr = globalPtr->addChar(id);
if(valuePtr == nullptr){
cout<<"Redefined"<<endl;
continue;
}
cout << "Location is : " << valuePtr << endl;
cout << "Value is : " << *valuePtr << endl;
} else if (nextChar == 'm') {
string id;
int value;
cout << "Please Id : ";
cin >> id;
cout << "Please input value : ";
cin >> value;
int *valuePtr = globalPtr->modifyValue(id, value);
if (valuePtr == nullptr) {
cout << "Not define yet" << endl;
continue;
}
cout << "Location is : " << valuePtr << endl;
cout << "Value is : " << *valuePtr << endl;
}
else if(nextChar == 's'){
string id;
cout << "Please Id : ";
cin >> id;
int *valuePtr = globalPtr->isHave(id);
if (valuePtr == nullptr) {
cout << "Not define" << endl;
continue;
}
cout << "Location is : " << valuePtr << endl;
cout << "Value is : " << *valuePtr << endl;
}
}
delete globalPtr;
return 0;
}
//int main(){
// variant<int, string> data;
// data = 5;
//// data = "56";
//// cout<<*get<string>(&data)<<endl;
//// cout<<data<<endl;
// cout<<get<string>(&data)<<endl;
//// assert(get<string>(&data));
// cout<<(typeid(5)==typeid(int))<<endl;
// cout<<(typeid(data)==typeid(int))<<endl;
//}