X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FTraits.ct;h=8749e9a8f2d6f8c1349366fcf21174ad0b64376f;hb=9a4ab28bb53bc1a7719141a2263282d4cf73b258;hp=d9d5a98b001ce6679f13ee3c7041be6aed616153;hpb=958bdb52c39fa39f4ef91cafd9628bcb4f85a03c;p=senf.git diff --git a/Utils/Console/Traits.ct b/Utils/Console/Traits.ct index d9d5a98..8749e9a 100644 --- a/Utils/Console/Traits.ct +++ b/Utils/Console/Traits.ct @@ -31,7 +31,7 @@ ///////////////////////////////ct.p//////////////////////////////////////// template -prefix_ void +prefix_ bool senf::console::senf_console_parse_argument(ParseCommandInfo::TokensRange const & tokens, Type & out) { @@ -44,6 +44,58 @@ senf::console::senf_console_parse_argument(ParseCommandInfo::TokensRange const & catch (std::bad_cast & ex) { throw SyntaxErrorException("parameter syntax error"); } + return false; +} + +/////////////////////////////////////////////////////////////////////////// +// senf::console::ArgumentTraits< senf::console::FlagCollection > + +template +prefix_ void senf::console::ArgumentTraits< senf::console::FlagCollection >:: +parse(ParseCommandInfo::TokensRange const & tokens, type & out) +{ + CheckedArgumentIteratorWrapper arg (tokens); + out.value = 0; + while (arg) { + Enum v; + senf::console::parse( *(arg++), v); + out.value |= v; + } +} + +template +prefix_ std::string +senf::console::ArgumentTraits< senf::console::FlagCollection >::description() +{ + return ArgumentTraits::description(); +} + +template +prefix_ std::string +senf::console::ArgumentTraits< senf::console::FlagCollection >::str(type const & value) +{ + std::stringstream ss; + senf::console::format(value, ss); + return ss.str(); +} + +/////////////////////////////////////////////////////////////////////////// +// senf::console::ReturnValueTraits< senf::console::FlagCollection > + +template +prefix_ void senf::console::ReturnValueTraits< senf::console::FlagCollection >:: +format(type const & value, std::ostream & os) +{ + unsigned n (0); + std::stringstream ss; + unsigned long flag (1); + for (unsigned bit (0); bit(flag), ss); + } + } + os << (n != 1 ? "(" + ss.str() + ")" : ss.str()); } ///////////////////////////////ct.e////////////////////////////////////////