options: add flag option type

This commit is contained in:
wm4
2015-03-04 17:20:47 +01:00
parent 3cd394995f
commit f447179c59
2 changed files with 121 additions and 0 deletions

View File

@@ -52,6 +52,7 @@ extern const m_option_type_t m_option_type_keyvalue_list;
extern const m_option_type_t m_option_type_time;
extern const m_option_type_t m_option_type_rel_time;
extern const m_option_type_t m_option_type_choice;
extern const m_option_type_t m_option_type_flags;
extern const m_option_type_t m_option_type_msglevels;
extern const m_option_type_t m_option_type_print_fn;
extern const m_option_type_t m_option_type_subconfig;
@@ -626,6 +627,9 @@ extern const char m_option_path_separator;
#define OPT_CHOICE_(optname, varname, flags, choices, ...) \
OPT_GENERAL(int, optname, varname, flags, M_CHOICES(choices), __VA_ARGS__)
#define OPT_FLAGS(...) \
OPT_CHOICE_(__VA_ARGS__, .type = &m_option_type_flags)
// Union of choices and an int range. The choice values can be included in the
// int range, or be completely separate - both works.
#define OPT_CHOICE_OR_INT_(optname, varname, flags, minval, maxval, choices, ...) \