19 #ifndef OPENXCOM_OPTIONINFO_H
20 #define OPENXCOM_OPTIONINFO_H
22 #include <yaml-cpp/yaml.h>
31 enum OptionType { OPTION_BOOL, OPTION_INT, OPTION_STRING, OPTION_KEY };
41 std::string _id, _desc, _cat;
43 union {
bool *b;
int *i; std::string *s; SDLKey *k; } _ref;
44 union {
bool b;
int i;
const char *s; SDLKey k; } _def;
47 OptionInfo(
const std::string &
id,
bool *option,
bool def,
const std::string &desc =
"",
const std::string &cat =
"");
49 OptionInfo(
const std::string &
id,
int *option,
int def,
const std::string &desc =
"",
const std::string &cat =
"");
51 OptionInfo(
const std::string &
id, SDLKey *option, SDLKey def,
const std::string &desc =
"",
const std::string &cat =
"");
53 OptionInfo(
const std::string &
id, std::string *option,
const char *def,
const std::string &desc =
"",
const std::string &cat =
"");
61 SDLKey *
asKey()
const;
63 void load(
const YAML::Node &node)
const;
65 void load(
const std::map<std::string, std::string> &map)
const;
67 void save(YAML::Node &node)
const;
71 OptionType
type()
const;
Helper class that ties metadata to particular options to help in serializing and stuff.
Definition: OptionInfo.h:39
void load(const YAML::Node &node) const
Loads the option from YAML.
Definition: OptionInfo.cpp:85
std::string * asString() const
Gets a string option pointer.
Definition: OptionInfo.cpp:265
bool * asBool() const
Gets a bool option pointer.
Definition: OptionInfo.cpp:223
void save(YAML::Node &node) const
Saves the option to YAML.
Definition: OptionInfo.cpp:148
void reset() const
Resets the option to default.
Definition: OptionInfo.cpp:170
std::string description() const
Gets the option description.
Definition: OptionInfo.cpp:203
int * asInt() const
Gets an int option pointer.
Definition: OptionInfo.cpp:237
OptionInfo(const std::string &id, bool *option, bool def, const std::string &desc="", const std::string &cat="")
Creates a bool option.
Definition: OptionInfo.cpp:33
SDLKey * asKey() const
Gets a key option pointer.
Definition: OptionInfo.cpp:251
std::string category() const
Gets the option category.
Definition: OptionInfo.cpp:213
OptionType type() const
Gets the option type.
Definition: OptionInfo.cpp:193
COPYING:
Definition: BaseInfoState.cpp:41