#ifndef QUERY_SCHEMA_HPP #define QUERY_SCHEMA_HPP #include "matador/sql/column_generator.hpp" #include "matador/sql/record.hpp" #include #include #include #include namespace matador::sql { class connection; struct table_info { std::string name; record prototype; void create(connection &conn) const; void drop(connection &conn) const; }; class schema { public: using repository = std::unordered_map; using iterator = repository::iterator; using const_iterator = repository::const_iterator; std::string name() const; template const table_info& attach(const std::string &table_name) { return attach(std::type_index(typeid(Type)), table_info{table_name, record{column_generator::generate(*this)}}); } const table_info& attach(std::type_index ti, const table_info& table); template [[nodiscard]] std::optional info() const { return info(std::type_index(typeid(Type))); } [[nodiscard]] std::optional info(std::type_index ti) const; template [[nodiscard]] std::pair reference() const { return reference(std::type_index(typeid(Type))); } [[nodiscard]] std::pair reference(const std::type_index &ti) const; template [[nodiscard]] bool exists() const { return exists(std::type_index(typeid(Type))); } [[nodiscard]] bool exists(const std::type_index &ti) const; iterator begin(); [[nodiscard]] const_iterator begin() const; iterator end(); [[nodiscard]] const_iterator end() const; [[nodiscard]] bool empty() const; private: std::string name_; repository repository_; }; } #endif //QUERY_SCHEMA_HPP