X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FTraits.hh;h=2e848821939f8f153d75a9da2db930b07d5c45ab;hb=92f8630b75f3ef50e73c48cde58645dcd1534e27;hp=f7fa1e4e7201c45d4b8bda716030b14287a5e11c;hpb=7ff3c55db7420433cea0bd7f0fe6c82583f78d4f;p=senf.git diff --git a/Utils/Console/Traits.hh b/Utils/Console/Traits.hh index f7fa1e4..2e84882 100644 --- a/Utils/Console/Traits.hh +++ b/Utils/Console/Traits.hh @@ -184,6 +184,10 @@ namespace console { This macro will register an enum type and it's enumerators defined at namespace scope. See \ref SENF_CONSOLE_REGISTER_ENUM_MEMBER to register a member enum type. + \note All enumerator values must be unique ignoring case. + + The enum parser will accept any unique initial substring ignoring case as valid enum value. + \ingroup console_commands */ # define SENF_CONSOLE_REGISTER_ENUM(Type, Values) \ @@ -207,6 +211,32 @@ namespace console { # define SENF_CONSOLE_REGISTER_ENUM_MEMBER(Class, Type, Values) \ SENF_CONSOLE_REGISTER_ENUM_(Class::, Type, Values) + template + struct FlagCollection + { + operator unsigned long() const { return value; } + FlagCollection() : value (0) {} + FlagCollection(unsigned long value_) : value (value_) {} + FlagCollection(Enum value_) : value (value_) {} + unsigned long value; + }; + + template + struct ArgumentTraits< FlagCollection > + { + typedef FlagCollection type; + static void parse(ParseCommandInfo::TokensRange const & tokens, type & out); + static std::string description(); + static std::string str(type const & value); + }; + + template + struct ReturnValueTraits< FlagCollection > + { + typedef FlagCollection type; + static void format(type const & value, std::ostream & os); + }; + }} ///////////////////////////////hh.e////////////////////////////////////////