object generating progress
This commit is contained in:
@@ -23,7 +23,6 @@ class attribute_generator;
|
||||
|
||||
class attribute {
|
||||
public:
|
||||
explicit attribute(const char *name); // NOLINT(*-explicit-constructor)
|
||||
explicit attribute(std::string name); // NOLINT(*-explicit-constructor)
|
||||
|
||||
attribute(const attribute&) = default;
|
||||
@@ -35,24 +34,8 @@ public:
|
||||
attribute(std::string name,
|
||||
utils::basic_type type,
|
||||
const utils::field_attributes&,
|
||||
null_option_type null_opt,
|
||||
int index = 0);
|
||||
attribute(std::string name,
|
||||
utils::basic_type type,
|
||||
int index,
|
||||
const std::shared_ptr<attribute> &ref_column,
|
||||
const utils::field_attributes& attr,
|
||||
null_option_type null_opt);
|
||||
|
||||
attribute(std::string name,
|
||||
utils::basic_type type,
|
||||
const std::shared_ptr<attribute> &ref_column = {});
|
||||
attribute(std::string name,
|
||||
utils::basic_type type,
|
||||
std::string table_name,
|
||||
const attribute_options& options,
|
||||
const std::shared_ptr<attribute> &ref_column = {});
|
||||
|
||||
[[nodiscard]] const std::string& name() const;
|
||||
void name(const std::string& n);
|
||||
[[nodiscard]] std::string full_name() const;
|
||||
@@ -61,15 +44,14 @@ public:
|
||||
[[nodiscard]] utils::field_attributes& attributes();
|
||||
[[nodiscard]] bool is_nullable() const;
|
||||
[[nodiscard]] utils::basic_type type() const;
|
||||
[[nodiscard]] const std::string& table_name() const;
|
||||
void table_name(const std::string& name);
|
||||
[[nodiscard]] object* owner() const;
|
||||
// [[nodiscard]] const std::string& table_name() const;
|
||||
// void table_name(const std::string& name);
|
||||
void change_type(utils::basic_type type, const utils::field_attributes &attr = utils::null_attributes);
|
||||
template < typename Type >
|
||||
void change_type(const utils::field_attributes &attr = utils::null_attributes) {
|
||||
type_ = utils::data_type_traits<Type>::type(attr.size());
|
||||
}
|
||||
[[nodiscard]] std::shared_ptr<attribute> reference_column() const;
|
||||
[[nodiscard]] bool is_foreign_reference() const;
|
||||
|
||||
[[nodiscard]] bool is_integer() const;
|
||||
[[nodiscard]] bool is_floating_point() const;
|
||||
@@ -92,11 +74,8 @@ private:
|
||||
|
||||
std::string name_;
|
||||
object *owner_{nullptr};
|
||||
std::string table_name_;
|
||||
attribute_options options_;
|
||||
utils::basic_type type_{utils::basic_type::type_null};
|
||||
|
||||
std::shared_ptr<attribute> reference_column_;
|
||||
};
|
||||
|
||||
|
||||
@@ -108,62 +87,62 @@ private:
|
||||
* @param null_opt
|
||||
* @return A column object with a given name
|
||||
*/
|
||||
attribute make_column(const std::string &name, utils::basic_type type, utils::field_attributes attr = utils::null_attributes, null_option_type null_opt = null_option_type::NOT_NULL);
|
||||
|
||||
template < typename Type >
|
||||
attribute make_column(const std::string &name, utils::field_attributes attr = utils::null_attributes, null_option_type null_opt = null_option_type::NOT_NULL)
|
||||
{
|
||||
return make_column(name, utils::data_type_traits<Type>::type(0), attr, null_opt);
|
||||
}
|
||||
template <>
|
||||
attribute make_column<std::string>(const std::string &name, utils::field_attributes attr, null_option_type null_opt);
|
||||
|
||||
template < typename Type >
|
||||
attribute make_pk_column(const std::string &name, size_t size = 0)
|
||||
{
|
||||
return make_column<Type>(name, { size, utils::constraints::PrimaryKey });
|
||||
}
|
||||
|
||||
template <>
|
||||
attribute make_pk_column<std::string>(const std::string &name, size_t size);
|
||||
|
||||
template < typename Type >
|
||||
attribute make_fk_column(const std::string &name, size_t size, const std::shared_ptr<attribute> &ref_column) {
|
||||
return {name, utils::data_type_traits<Type>::type(size), ref_column, { size, utils::constraints::ForeignKey }};
|
||||
}
|
||||
|
||||
template < typename Type >
|
||||
[[maybe_unused]] attribute make_fk_column(const std::string &name, const std::shared_ptr<attribute> &ref_column)
|
||||
{
|
||||
return {name, utils::data_type_traits<Type>::type(0), 0, ref_column, { 0, utils::constraints::ForeignKey }, null_option_type::NOT_NULL};
|
||||
}
|
||||
|
||||
template <>
|
||||
[[maybe_unused]] attribute make_fk_column<std::string>(const std::string &name, size_t size, const std::shared_ptr<attribute> &ref_column);
|
||||
|
||||
template < typename Type >
|
||||
[[maybe_unused]] attribute make_fk_column(const std::string &name, size_t size, const std::string &ref_table_name, const std::string &ref_column_name) {
|
||||
return {
|
||||
name, utils::data_type_traits<Type>::type(size), 0,
|
||||
std::make_shared<attribute>(ref_column_name, ref_table_name, utils::data_type_traits<Type>::type(size), utils::constraints::ForeignKey),
|
||||
{ 0, utils::constraints::ForeignKey }, null_option_type::NOT_NULL
|
||||
};
|
||||
}
|
||||
|
||||
template < typename Type >
|
||||
[[maybe_unused]] attribute make_fk_column(const std::string &name, const std::string &ref_table_name, const std::string &ref_column_name) {
|
||||
return {
|
||||
name, utils::data_type_traits<Type>::type(0), 0,
|
||||
std::make_shared<attribute>(ref_column_name, utils::data_type_traits<Type>::type(0), ref_table_name, attribute_options{utils::constraints::ForeignKey}),
|
||||
{ 0, utils::constraints::ForeignKey }, null_option_type::NOT_NULL
|
||||
};
|
||||
}
|
||||
|
||||
template <>
|
||||
[[maybe_unused]] attribute make_fk_column<std::string>(const std::string &name, const std::string &ref_table_name, const std::string &ref_column_name);
|
||||
|
||||
template <>
|
||||
[[maybe_unused]] attribute make_fk_column<std::string>(const std::string &name, size_t size, const std::string &ref_table_name, const std::string &ref_column_name);
|
||||
// attribute make_column(const std::string &name, utils::basic_type type, utils::field_attributes attr = utils::null_attributes, null_option_type null_opt = null_option_type::NOT_NULL);
|
||||
//
|
||||
// template < typename Type >
|
||||
// attribute make_column(const std::string &name, utils::field_attributes attr = utils::null_attributes, null_option_type null_opt = null_option_type::NOT_NULL)
|
||||
// {
|
||||
// return make_column(name, utils::data_type_traits<Type>::type(0), attr, null_opt);
|
||||
// }
|
||||
// template <>
|
||||
// attribute make_column<std::string>(const std::string &name, utils::field_attributes attr, null_option_type null_opt);
|
||||
//
|
||||
// template < typename Type >
|
||||
// attribute make_pk_column(const std::string &name, size_t size = 0)
|
||||
// {
|
||||
// return make_column<Type>(name, { size, utils::constraints::PrimaryKey });
|
||||
// }
|
||||
//
|
||||
// template <>
|
||||
// attribute make_pk_column<std::string>(const std::string &name, size_t size);
|
||||
//
|
||||
// template < typename Type >
|
||||
// attribute make_fk_column(const std::string &name, size_t size, const std::shared_ptr<attribute> &ref_column) {
|
||||
// return {name, utils::data_type_traits<Type>::type(size), ref_column, { size, utils::constraints::ForeignKey }};
|
||||
// }
|
||||
//
|
||||
// template < typename Type >
|
||||
// [[maybe_unused]] attribute make_fk_column(const std::string &name, const std::shared_ptr<attribute> &ref_column)
|
||||
// {
|
||||
// return {name, utils::data_type_traits<Type>::type(0), 0, ref_column, { 0, utils::constraints::ForeignKey }, null_option_type::NOT_NULL};
|
||||
// }
|
||||
//
|
||||
// template <>
|
||||
// [[maybe_unused]] attribute make_fk_column<std::string>(const std::string &name, size_t size, const std::shared_ptr<attribute> &ref_column);
|
||||
//
|
||||
// template < typename Type >
|
||||
// [[maybe_unused]] attribute make_fk_column(const std::string &name, size_t size, const std::string &ref_table_name, const std::string &ref_column_name) {
|
||||
// return {
|
||||
// name, utils::data_type_traits<Type>::type(size), 0,
|
||||
// std::make_shared<attribute>(ref_column_name, ref_table_name, utils::data_type_traits<Type>::type(size), utils::constraints::ForeignKey),
|
||||
// { 0, utils::constraints::ForeignKey }, null_option_type::NOT_NULL
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// template < typename Type >
|
||||
// [[maybe_unused]] attribute make_fk_column(const std::string &name, const std::string &ref_table_name, const std::string &ref_column_name) {
|
||||
// return {
|
||||
// name, utils::data_type_traits<Type>::type(0), 0,
|
||||
// std::make_shared<attribute>(ref_column_name, utils::data_type_traits<Type>::type(0), ref_table_name, attribute_options{utils::constraints::ForeignKey}),
|
||||
// { 0, utils::constraints::ForeignKey }, null_option_type::NOT_NULL
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// template <>
|
||||
// [[maybe_unused]] attribute make_fk_column<std::string>(const std::string &name, const std::string &ref_table_name, const std::string &ref_column_name);
|
||||
//
|
||||
// template <>
|
||||
// [[maybe_unused]] attribute make_fk_column<std::string>(const std::string &name, size_t size, const std::string &ref_table_name, const std::string &ref_column_name);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user