![]() |
Blamite Game Engine - Strings
00386.06.16.23.0646.blamite
A library containing general purpose utilities and classes for use in multiple projects.
|
#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... | |
BlamConfigurationSection * | GetConfigurationSection (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... | |
BlamColor * | GetColor (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... | |
BlamConfigurationFile::BlamConfigurationFile | ( | std::string | _filename, |
std::string | _comment_delimeter | ||
) |
Prepares a new configuration file to be loaded.
_filename | - The path to the configuration file. |
_comment_delimeter | - The prefix to use when checking if a line is a comment. |
BlamConfigurationFile::~BlamConfigurationFile | ( | ) |
Destructor.
Deletes any configuration sections within the file.
void BlamConfigurationFile::AddNewSection | ( | BlamConfigurationSection * | section | ) |
Adds a new configuration section to the file.
bool * BlamConfigurationFile::GetBool | ( | std::string | section_name, |
std::string | option | ||
) |
Retrieves a configuration setting as a bool.
section_name | - The section to retrieve the setting from. |
option | - The option to retrieve. |
nullptr
. If the setting exists but cannot be interpreted as a bool, then will also return nullptr
. BlamColor * BlamConfigurationFile::GetColor | ( | std::string | section_name, |
std::string | option | ||
) |
Retrieves a configuration setting as a color.
section_name | - The section to retrieve the setting from. |
option | - The option to retrieve. |
nullptr
. If the setting exists but cannot be interpreted as a color, then will also return nullptr
. BlamConfigurationSection * BlamConfigurationFile::GetConfigurationSection | ( | std::string | section_name | ) |
Retrieves a configuration section from the configuration file.
NULL
. 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.
float * BlamConfigurationFile::GetFloat | ( | std::string | section_name, |
std::string | option | ||
) |
Retrieves a configuration setting as a float.
section_name | - The section to retrieve the setting from. |
option | - The option to retrieve. |
nullptr
. If the setting exists but cannot be interpreted as a float, then will also return nullptr
. int * BlamConfigurationFile::GetInt | ( | std::string | section_name, |
std::string | option | ||
) |
Retrieves a configuration setting as an int.
section_name | - The section to retrieve the setting from. |
option | - The option to retrieve. |
nullptr
. If the setting exists but cannot be interpreted as an int, then will also return nullptr
. std::string * BlamConfigurationFile::GetString | ( | std::string | section_name, |
std::string | option | ||
) |
Retrieves a configuration setting as a string.
section_name | - The section to retrieve the setting from. |
option | - The option to retrieve. |
nullptr
. If the setting exists but is not listed as a string, then will also return nullptr
. bool BlamConfigurationFile::HasConfigurationSection | ( | std::string | section_name | ) |
Checks whether or not a given configuration section exists in the file.
section_name | - The name of the section to look for. |
true
if the section exists, otherwise returns false
. bool BlamConfigurationFile::IsLoaded | ( | ) |
Whether or not this configuration file has been loaded.
BlamResult BlamConfigurationFile::Load | ( | ) |
Loads the configuration file from disk.
#BlamResult::Success_OK
if the file was loaded successfully, otherwise returns an error code. BlamResult BlamConfigurationFile::Load | ( | std::string | _filename | ) |
Loads settings from a secondary file into this file.
Used for merging multiple configuration files together at runtime.
_filename | - The file to load additional settings from. |
#BlamResult::Success_OK
if the file was loaded successfully, otherwise returns an error code. BlamResult BlamConfigurationFile::LoadDefaults | ( | std::string | _filename | ) |
Load the list of default sections.
_filename | - The path to the configuration file containing default settings. |
BlamResult BlamConfigurationFile::Reload | ( | ) |
Cleans up old data and reloads the configuration file from disk.
#BlamResult::Success_OK
if the file was loaded successfully, otherwise returns an error code. void BlamConfigurationFile::RestoreDefaultSettings | ( | ) |
Resets all configuration values to default.
void BlamConfigurationFile::Save | ( | ) |
Saves the configuration file back to disk.
#BlamResult::Success_OK
if the file was saved successfully, otherwise returns an error code. std::string BlamConfigurationFile::comment_delimeter = "" |
The character or string used to indicate a comment within the file.
std::string BlamConfigurationFile::defaults_filename = "" |
The file path of the configuration file used to store default settings.
std::string BlamConfigurationFile::filename = "" |
The file path of the configuration file.
std::map<std::string, BlamConfigurationSection*> BlamConfigurationFile::sections |
The list of configuration sections contained within the file.