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

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...
 
BlamColorAsColor ()
 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...
 
BlamConfigurationSettingCopy ()
 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...
 
std::map< std::string, std::string > GetEnumeratorOptions ()
 Generates a list of enumerator options for the setting. 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...
 

Detailed Description

Class representing a configuration setting.

Constructor & Destructor Documentation

◆ BlamConfigurationSetting()

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.

Parameters
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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ AsBool()

bool * BlamConfigurationSetting::AsBool ( )

Retrieves the setting value as a bool.

Returns
Pointer to the setting value as a bool. If the value could not be converted to a bool, then nullptr will be returned instead.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AsColor()

BlamColor * BlamConfigurationSetting::AsColor ( )

Retrieves the setting value as a color.

Returns
Pointer to the setting value as a color. If the value could not be converted to a color, then nullptr will be returned instead.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AsFloat()

float * BlamConfigurationSetting::AsFloat ( )

Retrieves the setting value as a float.

Returns
Pointer to the setting value as a float. If the value could not be converted to a float, then nullptr will be returned instead.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AsInt()

int * BlamConfigurationSetting::AsInt ( )

Retrieves the setting value as an int.

Returns
Pointer to the setting value as an int. If the value could not be converted to an int, then nullptr will be returned instead.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AsString()

std::string * BlamConfigurationSetting::AsString ( )

Retrieves the setting value as a string.

Returns
Pointer to the setting value as a string.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConvertRawValueToString()

std::string BlamConfigurationSetting::ConvertRawValueToString ( )

Converts the raw setting value to a string, with no placeholders expanded.

Returns
The configuration setting as a string.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Copy()

BlamConfigurationSetting * BlamConfigurationSetting::Copy ( )

Creates a new copy of this setting.

Used when creating a new setting from a base default setting.

Returns
A pointer to the new copy of the setting.
+ Here is the call graph for this function:

◆ CreateConfigFileLine()

std::string BlamConfigurationSetting::CreateConfigFileLine ( )

Generates a string containing the setting as a config line, ready to be written to a config file.

Returns
The configuration setting as a config line string.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDescriptionString()

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.

Returns
A string representing the description of the setting.
+ Here is the call graph for this function:

◆ GetDisplayNameString()

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.

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

◆ GetEnumeratorOptions()

std::map< std::string, std::string > BlamConfigurationSetting::GetEnumeratorOptions ( )

Generates a list of enumerator options for the setting.

Some string settings are designed to be used as enumerator options. The display names and values for these settings is stored in the config_strings.xml string table. This function will generate a map containing all possible options for this setting.

Returns
A map of all possible enumerator options for the setting. If the setting does not have any enumerator option string configured (or if the setting is not a string), then this will return an empty list.
+ Here is the call graph for this function:

◆ GetRawValue()

std::string * BlamConfigurationSetting::GetRawValue ( )

Retrieves the raw value of the setting, with no placeholders expanded.

+ Here is the caller graph for this function:

◆ IsValid()

bool BlamConfigurationSetting::IsValid ( )

Whether or not the provided file line was able to be interpreted as a valid setting.

Returns
true if the setting is valid, otherwise returns false.
+ Here is the caller graph for this function:

◆ ParseValue()

void BlamConfigurationSetting::ParseValue ( )

Parses the raw setting value depending on the setting type.

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

◆ UpdateValue()

void BlamConfigurationSetting::UpdateValue ( std::string  new_value)

Updates the configuration setting with a new value.

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

Member Data Documentation

◆ id

std::string BlamConfigurationSetting::id = "unspecified"

The name of the setting.

◆ type

The type of setting that's being stored.


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