#ifndef QUERY_COLUMN_DEFINITION_HPP #define QUERY_COLUMN_DEFINITION_HPP #include "matador/utils/basic_types.hpp" #include "matador/utils/default_type_traits.hpp" #include "matador/utils/field_attributes.hpp" #include #include namespace matador::object { enum class null_option_type : uint8_t { Nullable, NotNull }; class object; class attribute_generator; class attribute { public: explicit attribute(std::string name); // NOLINT(*-explicit-constructor) attribute(const attribute&) = default; attribute& operator=(const attribute&) = default; attribute(attribute&&) noexcept = default; attribute& operator=(attribute&&) noexcept = default; attribute() = default; attribute(std::string name, utils::basic_type type, const utils::field_attributes &attr = utils::null_attributes, null_option_type null_opt = null_option_type::NotNull); [[nodiscard]] const std::string& name() const; void name(const std::string& n); [[nodiscard]] std::string full_name() const; [[nodiscard]] const utils::field_attributes& attributes() const; [[nodiscard]] utils::field_attributes& attributes(); [[nodiscard]] bool is_nullable() const; [[nodiscard]] utils::basic_type type() const; [[nodiscard]] std::shared_ptr owner() const; 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(attr.size()); } [[nodiscard]] bool is_integer() const; [[nodiscard]] bool is_floating_point() const; [[nodiscard]] bool is_bool() const; [[nodiscard]] bool is_string() const; [[nodiscard]] bool is_varchar() const; [[nodiscard]] bool is_date() const; [[nodiscard]] bool is_time() const; [[nodiscard]] bool is_blob() const; [[nodiscard]] bool is_null() const; template< typename Type > [[nodiscard]] bool is_type_of() const { return type() == utils::data_type_traits::type(attributes().size()); } friend std::ostream& operator<<(std::ostream& os, const attribute& attr); private: friend class object; friend class attribute_generator; friend class object_generator; std::string name_; std::shared_ptr owner_; utils::basic_type type_{utils::basic_type::Null}; utils::field_attributes options_{}; null_option_type null_option_{null_option_type::NotNull}; }; } #endif //QUERY_COLUMN_DEFINITION_HPP