-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabase.hpp
More file actions
40 lines (32 loc) · 993 Bytes
/
Database.hpp
File metadata and controls
40 lines (32 loc) · 993 Bytes
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
#ifndef DATABASE_H
#define DATABASE_H
#include <string>
#include "CommonTypes.hpp"
class Database {
private:
std::string name_;
TablePtrMap tables_;
public:
Database(std::string name) : name_(name) {
if (name_.empty()) {
throw std::runtime_error("database name cannot be empty");
}
};
Database(std::string& name) : name_(std::move(name)) {
if (name_.empty()) {
throw std::runtime_error("database name cannot be empty");
}
};
~Database() = default;
void addTable(TablePtr table);
bool dropTable(const std::string& name);
TablePtr getTable(const std::string& name) const;
bool tableExists(const std::string& name) const;
const std::string& getName() const;
void setName(std::string new_name);
std::vector<std::string> getTableNames() const;
// adds db context
bool validateRow(const std::string& table_name, const Row& row);
void clear();
};
#endif //DATABASE_H