83 virtual void setItem(
const std::string &key,
84 const std::string &value) = 0;
92 void setItem(
const std::string &key, std::string_view value);
101 void setItem(
const std::string &key,
const char *value);
111 template<
typename ValueType>
112 requires(std::is_same_v<std::remove_cvref_t<ValueType>,
bool>)
113 void setItem(
const std::string &key, ValueType value);
127 template<
typename ValueType>
128 requires(std::is_arithmetic_v<ValueType>
129 && !std::is_same_v<ValueType, bool>)
130 void setItem(
const std::string &key, ValueType value);
139 virtual std::optional<std::string>
getItem(
const std::string &key) = 0;
158 template<
typename ValueType>
159 std::optional<ValueType>
getItemAs(
const std::string &key);
177#include "guillaume/storage.tpp"
A key-value store of strings, modelled on the web Storage API (setItem, getItem, removeItem,...
virtual ~Storage(void)=default
Virtual destructor.
void setItem(const std::string &key, const char *value)
Store a copy of a C string under a key.
void setItem(const std::string &key, std::string_view value)
Store a copy of a string view under a key.
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.
virtual void clear(void)=0
Delete every item of the storage.
std::optional< ValueType > getItemAs(const std::string &key)
Read the item stored under a key and convert it to a type.
virtual std::optional< std::string > getItem(const std::string &key)=0
Read the text stored under a key.
void setItem(const std::string &key, ValueType value)
Store a number under a key, as its decimal text.
virtual void removeItem(const std::string &key)=0
Delete the item stored under a key. Does nothing when there is none.
void setItem(const std::string &key, ValueType value)
Store a boolean under a key, as the text "true" or "false".
A C++20 UI framework for desktop and XR, built as an entity-component-system.