30#include <utility/logging/loggable.hpp>
31#include <utility/logging/default_logger.hpp>
73 public utility::logging::Loggable<LocalStorage,
74 utility::logging::DefaultLogger>
80 mutable std::mutex _mutex;
85 sqlite3_stmt *_setItemStmt {
88 sqlite3_stmt *_getItemStmt {
91 sqlite3_stmt *_removeItemStmt {
104 sqlite3_stmt *prepareStatement(sqlite3_stmt *&stmt,
105 const char *sql)
const;
111 void finalizeStatements(
void);
118 void initializeSchema(
void);
127 bool executeStatement(
const std::string &sql)
const noexcept(
false);
163 const std::
string &value) noexcept(false) override;
172 std::optional<std::
string>
173 getItem(const std::
string &key) noexcept(false) override;
181 void removeItem(const std::
string &key) noexcept(false) override;
187 void clear(
void) noexcept(false) override;
static std::filesystem::path defaultStoragePath(void) noexcept(false)
Get the path used when the constructor is given none.
bool isPersistent(void) const noexcept
Tell whether the items are written to the storage file.
void setItem(const std::string &key, const std::string &value) noexcept(false) override
Store a string under a key, replacing the item already stored under that key, if any.
void clear(void) noexcept(false) override
Delete every item of the storage file.
LocalStorage(const std::filesystem::path &storageFilePath=defaultStoragePath()) noexcept(false)
Open the storage file, creating it and its parent directories when they do not exist.
std::optional< std::string > getItem(const std::string &key) noexcept(false) override
Read the text stored under a key.
void removeItem(const std::string &key) noexcept(false) override
Delete the item stored under a key. Does nothing when there is none.
A key-value store of strings, modelled on the web Storage API (setItem, getItem, removeItem,...
virtual void setItem(const std::string &key, const std::string &value)=0
Store a string under a key, replacing the item already stored under that key, if any.
A C++20 UI framework for desktop and XR, built as an entity-component-system.