Singleton manager for application configuration files.
More...
#include <ConfigurationManager.h>
|
| void | LoadConfiguration (std::string_view filePath) |
| | Loads the configuration file from the specified path.
|
| std::unordered_map< std::string, std::string > | ParseSection (std::string_view sectionName) const |
| | Parses all key-value pairs in the given section.
|
| const std::unordered_set< std::string > | FindHeaders () const |
| | Finds all section headers in the configuration file.
|
| template<typename T> |
| void | LoadSettings (T &config, std::string_view sectionName) const |
| | Loads settings into a config struct, reflecting missing fields back to file.
|
| template<typename T> |
| void | SaveSettings (T &config, std::string_view sectionName) |
| | Saves the values inside of the specified config struct to disk by reflecting the fields to file.
|
| | ConfigurationManager ()=default |
| | Default constructor.
|
| | ~ConfigurationManager ()=default |
| | Default destructor.
|
Singleton manager for application configuration files.
The ConfigurationManager provides functionality to read and write named sections in a simple INI configuration file. It supports parsing key-value pairs, finding section headers, and loading settings into user-defined structs via a Reflect(visitor) interface. Primitive types are converted using the Converters utilities. If a section or field is missing, defaults are written back to the file.
◆ ConfigurationManager()
| Raven::ConfigurationManager::ConfigurationManager |
( |
| ) |
|
|
default |
◆ ~ConfigurationManager()
| Raven::ConfigurationManager::~ConfigurationManager |
( |
| ) |
|
|
default |
◆ FindHeaders()
| const std::unordered_set< std::string > Raven::ConfigurationManager::FindHeaders |
( |
| ) |
const |
Finds all section headers in the configuration file.
- Returns
- Set of section names present in the file.
◆ LoadConfiguration()
| void Raven::ConfigurationManager::LoadConfiguration |
( |
std::string_view | filePath | ) |
|
|
inline |
Loads the configuration file from the specified path.
- Parameters
-
| filePath | Path to the configuration file. |
◆ LoadSettings()
template<typename T>
| void Raven::ConfigurationManager::LoadSettings |
( |
T & | config, |
|
|
std::string_view | sectionName ) const |
|
inline |
Loads settings into a config struct, reflecting missing fields back to file.
- Template Parameters
-
| T | Type of the config struct, must implement Reflect(visitor). |
- Parameters
-
| config | Reference to the config struct to populate. |
| sectionName | Name of the section to load or create. |
◆ ParseSection()
| std::unordered_map< std::string, std::string > Raven::ConfigurationManager::ParseSection |
( |
std::string_view | sectionName | ) |
const |
Parses all key-value pairs in the given section.
- Parameters
-
| sectionName | Name of the section (without brackets). |
- Returns
- Map of keys to values as strings.
◆ SaveSettings()
template<typename T>
| void Raven::ConfigurationManager::SaveSettings |
( |
T & | config, |
|
|
std::string_view | sectionName ) |
|
inline |
Saves the values inside of the specified config struct to disk by reflecting the fields to file.
- Template Parameters
-
| T | Type of the config struct, must implement the Reflect function. |
- Parameters
-
| config | Reference to the config struct. |
| sectionName | Name of the section to save out to disk. |
The documentation for this class was generated from the following files: