X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FTraits.hh;h=2e848821939f8f153d75a9da2db930b07d5c45ab;hb=794b9c2774e19c13ac7eee82ec56fd0f42ede5ff;hp=d479f45b71926758b57010db32282e37a89e4033;hpb=958bdb52c39fa39f4ef91cafd9628bcb4f85a03c;p=senf.git diff --git a/Utils/Console/Traits.hh b/Utils/Console/Traits.hh index d479f45..2e84882 100644 --- a/Utils/Console/Traits.hh +++ b/Utils/Console/Traits.hh @@ -133,6 +133,9 @@ namespace console { template void parse(ParseCommandInfo::TokensRange const & tokens, Type & out); + template + void format(Type const & value, std::ostream & os); + #ifndef DOXYGEN // Parse bool: true/false, yes/no, enabled/disabled, 0/1 @@ -181,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) \ @@ -204,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////////////////////////////////////////