-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibrary_main.cpp
59 lines (56 loc) · 1.65 KB
/
library_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
#include "library.h"
#include <iostream>
int main()
{
char choice;
Lib lib;
std::unordered_map<std::string, std::vector<std::string>> dbmap;
dbmap = lib.read_DBFiles();
while (true)
{
std::cout << "+-----------------------------------+" << std::endl;
std::cout << "|Main menu (enter a number below) |" << std::endl;
std::cout << "|-----------------------------------|" << std::endl;
std::cout << "|0. Exit |" << std::endl;
std::cout << "|1. Create Table |" << std::endl;
std::cout << "|2. Drop Table |" << std::endl;
std::cout << "|3. Insert Records |" << std::endl;
std::cout << "|4. Delete Records |" << std::endl;
std::cout << "|5. Display Records |" << std::endl;
std::cout << "|6. Show All Schema |" << std::endl;
std::cout << "+-----------------------------------+" << std::endl;
std::cin >> choice;
switch (choice)
{
case '0':
std::cout << "purging begins..." << std::endl;
lib.write_DBFiles(dbmap);
std::cout << "purge file is done!" << std::endl;
return 0;
case '1':
dbmap = lib.createTable(dbmap);
lib.write_DBFiles(dbmap);
continue;
case '2':
dbmap = lib.dropTable(dbmap);
lib.write_DBFiles(dbmap);
continue;
case '3':
dbmap = lib.insertRecords(dbmap);
continue;
case '4':
lib.removeRecords(dbmap);
continue;
case '5':
lib.displayTable(dbmap);
continue;
case '6':
lib.showSchema(dbmap);
continue;
default:
std::cout << "Error: invalid! please input an integer(0,1,2,3,4,5,6)" << std::endl;
continue;
}
}
return 0;
}