Configuration Files

Namespace: Blam::Config

class ConfigFile

Class to contain data related to a Config file.

Public Functions

std::string GetString(std::string option)

Retrieves the specified config option’s value as a string.

Parameters
  • option: - The ID of the configuration option.

const char *GetCString(std::string option)

Retrieves the specified config option’s value as a const char*, also referred to as a C-String.

Parameters
  • option: - The ID of the configuration option.

std::wstring GetWString(std::string option)

Retrieves the specified config option’s value as a wstring.

Parameters
  • option: - The ID of the configuration option.

float GetFloat(std::string option)

Retrieves the specified config option’s value as a float

Parameters
  • option: - The ID of the configuration option.

int GetInt(std::string option)

Retrieves the specified config option’s value as an int (32-bit integer)

Parameters
  • option: - The ID of the configuration option.

double GetDouble(std::string option)

Retrieves the specified config option’s value as a double

Parameters
  • option: - The ID of the configuration option.

bool GetBoolean(std::string option)

Retrieves the specified config option’s value as a bool

Parameters
  • option: - The ID of the configuration option.

Public Members

std::string path

The path to the configuration file. Can be either absolute or relative.

std::string filename

The name of the configuration file.

std::map<std::string, ConfigOption> options

Contains all options contained within the config file.

std::map<std::string, ConfigOption> default_options

Contains all defaults for the config file. Usually, defaults are stored as a resource embedded within the application.

Private Functions

Blam::Config::ConfigOption *find_config_option(std::string option)

Internal function to prevent erroring when retrieving a configuration value.

Returns nullptr if option could not be found

Parameters
  • option: - The ID of the configuration option.

Blam::Config::ConfigOption *find_config_default_option(std::string option)

Internal function to prevent erroring when retrieving a default configuration value.

Returns nullptr if option could not be found

Parameters
  • option: - The ID of the configuration option.

std::string get_raw_config_value(std::string config_option)

Helper function to obtain a raw configuration value.

Helper function to obtain a raw configuration value. Should not be called outside of the other functions to obtain a configuration value. It will log an error to console if the config option could not be found.

Parameters
  • option: - The ID of the configuration option.

struct ConfigOption

Structure to contain data for an option within a Config file.

Public Members

std::string id

The ID of the configuration setting, as it displays in the config file.

std::string value

The raw string value of the option, as it displays in the config file.