A class to manage the settings.json file, derived privately from JsonFile.
More...
#include <SettingsFile.h>
|
| | SettingsFile (const File &settingsFile) |
| | Constructor that initializes the SettingsFile with a given File object.
|
| |
| var | getSetting (const Identifier &key) |
| | Retrieves the value associated with a given key.
|
| |
| void | setSetting (const Identifier &key, const var &value) |
| | Sets the value associated with a given key in the settings.
|
| |
| String | getSettingsVersion () const |
| | Retrieves the settings version from the JSON data. This function retrieves the settings version from the JSON data stored in the SettingsFile object.
|
| |
| void | setSettingsVersion (const String &version) |
| | Sets the settings version in the JSON data. This function sets the settings version in the JSON data of the SettingsFile object.
|
| |
| bool | existsAsFile () |
| | Checks if the associated JSON file exists as a file.
|
| |
| void | setDefaultIfVoid (const Identifier &key, const var &defaultValue) |
| | Sets the default value (if required) associated with a given key in the settings.
|
| |
|
| | JsonFile (File jsonFile, const Identifier &defaultProperty, const String &defaultFormat) |
| | Simple helper class for handling json files. It will attempt to create a json file with the given default property and format, or if the given json file already exists, it will attempt to parse it and check it has the default property.
|
| |
| var | getDefaultProperty () const |
| | Get the variant for the default property.
|
| |
| const String & | getDefaultFormat () const |
| | Gets the underlying default formatted json, this is used as a fallback when an invalid input is passed to the JSON file.
|
| |
| void | initialise () |
| | Parse the file if it exists, or create it if it doesn't. Data is parsed to m_data;.
|
| |
| void | save () |
| | Call save internal.
|
| |
| void | createJsonFromDefaultFormat () |
| | Generate the JSON file using the default format - used in cases where JSON fails to load.
|
| |
| var | m_data |
| | The parsed json data.
|
| |
| File | m_jsonFile |
| | The json file.
|
| |
A class to manage the settings.json file, derived privately from JsonFile.
This class provides methods to get and set settings using a JSON file.
◆ SettingsFile()
| krotos::SettingsFile::SettingsFile |
( |
const File & | settingsFile | ) |
|
Constructor that initializes the SettingsFile with a given File object.
- Parameters
-
| settingsFile | A reference to a File object representing the settings file. |
◆ existsAsFile()
| bool krotos::SettingsFile::existsAsFile |
( |
| ) |
|
|
inline |
Checks if the associated JSON file exists as a file.
- Returns
- A boolean value that is true if the JSON file exists as a file, false otherwise.
◆ getSetting()
| var krotos::SettingsFile::getSetting |
( |
const Identifier & | key | ) |
|
Retrieves the value associated with a given key.
- Parameters
-
| key | An Identifier representing the key to look for in the settings. |
- Returns
- A var containing the value associated with the given key.
◆ getSettingsVersion()
| String krotos::SettingsFile::getSettingsVersion |
( |
| ) |
const |
Retrieves the settings version from the JSON data. This function retrieves the settings version from the JSON data stored in the SettingsFile object.
- Returns
- A String containing the settings version.
◆ setDefaultIfVoid()
| void krotos::SettingsFile::setDefaultIfVoid |
( |
const Identifier & | key, |
|
|
const var & | defaultValue ) |
Sets the default value (if required) associated with a given key in the settings.
- Parameters
-
| key | An Identifier representing the key to associate with the value. |
| defaultValue | A var containing the desired default value. |
◆ setSetting()
| void krotos::SettingsFile::setSetting |
( |
const Identifier & | key, |
|
|
const var & | value ) |
Sets the value associated with a given key in the settings.
- Parameters
-
| key | An Identifier representing the key to associate with the value. |
| value | A var containing the value to set for the given key. |
◆ setSettingsVersion()
| void krotos::SettingsFile::setSettingsVersion |
( |
const String & | version | ) |
|
Sets the settings version in the JSON data. This function sets the settings version in the JSON data of the SettingsFile object.
- Parameters
-
| version | A String representing the new settings version to set. |
The documentation for this class was generated from the following files: