Elaztek Developer Hub
Blamite Game Engine - Strings  00390.07.02.23.1947.blamite
A library containing general purpose utilities and classes for use in multiple projects.
BlamConfigurationFile Class Reference

#include <config.h>

Public Member Functions

 BlamConfigurationFile (std::string _filename, std::string _comment_delimeter)
 Prepares a new configuration file to be loaded. More...
 
 ~BlamConfigurationFile ()
 Destructor. More...
 
BlamResult LoadDefaults (std::string _filename)
 Load the list of default sections. More...
 
BlamResult Load ()
 Loads the configuration file from disk. More...
 
BlamResult Load (std::string _filename)
 Loads settings from a secondary file into this file. More...
 
BlamResult Reload ()
 Cleans up old data and reloads the configuration file from disk. More...
 
void Save ()
 Saves the configuration file back to disk. More...
 
bool IsLoaded ()
 Whether or not this configuration file has been loaded. More...
 
void AddNewSection (BlamConfigurationSection *section)
 Adds a new configuration section to the file. More...
 
bool HasConfigurationSection (std::string section_name)
 Checks whether or not a given configuration section exists in the file. More...
 
BlamConfigurationSectionGetConfigurationSection (std::string section_name)
 Retrieves a configuration section from the configuration file. More...
 
std::string GetDisplayNameString ()
 Generates a display name for the configuration file for use in a user-friendly settings dialog. More...
 
void RestoreDefaultSettings ()
 Resets all configuration values to default. More...
 
std::string * GetString (std::string section_name, std::string option)
 Retrieves a configuration setting as a string. More...
 
bool * GetBool (std::string section_name, std::string option)
 Retrieves a configuration setting as a bool. More...
 
float * GetFloat (std::string section_name, std::string option)
 Retrieves a configuration setting as a float. More...
 
int * GetInt (std::string section_name, std::string option)
 Retrieves a configuration setting as an int. More...
 
BlamColorGetColor (std::string section_name, std::string option)
 Retrieves a configuration setting as a color. More...
 

Public Attributes

std::map< std::string, BlamConfigurationSection * > sections
 The list of configuration sections contained within the file. More...
 
std::string filename = ""
 The file path of the configuration file. More...
 
std::string defaults_filename = ""
 The file path of the configuration file used to store default settings. More...
 
std::string comment_delimeter = ""
 The character or string used to indicate a comment within the file. More...
 

Constructor & Destructor Documentation

◆ BlamConfigurationFile()

BlamConfigurationFile::BlamConfigurationFile ( std::string  _filename,
std::string  _comment_delimeter 
)

Prepares a new configuration file to be loaded.

Parameters
_filename- The path to the configuration file.
_comment_delimeter- The prefix to use when checking if a line is a comment.
Deprecated:
Use the new constructor.

◆ ~BlamConfigurationFile()

BlamConfigurationFile::~BlamConfigurationFile ( )

Destructor.

Deletes any configuration sections within the file.

Member Function Documentation

◆ AddNewSection()

void BlamConfigurationFile::AddNewSection ( BlamConfigurationSection section)

Adds a new configuration section to the file.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetBool()

bool * BlamConfigurationFile::GetBool ( std::string  section_name,
std::string  option 
)

Retrieves a configuration setting as a bool.

Parameters
section_name- The section to retrieve the setting from.
option- The option to retrieve.
Returns
Pointer to the setting value if it exists, otherwise returns nullptr. If the setting exists but cannot be interpreted as a bool, then will also return nullptr.
+ Here is the call graph for this function:

◆ GetColor()

BlamColor * BlamConfigurationFile::GetColor ( std::string  section_name,
std::string  option 
)

Retrieves a configuration setting as a color.

Parameters
section_name- The section to retrieve the setting from.
option- The option to retrieve.
Returns
Pointer to the setting value if it exists, otherwise returns nullptr. If the setting exists but cannot be interpreted as a color, then will also return nullptr.
+ Here is the call graph for this function:

◆ GetConfigurationSection()

BlamConfigurationSection * BlamConfigurationFile::GetConfigurationSection ( std::string  section_name)

Retrieves a configuration section from the configuration file.

Returns
The specified configuration section if it exists, otherwise returns NULL.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDisplayNameString()

std::string BlamConfigurationFile::GetDisplayNameString ( )

Generates a display name for the configuration file for use in a user-friendly settings dialog.

This will attempt to check the string database for a matching configuration string entry. By default, these are stored in config_strings.xml, though the specific file is largely irrelevant. The format for a display name string is as follows:

config_file_{0}_name

{0} represents the file name of the configuration file, with no extension or other path information.

If no matching string is found, then this will simply return the filename of the file, with the path information and extension removed.

Returns
A string representing the display name for the file.
+ Here is the call graph for this function:

◆ GetFloat()

float * BlamConfigurationFile::GetFloat ( std::string  section_name,
std::string  option 
)

Retrieves a configuration setting as a float.

Parameters
section_name- The section to retrieve the setting from.
option- The option to retrieve.
Returns
Pointer to the setting value if it exists, otherwise returns nullptr. If the setting exists but cannot be interpreted as a float, then will also return nullptr.
+ Here is the call graph for this function:

◆ GetInt()

int * BlamConfigurationFile::GetInt ( std::string  section_name,
std::string  option 
)

Retrieves a configuration setting as an int.

Parameters
section_name- The section to retrieve the setting from.
option- The option to retrieve.
Returns
Pointer to the setting value if it exists, otherwise returns nullptr. If the setting exists but cannot be interpreted as an int, then will also return nullptr.
+ Here is the call graph for this function:

◆ GetString()

std::string * BlamConfigurationFile::GetString ( std::string  section_name,
std::string  option 
)

Retrieves a configuration setting as a string.

Parameters
section_name- The section to retrieve the setting from.
option- The option to retrieve.
Returns
Pointer to the setting value if it exists, otherwise returns nullptr. If the setting exists but is not listed as a string, then will also return nullptr.
+ Here is the call graph for this function:

◆ HasConfigurationSection()

bool BlamConfigurationFile::HasConfigurationSection ( std::string  section_name)

Checks whether or not a given configuration section exists in the file.

Parameters
section_name- The name of the section to look for.
Returns
true if the section exists, otherwise returns false.

◆ IsLoaded()

bool BlamConfigurationFile::IsLoaded ( )

Whether or not this configuration file has been loaded.

Returns
Whether or not this configuration file has been loaded.

◆ Load() [1/2]

BlamResult BlamConfigurationFile::Load ( )

Loads the configuration file from disk.

Returns
#BlamResult::Success_OK if the file was loaded successfully, otherwise returns an error code.
+ Here is the caller graph for this function:

◆ Load() [2/2]

BlamResult BlamConfigurationFile::Load ( std::string  _filename)

Loads settings from a secondary file into this file.

Used for merging multiple configuration files together at runtime.

Parameters
_filename- The file to load additional settings from.
Returns
#BlamResult::Success_OK if the file was loaded successfully, otherwise returns an error code.
+ Here is the call graph for this function:

◆ LoadDefaults()

BlamResult BlamConfigurationFile::LoadDefaults ( std::string  _filename)

Load the list of default sections.

Parameters
_filename- The path to the configuration file containing default settings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Reload()

BlamResult BlamConfigurationFile::Reload ( )

Cleans up old data and reloads the configuration file from disk.

Returns
#BlamResult::Success_OK if the file was loaded successfully, otherwise returns an error code.
+ Here is the call graph for this function:

◆ RestoreDefaultSettings()

void BlamConfigurationFile::RestoreDefaultSettings ( )

Resets all configuration values to default.

+ Here is the call graph for this function:

◆ Save()

void BlamConfigurationFile::Save ( )

Saves the configuration file back to disk.

Returns
#BlamResult::Success_OK if the file was saved successfully, otherwise returns an error code.
+ Here is the call graph for this function:

Member Data Documentation

◆ comment_delimeter

std::string BlamConfigurationFile::comment_delimeter = ""

The character or string used to indicate a comment within the file.

◆ defaults_filename

std::string BlamConfigurationFile::defaults_filename = ""

The file path of the configuration file used to store default settings.

◆ filename

std::string BlamConfigurationFile::filename = ""

The file path of the configuration file.

◆ sections

std::map<std::string, BlamConfigurationSection*> BlamConfigurationFile::sections

The list of configuration sections contained within the file.


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