OpenXcom
1.0
Open-source clone of the original X-Com
|
Helper class that ties metadata to particular options to help in serializing and stuff. More...
#include <OptionInfo.h>
Public Member Functions | |
OptionInfo (const std::string &id, bool *option, bool def, const std::string &desc="", const std::string &cat="") | |
Creates a bool option. More... | |
OptionInfo (const std::string &id, int *option, int def, const std::string &desc="", const std::string &cat="") | |
Creates a int option. More... | |
OptionInfo (const std::string &id, SDLKey *option, SDLKey def, const std::string &desc="", const std::string &cat="") | |
Creates a key option. More... | |
OptionInfo (const std::string &id, std::string *option, const char *def, const std::string &desc="", const std::string &cat="") | |
Creates a string option. More... | |
bool * | asBool () const |
Gets a bool option pointer. More... | |
int * | asInt () const |
Gets an int option pointer. More... | |
std::string * | asString () const |
Gets a string option pointer. More... | |
SDLKey * | asKey () const |
Gets a key option pointer. More... | |
void | load (const YAML::Node &node) const |
Loads the option from YAML. More... | |
void | load (const std::map< std::string, std::string > &map) const |
Loads the option from a map. More... | |
void | save (YAML::Node &node) const |
Saves the option to YAML. More... | |
void | reset () const |
Resets the option to default. More... | |
OptionType | type () const |
Gets the option type. More... | |
std::string | description () const |
Gets the option description. More... | |
std::string | category () const |
Gets the option category. More... | |
Helper class that ties metadata to particular options to help in serializing and stuff.
The option variable must already exist, this info just points to it. Does some special shenanigans to be able to be tied to different variable types.
OpenXcom::OptionInfo::OptionInfo | ( | const std::string & | id, |
bool * | option, | ||
bool | def, | ||
const std::string & | desc = "" , |
||
const std::string & | cat = "" |
||
) |
OpenXcom::OptionInfo::OptionInfo | ( | const std::string & | id, |
int * | option, | ||
int | def, | ||
const std::string & | desc = "" , |
||
const std::string & | cat = "" |
||
) |
OpenXcom::OptionInfo::OptionInfo | ( | const std::string & | id, |
SDLKey * | option, | ||
SDLKey | def, | ||
const std::string & | desc = "" , |
||
const std::string & | cat = "" |
||
) |
OpenXcom::OptionInfo::OptionInfo | ( | const std::string & | id, |
std::string * | option, | ||
const char * | def, | ||
const std::string & | desc = "" , |
||
const std::string & | cat = "" |
||
) |
bool * OpenXcom::OptionInfo::asBool | ( | ) | const |
Gets a bool option pointer.
Returns the pointer to the boolean option, or throws an exception if it's not a boolean.
int * OpenXcom::OptionInfo::asInt | ( | ) | const |
Gets an int option pointer.
Returns the pointer to the integer option, or throws an exception if it's not a integer.
SDLKey * OpenXcom::OptionInfo::asKey | ( | ) | const |
Gets a key option pointer.
Returns the pointer to the key option, or throws an exception if it's not a key.
std::string * OpenXcom::OptionInfo::asString | ( | ) | const |
Gets a string option pointer.
Returns the pointer to the string option, or throws an exception if it's not a string.
std::string OpenXcom::OptionInfo::category | ( | ) | const |
std::string OpenXcom::OptionInfo::description | ( | ) | const |
void OpenXcom::OptionInfo::load | ( | const YAML::Node & | node | ) | const |
Loads the option from YAML.
Loads an option value from the corresponding YAML.
node | Options YAML node. |
void OpenXcom::OptionInfo::load | ( | const std::map< std::string, std::string > & | map | ) | const |
Loads the option from a map.
Loads an option value from the corresponding map (eg.
for command-line options).
map | Options map. |
void OpenXcom::OptionInfo::reset | ( | ) | const |
Resets the option to default.
Resets an option back to its default value.
void OpenXcom::OptionInfo::save | ( | YAML::Node & | node | ) | const |
Saves the option to YAML.
Saves an option value to the corresponding YAML.
node | Options YAML node. |
OptionType OpenXcom::OptionInfo::type | ( | ) | const |
Gets the option type.
Returns the variable type of the option.