#include "matador/object/attribute.hpp" #include "matador/object/object.hpp" #include #include namespace matador::object { attribute::attribute(std::string name) : attribute(std::move(name), utils::basic_type::Null, {}, null_option_type::NotNull) { } attribute::attribute(std::string name, const utils::basic_type type, const utils::field_attributes &attr, const null_option_type null_opt) : name_(std::move(name)) , type_(type) , options_(attr) , null_option_(null_opt) {} const std::string &attribute::name() const { return name_; } void attribute::name( const std::string& n ) { name_ = n; } std::string attribute::full_name() const { return owner_ ? owner_->name() + "." + name_ : name_; } const utils::field_attributes &attribute::attributes() const { return options_; } utils::field_attributes& attribute::attributes() { return options_; } bool attribute::is_nullable() const { return null_option_ == null_option_type::Nullable; } utils::basic_type attribute::type() const { return type_; } object* attribute::owner() const { return owner_; } void attribute::change_type(const utils::basic_type type, const utils::field_attributes& attr) { options_ = attr; type_ = type; } bool attribute::is_integer() const { return type_ >= utils::basic_type::Int8 && type_ <= utils::basic_type::UInt64; } bool attribute::is_floating_point() const { return type_ == utils::basic_type::Float || type_ == utils::basic_type::Double; } bool attribute::is_bool() const { return type_ == utils::basic_type::Boolean; } bool attribute::is_string() const { return type_ == utils::basic_type::Text; } bool attribute::is_varchar() const { return type_ == utils::basic_type::Varchar; } bool attribute::is_date() const { return type_ == utils::basic_type::Date; } bool attribute::is_time() const { return type_ == utils::basic_type::Time; } bool attribute::is_blob() const { return type_ == utils::basic_type::Blob; } bool attribute::is_null() const { return type_ == utils::basic_type::Null; } std::ostream & operator<<(std::ostream &os, const attribute &attr) { os << attr.name_; return os; } }