-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdriver.cpp
More file actions
73 lines (71 loc) · 2.6 KB
/
driver.cpp
File metadata and controls
73 lines (71 loc) · 2.6 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "./utils/IndexList.h"
#include "./utils/IndexList.cpp"
#include "./constants/checkQuery.cpp"
#include "./constants/tokenizeQuery.cpp"
#include "./utils/TableRecord.cpp"
#include "./utils/TableList.cpp"
#include "./src/import.cpp"
#include "./src/select.cpp"
#include "./src/insert.cpp"
#include "./src/delete.cpp"
void syntaxHelpMenu(){
cout << "Syntax Help" << endl;
cout << endl;
cout << "IMPORT Query" << endl;
cout << "\t Import <file_name>.csv;" << endl;
cout << endl;
cout << "SELECT Query" << endl;
cout << "\t Select * from <table_name> [Where] [column_name] [operation] [value];" << endl;
cout << "\t OPTION" << endl;
cout << "\t\t WHERE => It can be used only on any one column." << endl;
cout << "\t\t OPERATION => Valid operations are {=, !=, >, <, <=, >=}" << endl;
cout << endl;
cout << "INSERT Query" << endl;
cout << "\t Insert into <table_name> values (data...);" << endl;
cout << "\t DESCRIPTION" << endl;
cout << "\t\t DATA => It is comma separated string of the data to be inserted. DO NOT leave a space in the paranthesis." << endl;
cout << endl;
cout << "DELETE Query" << endl;
cout << "\t Delete from <table_name> [Where] [column_name] [operation] [value];" << endl;
cout << "\t OPTION" << endl;
cout << "\t\t WHERE => It can be used only on any one column." << endl;
cout << "\t\t OPERATION => Valid operations are {=, !=, >, <, <=, >=}" << endl;
cout << endl;
}
int main(){
cout << "Welcome to EL.db" << endl;
cout << "EL.db v1.0.0" << endl;
cout << "Enter \\h for help and \\q to quit." << endl;
TableList table = TableList();
char query[500];
while(true){
cout << "EL.db> ";
cin.getline(query, 500);
string str_query = (string)query;
if(str_query == "\\q"){
break;
}
else if(str_query == "\\h"){
syntaxHelpMenu();
}
else if(checkImportQuery(str_query)){
handleImportQuery(str_query,&table);
}
else if(checkSelectQuery(str_query)){
handleSelectQuery(str_query);
}
else if(checkInsertQuery(str_query)){
handleInsertQuery(str_query,&table);
}
else if(checkDeleteQuery(str_query)){
handleDeleteQuery(str_query);
}
else{
cout << "Error: Something wrong with your query. Please check the syntax." << endl;
}
}
cout << "********************************" <<endl;
cout << "* THANK YOU :) *" << endl;
cout << "********************************" <<endl;
return 0;
}