![]() |
Blamite Game Engine - Strings
00321.06.22.21.0037.blamite
A library containing general purpose utilities and classes for use in multiple projects.
|
Class representing a configuration setting. More...
#include <config.h>
Public Member Functions | |
BlamConfigurationSetting (std::string line, int _line_number, std::string _comment_delimeter, std::string _filename) | |
Prepares a new configuration setting. More... | |
void | ParseValue () |
Parses the raw setting value depending on the setting type. More... | |
bool | IsValid () |
Whether or not the provided file line was able to be interpreted as a valid setting. More... | |
std::string * | AsString () |
Retrieves the setting value as a string. More... | |
bool * | AsBool () |
Retrieves the setting value as a bool. More... | |
float * | AsFloat () |
Retrieves the setting value as a float. More... | |
int * | AsInt () |
Retrieves the setting value as an int. More... | |
BlamColor * | AsColor () |
Retrieves the setting value as a color. More... | |
std::string | ConvertRawValueToString () |
Converts the raw setting value to a string, with no placeholders expanded. More... | |
void | UpdateValue (std::string new_value) |
Updates the configuration setting with a new value. More... | |
std::string * | GetRawValue () |
Retrieves the raw value of the setting, with no placeholders expanded. More... | |
std::string | GetDisplayNameString () |
Generates a display name for the configuration setting for use in a user-friendly settings dialog. More... | |
std::string | GetDescriptionString () |
Generates a description for the configuration setting for use in a user-friendly settings dialog. More... | |
BlamConfigurationSetting * | Copy () |
Creates a new copy of this setting. More... | |
std::string | CreateConfigFileLine () |
Generates a string containing the setting as a config line, ready to be written to a config file. More... | |
Public Attributes | |
std::string | id = "unspecified" |
The name of the setting. More... | |
BlamConfigurationSettingType | type = BlamConfigurationSettingType::Invalid |
The type of setting that's being stored. More... | |
Class representing a configuration setting.
BlamConfigurationSetting::BlamConfigurationSetting | ( | std::string | line, |
int | _line_number, | ||
std::string | _comment_delimeter, | ||
std::string | _filename | ||
) |
Prepares a new configuration setting.
This method will create new setting data, as well as convert the setting value to the appropriate type.
line | - The line in the file to interpret as a configuration setting. |
_line_number | - The line number that this setting appeared on within the file. |
_comment_delimeter | - The prefix to use when checking if the line is a comment. |
_filename | - The name of the configuration file this setting belongs to. |
bool * BlamConfigurationSetting::AsBool | ( | ) |
Retrieves the setting value as a bool.
nullptr
will be returned instead. BlamColor * BlamConfigurationSetting::AsColor | ( | ) |
Retrieves the setting value as a color.
nullptr
will be returned instead. float * BlamConfigurationSetting::AsFloat | ( | ) |
Retrieves the setting value as a float.
nullptr
will be returned instead. int * BlamConfigurationSetting::AsInt | ( | ) |
Retrieves the setting value as an int.
nullptr
will be returned instead. std::string * BlamConfigurationSetting::AsString | ( | ) |
Retrieves the setting value as a string.
std::string BlamConfigurationSetting::ConvertRawValueToString | ( | ) |
Converts the raw setting value to a string, with no placeholders expanded.
BlamConfigurationSetting * BlamConfigurationSetting::Copy | ( | ) |
Creates a new copy of this setting.
Used when creating a new setting from a base default setting.
std::string BlamConfigurationSetting::CreateConfigFileLine | ( | ) |
Generates a string containing the setting as a config line, ready to be written to a config file.
std::string BlamConfigurationSetting::GetDescriptionString | ( | ) |
Generates a description for the configuration setting 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_{0}_{1}_info
{0}
represents the file name of the configuration file, with no extension or other path information.{1}
represents the setting ID as it appears in the configuration file.
If no matching string is found, then this will simply return an empty string.
std::string BlamConfigurationSetting::GetDisplayNameString | ( | ) |
Generates a display name for the configuration setting 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_{0}_{1}_name
{0}
represents the file name of the configuration file, with no extension or other path information.{1}
represents the setting ID as it appears in the configuration file.
If no matching string is found, then this will simply return the ID of the setting.
std::string * BlamConfigurationSetting::GetRawValue | ( | ) |
Retrieves the raw value of the setting, with no placeholders expanded.
bool BlamConfigurationSetting::IsValid | ( | ) |
Whether or not the provided file line was able to be interpreted as a valid setting.
true
if the setting is valid, otherwise returns false
. void BlamConfigurationSetting::ParseValue | ( | ) |
Parses the raw setting value depending on the setting type.
void BlamConfigurationSetting::UpdateValue | ( | std::string | new_value | ) |
Updates the configuration setting with a new value.
std::string BlamConfigurationSetting::id = "unspecified" |
The name of the setting.
BlamConfigurationSettingType BlamConfigurationSetting::type = BlamConfigurationSettingType::Invalid |
The type of setting that's being stored.