OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
OpenXcom::OptionInfo Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

OpenXcom::OptionInfo::OptionInfo ( const std::string &  id,
bool *  option,
bool  def,
const std::string &  desc = "",
const std::string &  cat = "" 
)

Creates a bool option.

Creates info for a boolean option.

Parameters
idString ID used in serializing.
optionPointer to the option.
defDefault option value.
descLanguage ID for the option description (if any).
catLanguage ID for the option category (if any).
OpenXcom::OptionInfo::OptionInfo ( const std::string &  id,
int *  option,
int  def,
const std::string &  desc = "",
const std::string &  cat = "" 
)

Creates a int option.

Creates info for an integer option.

Parameters
idString ID used in serializing.
optionPointer to the option.
defDefault option value.
descLanguage ID for the option description (if any).
catLanguage ID for the option category (if any).
OpenXcom::OptionInfo::OptionInfo ( const std::string &  id,
SDLKey *  option,
SDLKey  def,
const std::string &  desc = "",
const std::string &  cat = "" 
)

Creates a key option.

Creates info for a keyboard shortcut option.

Parameters
idString ID used in serializing.
optionPointer to the option.
defDefault option value.
descLanguage ID for the option description (if any).
catLanguage ID for the option category (if any).
OpenXcom::OptionInfo::OptionInfo ( const std::string &  id,
std::string *  option,
const char *  def,
const std::string &  desc = "",
const std::string &  cat = "" 
)

Creates a string option.

Creates info for a string option.

Parameters
idString ID used in serializing.
optionPointer to the option.
defDefault option value.
descLanguage ID for the option description (if any).
catLanguage ID for the option category (if any).

Member Function Documentation

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.

Returns
Pointer to the option.
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.

Returns
Pointer to the option.
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.

Returns
Pointer to the option.
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.

Returns
Pointer to the option.
std::string OpenXcom::OptionInfo::category ( ) const

Gets the option category.

Returns the category of the option.

Options with categories show up in the Options screens.

Returns
Language string ID for the category.
std::string OpenXcom::OptionInfo::description ( ) const

Gets the option description.

Returns the description of the option.

Options with descriptions show up in the Options screens.

Returns
Language string ID for the description.
void OpenXcom::OptionInfo::load ( const YAML::Node &  node) const

Loads the option from YAML.

Loads an option value from the corresponding YAML.

Parameters
nodeOptions 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).

Parameters
mapOptions 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.

Parameters
nodeOptions YAML node.
OptionType OpenXcom::OptionInfo::type ( ) const

Gets the option type.

Returns the variable type of the option.

Returns
Option type.

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