attribute_definition and object_definition progress

This commit is contained in:
Sascha Kühl
2025-11-17 15:58:09 +01:00
parent 9ffcee1317
commit 7242dc2612
17 changed files with 161 additions and 205 deletions
+6 -17
View File
@@ -3,22 +3,13 @@
#include "matador/utils/value.hpp"
#include "matador/utils/basic_types.hpp"
#include "matador/utils/constraints.hpp"
#include <optional>
#include <string>
namespace matador::utils {
enum class constraints : unsigned char;
}
namespace matador::sql {
enum struct field_type {
Attribute,
PrimaryKey,
ForeignKey
};
/**
*
*/
@@ -26,12 +17,12 @@ class field {
public:
explicit field(std::string name);
template<typename Type>
field(std::string name, Type value, const field_type type = field_type::Attribute, const size_t size = 0, const int index = -1)
field(std::string name, Type value, const utils::constraints type = utils::constraints::NONE, const size_t size = 0, const int index = -1)
: name_(std::move(name))
, type_(type)
, index_(index)
, value_(value, size) {}
field(std::string name, utils::basic_type dt, field_type type = field_type::Attribute, size_t size = 0, int index = -1);
field(std::string name, utils::basic_type dt, utils::constraints type = utils::constraints::NONE, size_t size = 0, int index = -1);
field(const field &x) = default;
field& operator=(const field &x) = default;
field(field &&x) noexcept;
@@ -45,7 +36,7 @@ public:
}
[[nodiscard]] const std::string& name() const;
[[nodiscard]] field_type type() const;
[[nodiscard]] utils::constraints type() const;
[[nodiscard]] size_t size() const;
[[nodiscard]] int index() const;
@@ -71,18 +62,16 @@ public:
friend std::ostream& operator<<(std::ostream &out, const field &col);
private:
static utils::constraints determine_constraint(field_type type);
template<class Operator>
void process(Operator &op) {
op.on_attribute(name_.c_str(), value_, { value_.size(), determine_constraint(type_) } );
op.on_attribute(name_.c_str(), value_, { value_.size(), type_ } );
}
private:
friend class record;
std::string name_;
field_type type_{field_type::Attribute};
utils::constraints type_{utils::constraints::NONE};
int index_{-1};
utils::value value_;