-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColumn.hpp
More file actions
40 lines (33 loc) · 1.01 KB
/
Column.hpp
File metadata and controls
40 lines (33 loc) · 1.01 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
//
// Created by Piotrek Rybiec on 04/05/2025.
//
#ifndef COLUMN_H
#define COLUMN_H
#include <utility>
#include "data_types.hpp"
#include "Constraint.hpp"
class Column {
private:
std::string name;
DataType type;
std::vector<std::shared_ptr<Constraint>> constraints;
public:
Column() = default;
Column(std::string name, DataType type)
: name(std::move(name)),
type(type) {}
Column(std::string name, DataType type, bool nullable) : name(std::move(name)), type(type) {
if (!nullable) {
addConstraint(std::make_shared<NotNullConstraint>(ConstraintType::NOT_NULL, name + "_not_null", name));
}
}
void addConstraint(const std::shared_ptr<Constraint>& constraint);
bool isPrimaryKey() const;
bool isUnique() const;
bool isNullable() const;
const std::string& getName() const;
DataType getType() const;
const std::vector<std::shared_ptr<Constraint>>& getConstraints() const;
void setName(std::string new_name);
};
#endif //COLUMN_H