26#ifndef SQLITE_HAS_CODEC
27#define SQLITE_HAS_CODEC
35#include <unordered_map>
37#include <sqlcipher/sqlite3.h>
75 const std::filesystem::path&
getPath()
const;
93 bool unlock(
const std::string& password);
108 bool exec(
const std::string& command);
140 operator bool()
const;
143 mutable std::mutex m_mutex;
144 std::filesystem::path m_path;
147 std::shared_ptr<sqlite3> m_database;
149 std::unordered_map<std::string, SqliteCustomFunction> m_custom;
A sqlite function context.
Definition sqlcontext.h:45
A sqlite (sqlcipher) database.
Definition sqldatabase.h:52
SqlDatabase & operator=(SqlDatabase &&database) noexcept
Moves a SqlDatabase object.
SqlDatabase(const std::filesystem::path &path, int flags)
Constructs a SqlDatabase.
SqlDatabase & operator=(const SqlDatabase &database)
Copies a SqlDatabase object.
const std::filesystem::path & getPath() const
Gets the path of the database file.
bool exec(const std::string &command)
Executes an sql command on the database.
SqlStatement createStatement(const std::string &command)
Creates an new SqlStatement for the database.
SqlDatabase(SqlDatabase &&database) noexcept
Moves a SqlDatabase object.
SqlDatabase(const SqlDatabase &database)
Copies a SqlDatabase object.
bool unlock(const std::string &password)
Unlocks the database.
bool registerFunction(const std::string &name, const SqliteCustomFunction &func, int expectedArgs=-1)
Registers a custom sql function to the database.
bool changePassword(const std::string &password)
Changes the database's password.
bool isEncrypted() const
Gets whether or not the database is encrypted.
sqlite3 * c_obj()
Returns the underlying sqlite3 object pointer for the database.
A sqlite statement.
Definition sqlstatement.h:45
Definition sqlcontext.h:40
std::function< void(SqlContext &)> SqliteCustomFunction
Definition sqldatabase.h:46