|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Key-value storage that lasts as long as the process: the place for data shared between scenes that need not survive a restart. More...
#include <headers/guillaume/session_storage.hpp>


Public Member Functions | |
| SessionStorage (void)=default | |
| Create a handle on the process-wide session items. | |
| ~SessionStorage (void) override=default | |
| Destroy the handle. The items are kept. | |
| void | setItem (const std::string &key, const std::string &value) override |
| Store a string under a key, replacing the item already stored under that key, if any. | |
| std::optional< std::string > | getItem (const std::string &key) override |
| Read the text stored under a key. | |
| void | removeItem (const std::string &key) override |
| Delete the item stored under a key. Does nothing when there is none. | |
| void | clear (void) override |
| Delete every session item of the process, including those written through other SessionStorage objects. | |
| void | setItem (const std::string &key, std::string_view value) |
| Store a copy of a string view under a key. | |
| void | setItem (const std::string &key, const char *value) |
| Store a copy of a C string under a key. | |
| template<typename ValueType> requires (std::is_same_v<std::remove_cvref_t<ValueType>, bool>) | |
| void | setItem (const std::string &key, ValueType value) |
| Store a boolean under a key, as the text "true" or "false". | |
| Public Member Functions inherited from guillaume::Storage | |
| virtual | ~Storage (void)=default |
| Virtual destructor. | |
| void | setItem (const std::string &key, std::string_view value) |
| Store a copy of a string view under a key. | |
| void | setItem (const std::string &key, const char *value) |
| Store a copy of a C string under a key. | |
| template<typename ValueType> requires (std::is_same_v<std::remove_cvref_t<ValueType>, bool>) | |
| void | setItem (const std::string &key, ValueType value) |
| Store a boolean under a key, as the text "true" or "false". | |
| template<typename ValueType> requires (std::is_arithmetic_v<ValueType> && !std::is_same_v<ValueType, bool>) | |
| void | setItem (const std::string &key, ValueType value) |
| Store a number under a key, as its decimal text. | |
| template<typename ValueType> | |
| std::optional< ValueType > | getItemAs (const std::string &key) |
| Read the item stored under a key and convert it to a type. | |
Key-value storage that lasts as long as the process: the place for data shared between scenes that need not survive a restart.
All SessionStorage objects of a process read and write the same items: creating a second instance gives another handle on the same data, not a second store, and destroying an instance deletes nothing. The typed overloads of Storage (numbers, booleans, getItemAs) are available.
Definition at line 58 of file session_storage.hpp.
|
overridevirtual |
Delete every session item of the process, including those written through other SessionStorage objects.
Implements guillaume::Storage.
|
overridevirtual |
Read the text stored under a key.
| key | The name of the item. |
Implements guillaume::Storage.
|
overridevirtual |
Delete the item stored under a key. Does nothing when there is none.
| key | The name of the item. |
Implements guillaume::Storage.
| void guillaume::Storage::setItem | ( | const std::string & | key, |
| const char * | value ) |
Store a copy of a C string under a key.
| key | The name of the item. |
| value | The null-terminated text to store. A null pointer stores an empty string. |
|
overridevirtual |
Store a string under a key, replacing the item already stored under that key, if any.
| key | The name of the item. |
| value | The text to store. |
Implements guillaume::Storage.
| void guillaume::Storage::setItem | ( | const std::string & | key, |
| std::string_view | value ) |
Store a copy of a string view under a key.
| key | The name of the item. |
| value | The text to store. |
| void guillaume::Storage::setItem | ( | const std::string & | key, |
| ValueType | value ) |
Store a boolean under a key, as the text "true" or "false".
| ValueType | bool (possibly const or a reference). |
| key | The name of the item. |
| value | The boolean to store. |