#include <filesystem>
#include <string>
Go to the source code of this file.
- Copyright
- Jaremie Romer and McCallister Romer 2025
◆ Load()
auto nc::config::Load |
( |
const std::filesystem::path & |
path | ) |
-> Config |
Load a Config object from a file.
- Parameters
-
path | The path to a config file. |
- Returns
- A Config object initialized with key-value pairs from the file.
- Exceptions
-
NcError | if there is a failure opening or reading values from the file or if Validate() fails on the resulting Config object. |
The input file may contain any config options as equals-separated key-value pairs, each on their own line. Any options absent in the file will be initialized to their default values.
The following are ignored:
- Unrecognized options
- Leading/trailing whitespace and empty lines
- Line comments starting with ';' or '#'
- Sections (e.g. [my_section])
For a listing of all keys see the Sample or create a default file with: Save("config.ini", nc::config::Config{});
◆ Save()
void nc::config::Save |
( |
const std::filesystem::path & |
path, |
|
|
const Config & |
config |
|
) |
| |
Write a Config object's contents to a file.
- Parameters
-
path | The file path to be written to. |
config | The object data to be written. |
- Exceptions
-
NcError | if the file cannot be opened or created. |
◆ Validate()
auto nc::config::Validate |
( |
const Config & |
config | ) |
-> bool |
Check if a Config object is in a valid state for initializing NcEngine.
- Parameters
-
config | The object to verify. |
- Returns
- A bool indicating whether or not the object is valid.
- Note
- This should be called on any manually constructed Config object prior to initializing the engine with it. It does not need to be called on an object returned from nc::config::Load().