Hyper API for C++  0.0.17231
Hyper client library for C++ applications
Catalog.hpp
Go to the documentation of this file.
1 
5 #ifndef TABLEAU_HYPER_CATALOG_HPP
6 #define TABLEAU_HYPER_CATALOG_HPP
7 
10 #include <hyperapi/impl/infra.hpp>
11 #include <hyperapi/hyperapi.h>
12 
13 #include <string>
14 #include <unordered_set>
15 
16 namespace hyperapi {
17 
18 class Connection;
19 
31 class Catalog final {
32  private:
37  explicit Catalog(Connection& connection) noexcept;
38 
39  public:
40  Catalog(const Catalog&) = delete;
41  Catalog& operator=(const Catalog&) = delete;
42  Catalog(Catalog&&) = delete;
43  Catalog operator=(Catalog&&) = delete;
44 
53  bool hasTable(const TableName& table) const;
54 
65  TableDefinition getTableDefinition(const TableName& tableName) const;
66 
74  void createSchema(const SchemaName& schemaName) const;
75 
83  void createSchemaIfNotExists(const SchemaName& schemaName) const;
84 
92  void createTable(const hyperapi::TableDefinition& table_definition) const;
93 
101  void createTableIfNotExists(const hyperapi::TableDefinition& table_definition) const;
102 
112  std::unordered_set<SchemaName> getSchemaNames() const;
113 
121  std::unordered_set<SchemaName> getSchemaNames(const DatabaseName& database) const;
122 
132  std::unordered_set<TableName> getTableNames(const SchemaName& schema) const;
133 
142  void createDatabase(const std::string& databasePath);
143 
153  void createDatabaseIfNotExists(const std::string& databasePath);
154 
161  void detachDatabase(const DatabaseName& databaseName);
162 
170  void attachDatabase(const std::string& databasePath, const DatabaseName& databaseName);
171 
179  void attachDatabase(const std::string& databasePath);
180 
190  void detachAllDatabases();
191 
203  void dropDatabase(const std::string& databasePath);
204 
216  void dropDatabaseIfExists(const std::string& databasePath);
217 
221  Connection& getConnection() const noexcept { return m_connection; }
222 
223  private:
225  Connection& m_connection;
226 
227  friend class Connection;
228 };
229 }
230 
231 #endif
hyperapi::Catalog::createSchemaIfNotExists
void createSchemaIfNotExists(const SchemaName &schemaName) const
Creates a SQL schema with the given name.
hyperapi::Catalog::createTable
void createTable(const hyperapi::TableDefinition &table_definition) const
Creates a SQL table with the given table definition.
hyperapi::Catalog::getConnection
Connection & getConnection() const noexcept
Returns the underlying connection.
Definition: Catalog.hpp:221
hyperapi::Catalog::getTableDefinition
TableDefinition getTableDefinition(const TableName &tableName) const
Gets the table definition for an existing table.
hyperapi::Catalog::dropDatabase
void dropDatabase(const std::string &databasePath)
Drops the database with the given path.
hyperapi::TableDefinition
A table definition.
Definition: TableDefinition.hpp:44
HyperException.hpp
TableDefinition.hpp
hyperapi::Catalog::getTableNames
std::unordered_set< TableName > getTableNames(const SchemaName &schema) const
Gets the names of all tables in the given schema.
hyperapi::Catalog::attachDatabase
void attachDatabase(const std::string &databasePath, const DatabaseName &databaseName)
Attaches a database file databasePath to the underlying connection under the name databaseName.
hyperapi::Catalog
The catalog class gives access to the metadata of the attached databases of a connection.
Definition: Catalog.hpp:31
hyperapi::Connection
Defines a Hyper connection.
Definition: Connection.hpp:42
hyperapi::Catalog::getSchemaNames
std::unordered_set< SchemaName > getSchemaNames() const
Gets the name of all schemas in the first database in the database search path.
hyperapi::Catalog::dropDatabaseIfExists
void dropDatabaseIfExists(const std::string &databasePath)
Drops the database with the given path.
hyperapi
The primary namespace of the Hyper API for C++.
Definition: ByteSpan.hpp:15
hyperapi::Catalog::detachAllDatabases
void detachAllDatabases()
Detaches all databases from the underlying connection.
hyperapi::Catalog::createDatabase
void createDatabase(const std::string &databasePath)
Creates a database file with the given path.
hyperapi::Catalog::createTableIfNotExists
void createTableIfNotExists(const hyperapi::TableDefinition &table_definition) const
Creates a SQL table with the given table definition.
hyperapi::SchemaName
Represents an escaped SQL schema name.
Definition: SchemaName.hpp:13
hyperapi::Catalog::hasTable
bool hasTable(const TableName &table) const
Checks whether a table with the given name exists.
hyperapi::Catalog::createDatabaseIfNotExists
void createDatabaseIfNotExists(const std::string &databasePath)
Creates a database file with the given path if it doesn't exist yet.
hyperapi::Catalog::detachDatabase
void detachDatabase(const DatabaseName &databaseName)
Detaches a database from the underlying connection.
hyperapi::TableName
Represents an escaped SQL table name.
Definition: TableName.hpp:15
hyperapi::Catalog::createSchema
void createSchema(const SchemaName &schemaName) const
Creates a SQL schema with the given name.
hyperapi::DatabaseName
Represents an escaped SQL database name.
Definition: DatabaseName.hpp:12