-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtableManager.cpp
More file actions
58 lines (46 loc) · 1.16 KB
/
tableManager.cpp
File metadata and controls
58 lines (46 loc) · 1.16 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
//
// Created by Ignacio Mora on 6/16/17.
//
#include "tableManager.h"
TableManager::TableManager() {
}
Table TableManager::getTable(std::string name) {
int i;
for (i = 0; i < tableList.size(); i++){
if (tableList[i].getName() == name)
return tableList[i];
}
return Table();
}
bool TableManager::addTable(Table table) {
if (!exists(table.getName())) {
tableList.push_back(table);
return true;
}
return false;
}
bool TableManager::exists(std::string name) {
int i;
for (i = 0; i < tableList.size(); i++){
if (tableList[i].getName() == name)
return true;
}
return false;
}
int TableManager::deleteTable(std::string name) {
int rowsAffected = 0;
if (exists(name)){
int i;
for(i = 0; i < tableList.size(); i++){
if (tableList[i].getName() == name){
break;
}
}
rowsAffected = tableList[i].getTotalRows();
tableList.erase(tableList.begin() + i);
}
return rowsAffected;
}
void TableManager::updateRow(std::string name, std::vector<std::string> row) {
getTable(name).insertRow(row);
}