Raven Engine v0.1
Loading...
Searching...
No Matches
Raven::ConfigurationManager Class Reference

Singleton manager for application configuration files. More...

#include <ConfigurationManager.h>

Public Member Functions

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ ConfigurationManager()

Raven::ConfigurationManager::ConfigurationManager ( )
default

Default constructor.

◆ ~ConfigurationManager()

Raven::ConfigurationManager::~ConfigurationManager ( )
default

Default destructor.

Member Function Documentation

◆ 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
filePathPath 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
TType of the config struct, must implement Reflect(visitor).
Parameters
configReference to the config struct to populate.
sectionNameName 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
sectionNameName 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
TType of the config struct, must implement the Reflect function.
Parameters
configReference to the config struct.
sectionNameName of the section to save out to disk.

The documentation for this class was generated from the following files: