A settings database.
More...
#include <Settings.h>
|
void | initializeDatabase () |
| Initialize the database, creating the required tables if they have not been created.
|
|
template<typename T , typename S > |
std::optional< T > | getDatabaseValue (soci::session &sql, S name) |
| Get a value from settings the database. More...
|
|
template<typename T , typename S > |
void | setDatabaseValue (soci::session &sql, S name, T value) |
| Set a value in the settings database. More...
|
|
template<typename T , typename S > |
void | setValue (S name, T value) |
| Set a value in the settings database. More...
|
|
template<typename T , typename S > |
std::optional< T > | getValue (S name) |
| Get a value in the settings database. More...
|
|
template<typename T , typename S > |
T | getValue (S name, T defaultValue) |
| Get a value in the settings database, returning the default value if not found. More...
|
|
|
std::filesystem::path | mDbPath |
| The file path to the settings database.
|
|
|
static constexpr std::string_view | string_table = "settings_string" |
| The string table.
|
|
static constexpr std::string_view | int_table = "settings_int" |
| The integer table.
|
|
static constexpr std::string_view | real_table = "settings_real" |
| The real table.
|
|
static constexpr std::string_view | int_pair_table = "settings_int_pair" |
| The integer pair table.
|
|
static constexpr std::string_view | real_pair_table = "settings_real_pair" |
| The real pair table.
|
|
static constexpr std::string_view | color_table = "settings_color" |
| The color table.
|
|
◆ getDatabaseValue()
template<typename T , typename S >
std::optional<T> rose::Settings::getDatabaseValue |
( |
soci::session & |
sql, |
|
|
S |
name |
|
) |
| |
|
inline |
Get a value from settings the database.
Select the table to search based on the type of value sought.
- Template Parameters
-
T | The type of the value to retrieve. |
S | The type of the name of the value. |
- Parameters
-
sql | The database session to use. |
name | The name of the value |
- Returns
- A std::optional<T> containing the value if found, empty if not found.
◆ getValue() [1/2]
template<typename T , typename S >
std::optional<T> rose::Settings::getValue |
( |
S |
name | ) |
|
|
inline |
Get a value in the settings database.
- Template Parameters
-
T | The type of the value. |
S | The type of the name of the value. |
- Parameters
-
name | The name of the value. |
- Returns
- A std::optional<T> with the value if found, empty if not found.
◆ getValue() [2/2]
template<typename T , typename S >
T rose::Settings::getValue |
( |
S |
name, |
|
|
T |
defaultValue |
|
) |
| |
|
inline |
Get a value in the settings database, returning the default value if not found.
- Template Parameters
-
T | The type of the value. |
S | The type of the name of the value. |
- Parameters
-
name | The name of the value. |
defaultValue | The default value to return if the value is not in the database. |
- Returns
- The found value, or the default value.
◆ setDatabaseValue()
template<typename T , typename S >
void rose::Settings::setDatabaseValue |
( |
soci::session & |
sql, |
|
|
S |
name, |
|
|
T |
value |
|
) |
| |
|
inline |
Set a value in the settings database.
Select the table to store the value based on the type of value.
- Template Parameters
-
T | The type of the value to retrieve. |
S | The type of the name of the value. |
- Parameters
-
sql | The database session to use. |
name | The name of the value |
value | The value to store. |
◆ setValue()
template<typename T , typename S >
void rose::Settings::setValue |
( |
S |
name, |
|
|
T |
value |
|
) |
| |
|
inline |
Set a value in the settings database.
- Template Parameters
-
T | The type of the value. |
S | The type of the name of the value. |
- Parameters
-
name | The name of the value. |
value | The value. |
◆ transmitDataUpdate()
void rose::Settings::transmitDataUpdate |
( |
const std::string & |
dataName | ) |
|
|
protected |
Send out notification that data has changed.
- Parameters
-
dataName | The name of the data item that has changed. |
The documentation for this class was generated from the following files: