20 #include <yaml-cpp/yaml.h> 28 enum OptionType { OPTION_BOOL, OPTION_INT, OPTION_STRING, OPTION_KEY };
38 std::string _id, _desc, _cat;
40 union {
bool *b;
int *i; std::string *s; SDLKey *k; } _ref;
41 union {
bool b;
int i;
const char *s; SDLKey k; } _def;
44 OptionInfo(
const std::string &
id,
bool *option,
bool def,
const std::string &desc =
"",
const std::string &cat =
"");
46 OptionInfo(
const std::string &
id,
int *option,
int def,
const std::string &desc =
"",
const std::string &cat =
"");
48 OptionInfo(
const std::string &
id, SDLKey *option, SDLKey def,
const std::string &desc =
"",
const std::string &cat =
"");
50 OptionInfo(
const std::string &
id, std::string *option,
const char *def,
const std::string &desc =
"",
const std::string &cat =
"");
58 SDLKey *
asKey()
const;
60 void load(
const YAML::Node &node)
const;
62 void load(
const std::map<std::string, std::string> &map)
const;
64 void save(YAML::Node &node)
const;
68 OptionType
type()
const;
int * asInt() const
Gets an int option pointer.
Definition: OptionInfo.cpp:238
Helper class that ties metadata to particular options to help in serializing and stuff.
Definition: OptionInfo.h:35
std::string category() const
Gets the option category.
Definition: OptionInfo.cpp:214
std::string description() const
Gets the option description.
Definition: OptionInfo.cpp:204
bool * asBool() const
Gets a bool option pointer.
Definition: OptionInfo.cpp:224
OptionInfo(const std::string &id, bool *option, bool def, const std::string &desc="", const std::string &cat="")
Creates a bool option.
Definition: OptionInfo.cpp:34
void reset() const
Resets the option to default.
Definition: OptionInfo.cpp:171
SDLKey * asKey() const
Gets a key option pointer.
Definition: OptionInfo.cpp:252
void save(YAML::Node &node) const
Saves the option to YAML.
Definition: OptionInfo.cpp:149
void load(const YAML::Node &node) const
Loads the option from YAML.
Definition: OptionInfo.cpp:86
OptionType type() const
Gets the option type.
Definition: OptionInfo.cpp:194
std::string * asString() const
Gets a string option pointer.
Definition: OptionInfo.cpp:266
Definition: BaseInfoState.cpp:40