-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.cpp
57 lines (44 loc) · 1.21 KB
/
database.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
#include "database.h"
namespace db{
database::database(){}
database::database(std::string name) : db_name(name){}
table database::operator[](int x){
return t[x];
}
std::string database::name(){
return db_name;
}
void database::set_name(std::string name){
db_name = name;
}
std::vector<table> database::tables(){
return t;
}
bool database::is_public(){
return ispub;
}
void database::make_public(){
ispub = true;
}
void database::make_private(){
ispub = false;
}
bool database::create_table(std::string name, std::vector<std::string> cn, std::vector<std::string> ct){
for (int i = 0; i < (int)t.size(); i++){
if (name == t[i].table_name()){
return false;
}
}
t.push_back(table(name, cn, ct));
return true;
}
bool database::drop_table(std::string name){
for (int i = 0; i < (int)t.size(); i++){
if (name == t[i].table_name()){
t.erase(t.begin() + i);
return true;
}
}
return false;
}
}