19 #ifndef OPENXCOM_OPTIONINFO_H
20 #define OPENXCOM_OPTIONINFO_H
22 #include <yaml-cpp/yaml.h>
30 enum OptionType { OPTION_BOOL, OPTION_INT, OPTION_STRING, OPTION_KEY };
40 std::string _id, _desc, _cat;
42 union {
bool *b;
int *i; std::string *s; SDLKey *k; } _ref;
43 union {
bool b;
int i;
const char *s; SDLKey k; } _def;
46 OptionInfo(
const std::string &
id,
bool *option,
bool def,
const std::string &desc =
"",
const std::string &cat =
"");
48 OptionInfo(
const std::string &
id,
int *option,
int def,
const std::string &desc =
"",
const std::string &cat =
"");
50 OptionInfo(
const std::string &
id, SDLKey *option, SDLKey def,
const std::string &desc =
"",
const std::string &cat =
"");
52 OptionInfo(
const std::string &
id, std::string *option,
const char *def,
const std::string &desc =
"",
const std::string &cat =
"");
60 SDLKey *
asKey()
const;
62 void load(
const YAML::Node &node)
const;
64 void load(
const std::map<std::string, std::string> &map)
const;
66 void save(YAML::Node &node)
const;
70 OptionType
type()
const;
bool * asBool() const
Gets a bool option pointer.
Definition: OptionInfo.cpp:223
int * asInt() const
Gets an int option pointer.
Definition: OptionInfo.cpp:237
Helper class that ties metadata to particular options to help in serializing and stuff.
Definition: OptionInfo.h:37
void load(const YAML::Node &node) const
Loads the option from YAML.
Definition: OptionInfo.cpp:85
void reset() const
Resets the option to default.
Definition: OptionInfo.cpp:170
std::string description() const
Gets the option description.
Definition: OptionInfo.cpp:203
std::string * asString() const
Gets a string option pointer.
Definition: OptionInfo.cpp:265
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
OptionType type() const
Gets the option type.
Definition: OptionInfo.cpp:193
void save(YAML::Node &node) const
Saves the option to YAML.
Definition: OptionInfo.cpp:148
std::string category() const
Gets the option category.
Definition: OptionInfo.cpp:213
SDLKey * asKey() const
Gets a key option pointer.
Definition: OptionInfo.cpp:251