|
vkdb
A time series database engine in C++.
|
Represents a database in vkdb. More...
#include <database.h>
Public Types | |
| using | size_type = uint64_t |
| using | error_callback = std::function<void(Token, const std::string&)> |
| using | runtime_error_callback = std::function<void(const RuntimeError&)> |
Public Member Functions | |
| Database ()=delete | |
| Deleted default constructor. | |
| Database (DatabaseName name, error_callback error=VQ::error, runtime_error_callback runtime_error=VQ::runtimeError) | |
| Construct a new Database object. | |
| Database (Database &&) noexcept=default | |
| Move-construct a new Database object. | |
| Database & | operator= (Database &&) noexcept=default |
| Move-assign a new Database object. | |
| Database (const Database &)=delete | |
| Deleted copy constructor. | |
| Database & | operator= (const Database &)=delete |
| Deleted copy assignment operator. | |
| ~Database () noexcept=default | |
| Destroy the Database object. | |
| Table & | createTable (const TableName &table_name) |
| Create a Table object. | |
| Table & | getTable (const TableName &table_name) |
| Get the Table object. | |
| void | dropTable (const TableName &table_name) |
| Drop the Table object. | |
| void | clear () |
| Clear the database. | |
| DatabaseName | name () const noexcept |
| Get the name of the database. | |
| FilePath | path () const noexcept |
| Get the path to the database directory. | |
| std::vector< TableName > | tables () const noexcept |
| Get the names of the tables in the database. | |
| Database & | run (const std::string &source, std::ostream &stream=std::cout) noexcept |
| Run a source string. | |
| Database & | runFile (const std::filesystem::path path, std::ostream &stream=std::cout) noexcept |
| Run a file. | |
| Database & | runPrompt () noexcept |
| Run the prompt. | |
Represents a database in vkdb.
Definition at line 20 of file database.h.
| using vkdb::Database::error_callback = std::function<void(Token, const std::string&)> |
Definition at line 23 of file database.h.
| using vkdb::Database::runtime_error_callback = std::function<void(const RuntimeError&)> |
Definition at line 24 of file database.h.
| using vkdb::Database::size_type = uint64_t |
Definition at line 22 of file database.h.
|
explicit |
Construct a new Database object.
The constructor will load the database if it exists.
| name | Name of the database. |
| error | Error callback. |
| runtime_error | Runtime error callback. |
| std::runtime_error | If loading the database fails. |
Definition at line 8 of file database.cpp.
| void vkdb::Database::clear | ( | ) |
Clear the database.
Removes the database directory and all its contents.
| std::runtime_error | If the database directory cannot be removed. |
Definition at line 51 of file database.cpp.
| Table & vkdb::Database::createTable | ( | const TableName & | table_name | ) |
Create a Table object.
Inserts new Table object into the table map and creates the directory for the table.
| table_name | Name of the table. |
| std::runtime_error | If the table already exists. |
Definition at line 21 of file database.cpp.
| void vkdb::Database::dropTable | ( | const TableName & | table_name | ) |
Drop the Table object.
Removes the table directory and erases the table from the table map.
| table_name | Name of the table. |
| std::runtime_error | If the table does not exist. |
Definition at line 41 of file database.cpp.
|
nodiscard |
Get the Table object.
| table_name | Name of the table. |
| std::runtime_error | If the table does not exist. |
Definition at line 32 of file database.cpp.
|
nodiscardnoexcept |
Get the name of the database.
Definition at line 55 of file database.cpp.
|
nodiscardnoexcept |
Get the path to the database directory.
Definition at line 59 of file database.cpp.
|
noexcept |
Run a source string.
The source string is lexed, parsed, and interpreted.
| source | Source string. |
| stream | Output stream. |
Definition at line 68 of file database.cpp.
|
noexcept |
Run a file.
The file is read, lexed, parsed, and interpreted.
| path | Path to the file. |
| stream | Output stream. |
Definition at line 92 of file database.cpp.
|
noexcept |
Run the prompt.
The user can enter queries and commands interactively.
Definition at line 122 of file database.cpp.
|
nodiscardnoexcept |
Get the names of the tables in the database.
Definition at line 63 of file database.cpp.