-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable.hpp
More file actions
59 lines (46 loc) · 1.49 KB
/
Table.hpp
File metadata and controls
59 lines (46 loc) · 1.49 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
//
// Created by Piotrek Rybiec on 05/05/2025.
//
#ifndef TABLE_H
#define TABLE_H
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "Row.hpp"
#include "Column.hpp"
#include "Constraint.hpp"
#include "CommonTypes.hpp"
class Table {
private:
std::string name_;
ColumnList columns_;
RowList rows_;
ConstraintList constraints_;
std::unordered_map<std::string, size_t> column_index_map_;
public:
explicit Table(std::string name);
Table(const std::string& name, const std::vector<Column>& columns);
void addColumn(const Column& c);
const Column& getColumn(const std::string& name) const;
const ColumnList& getColumns() const;
bool hasColumn(const std::string& name) const;
size_t getColumnIndex(const std::string& name) const;
void dropColumn(const std::string& name);
void renameColumn(const std::string& old_name, const std::string& new_name);
void addRow(const Row& r);
const RowList& getRows() const;
Row& getRow(size_t index);
size_t rowCount() const;
void addConstraint(ConstraintPtr c);
const ConstraintList& getConstraints() const;
ConstraintList getConstraintsOfType(ConstraintType t) const;
const std::string& getName() const;
void setName(std::string new_name);
bool validateRow(const Row& row) const;
void clear();
void clearRows();
ConstraintPtr getPrimaryKeyConstraint() const;
std::vector<std::string> getPrimaryKeyColumns() const;
};
#endif //TABLE_H