builder progress (attribute, object and constraint class in todo.md)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "matador/utils/basic_types.hpp"
|
||||
#include "matador/utils/constraints.hpp"
|
||||
#include "matador/utils/data_type_traits.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -23,26 +24,25 @@ private:
|
||||
std::string alias_;
|
||||
};
|
||||
|
||||
// class attribute {
|
||||
// public:
|
||||
// attribute(std::string name, const utils::basic_type type)
|
||||
// : name_(std::move(name))
|
||||
// , type_(type) {}
|
||||
//
|
||||
// [[nodiscard]] const std::string& name() const;
|
||||
// [[nodiscard]] utils::basic_type type() const;
|
||||
// [[nodiscard]] const attribute_options& options() const;
|
||||
//
|
||||
// private:
|
||||
// friend class entity;
|
||||
//
|
||||
// std::string name_;
|
||||
// std::string alias_;
|
||||
// utils::basic_type type_{};
|
||||
// attribute_options options_;
|
||||
//
|
||||
// entity* owner_{nullptr};
|
||||
// };
|
||||
class data_type {
|
||||
public:
|
||||
template<typename Type>
|
||||
data_type() : type_(utils::data_type_traits<Type>()) {}
|
||||
template<typename Type>
|
||||
explicit data_type(const size_t size) : type_(utils::data_type_traits<Type>()), size_(size) {}
|
||||
|
||||
[[nodiscard]] const utils::basic_type& type() const { return type_; }
|
||||
[[nodiscard]] size_t size() const { return size_; }
|
||||
|
||||
private:
|
||||
utils::basic_type type_{};
|
||||
size_t size_{0};
|
||||
};
|
||||
|
||||
// using BigInt = data_type<int64_t>();
|
||||
// using Real = data_type<float>;
|
||||
// using double_ = data_type<double>;
|
||||
// using string = data_type<std::string>;
|
||||
|
||||
class constraint {
|
||||
public:
|
||||
@@ -70,13 +70,17 @@ namespace matador::query {
|
||||
|
||||
class column_builder {
|
||||
public:
|
||||
explicit column_builder(std::string column_name);
|
||||
explicit column_builder(std::string column_name, utils::basic_type type, size_t size = 0);
|
||||
|
||||
// ReSharper disable once CppNonExplicitConversionOperator
|
||||
operator query::column() const; // NOLINT(*-explicit-constructor)
|
||||
|
||||
column_builder& not_null();
|
||||
|
||||
private:
|
||||
std::string column_name;
|
||||
std::string column_name_;
|
||||
utils::basic_type type_{};
|
||||
utils::constraints constraints_{};
|
||||
};
|
||||
|
||||
class table_builder {
|
||||
@@ -113,7 +117,7 @@ private:
|
||||
|
||||
constraint_builder constraint(std::string name);
|
||||
table_builder table(std::string name);
|
||||
column_builder column(std::string name);
|
||||
column_builder column(std::string name, utils::basic_type type, size_t size = 0);
|
||||
|
||||
}
|
||||
#endif //MATADOR_BUILDER_HPP
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "matador/sql/sql_functions.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -40,6 +39,7 @@ private:
|
||||
std::shared_ptr<query::table> table_;
|
||||
std::string name;
|
||||
std::string alias_;
|
||||
|
||||
sql::sql_function_t function_{sql::sql_function_t::None};
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "matador/query/table.hpp"
|
||||
#include "matador/query/query_part.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace matador::query {
|
||||
|
||||
struct query_data {
|
||||
|
||||
Reference in New Issue
Block a user