1#ifndef DATABASE_DATABASE_H
2#define DATABASE_DATABASE_H
12static const FilePath DATABASE_DIRECTORY{
13 std::filesystem::path(getenv(
"HOME")) /
".vkdb"
22 using size_type = uint64_t;
23 using error_callback = std::function<void(
Token,
const std::string&)>;
24 using runtime_error_callback = std::function<void(
const RuntimeError&)>;
109 void dropTable(const TableName& table_name);
124 [[nodiscard]] DatabaseName
name() const noexcept;
131 [[nodiscard]] FilePath
path() const noexcept;
138 [[nodiscard]]
std::vector<TableName>
tables() const noexcept;
149 const
std::
string& source,
150 std::ostream& stream =
std::cout
163 std::ostream& stream =
std::cout
179 using TableMap =
std::unordered_map<TableName,
Table>;
188 void error(
Token token, const
std::
string& message) noexcept;
207 const
std::
string& where,
208 const
std::
string& message
242 bool had_runtime_error_;
248 error_callback callback_;
254 runtime_error_callback runtime_callback_;
Represents a database in vkdb.
Table & getTable(const TableName &table_name)
Get the Table object.
Database()=delete
Deleted default constructor.
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 & runFile(const std::filesystem::path path, std::ostream &stream=std::cout) noexcept
Run a file.
void clear()
Clear the database.
Database(Database &&) noexcept=default
Move-construct a new Database object.
void dropTable(const TableName &table_name)
Drop the Table object.
Database & runPrompt() noexcept
Run the prompt.
DatabaseName name() const noexcept
Get the name of the database.
Database & run(const std::string &source, std::ostream &stream=std::cout) noexcept
Run a source string.
Table & createTable(const TableName &table_name)
Create a Table object.
Represents a table in vkdb.
static void error(Token token, const std::string &message) noexcept
Handle an error.
static void runtimeError(const RuntimeError &error) noexcept
Handle a runtime error.