xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
TableManager.h
Go to the documentation of this file.
1#ifndef TABLE_MANAGER_H
2#define TABLE_MANAGER_H
3
8
9#include <cstring>
10#include <fstream>
11
12#include <memory>
13
14namespace Xale::Execution
15{
17 {
18 public:
20 Xale::DataStructure::Table* createTable(const std::string& name);
21 bool dropTable(const std::string& name);
22 Xale::DataStructure::Table* getTable(const std::string& name);
23 bool tableExists(const std::string& name) const;
24 std::vector<std::string> getTableNames() const;
25
26 void saveAllTables();
27 void loadAllTables();
28
29 private:
31 Xale::Storage::IFileManager& _fileManager;
32 std::unordered_map<std::string, std::unique_ptr<Xale::DataStructure::Table>> _tables;
33
34 void saveTable(const Xale::DataStructure::Table& table);
35 void loadTable(const std::string& tableName, const std::vector<char>& data);
36 };
37}
38
39#endif // TABLE_MANAGER_H
Mutable and persistent dataset.
Definition Table.h:17
bool tableExists(const std::string &name) const
Checks if a table with the given name exists.
Definition TableManager.cpp:71
Xale::DataStructure::Table * createTable(const std::string &name)
Creates a new table with the given name.
Definition TableManager.cpp:21
std::vector< std::string > getTableNames() const
Retrieves the names of all existing tables.
Definition TableManager.cpp:80
bool dropTable(const std::string &name)
Drops the table with the given name.
Definition TableManager.cpp:40
TableManager(Xale::Storage::IStorageEngine &storage, Xale::Storage::IFileManager &fileManager)
Constructor for TableManager.
Definition TableManager.cpp:10
Xale::DataStructure::Table * getTable(const std::string &name)
Retrieves the table with the given name.
Definition TableManager.cpp:56
void saveAllTables()
Save all tables to disk File format: [4 bytes: table_count] For each table: [4 bytes: table_name_leng...
Definition TableManager.cpp:100
void loadAllTables()
Load all tables from disk File format: [4 bytes: table_count] For each table: [4 bytes: table_name_le...
Definition TableManager.cpp:167
Interface for file management operations.
Definition IFileManager.h:13
Interface for storage engine operations.
Definition IStorageEngine.h:12
Definition BasicExecutor.h:13