This class provides simple JSON configuration file save/load.
More...
#include <grmcdorman/device/ConfigFile.h>
|
| | ConfigFile () |
| | Construct a new Config File object. More...
|
| |
| | ConfigFile (const char *explicit_path) |
| | Construct a new Config File object. More...
|
| |
| const char * | get_path () const |
| | Get the path. More...
|
| |
| void | save (const std::vector< Device * > &devices) |
| | Save all device settings. More...
|
| |
| bool | load (const std::vector< Device * > &devices) |
| | Load all device settings. More...
|
| |
| void | save (DynamicJsonDocument &json) |
| | Save the JSON settings to the file system. More...
|
| |
| std::optional< DynamicJsonDocument > | load () |
| | Load the JSON settings from the file system. More...
|
| |
This class provides simple JSON configuration file save/load.
◆ ConfigFile() [1/2]
| grmcdorman::device::ConfigFile::ConfigFile |
( |
| ) |
|
|
inline |
Construct a new Config File object.
This will have the default file path, /config.json.
◆ ConfigFile() [2/2]
| grmcdorman::device::ConfigFile::ConfigFile |
( |
const char * |
explicit_path | ) |
|
|
inlineexplicit |
Construct a new Config File object.
- Parameters
-
| explicit_path | The explicit path to the config file. Must be a persisent pointer; do not pass a .c_str() value. |
◆ get_path()
| const char * grmcdorman::device::ConfigFile::get_path |
( |
| ) |
const |
|
inline |
Get the path.
- Returns
- Configuration file path.
◆ load() [1/2]
| std::optional< DynamicJsonDocument > grmcdorman::device::ConfigFile::load |
( |
| ) |
|
Load the JSON settings from the file system.
If the settings cannot be retrieved, or an error occurred, an unset value is returned.
- Returns
- The loaded settings, or unset if no settings can be loaded.
◆ load() [2/2]
| bool grmcdorman::device::ConfigFile::load |
( |
const std::vector< Device * > & |
devices | ) |
|
Load all device settings.
This loads all applicable device settings.
- Parameters
-
| devices | The set of devices to save. |
- Returns
true if settings were loaded.
◆ save() [1/2]
| void grmcdorman::device::ConfigFile::save |
( |
const std::vector< Device * > & |
devices | ) |
|
Save all device settings.
This saves all applicable device settings. If there are no devices with savable settings, no config file is saved.
- Parameters
-
| devices | The set of devices to save. |
◆ save() [2/2]
| void grmcdorman::device::ConfigFile::save |
( |
DynamicJsonDocument & |
json | ) |
|
Save the JSON settings to the file system.
- Parameters
-
The documentation for this class was generated from the following files: