#define prefix_
///////////////////////////////ct.p////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+// senf::console::ArgumentTraits< senf::console::ValueRange<T> >
+
template <class T>
prefix_ void senf::console::ArgumentTraits< senf::console::ValueRange<T> >::
parse(ParseCommandInfo::TokensRange const & tokens, type & out)
if (tokens.size() != 1)
throw senf::console::SyntaxErrorException("parameter syntax error");
std::string v (tokens.begin()[0].value());
- unsigned i (v.find(':'));
+ std::string::size_type i (v.find(':'));
try {
if (i == std::string::npos)
out.low = out.high = boost::lexical_cast<T>(v);
return ss.str();
}
+///////////////////////////////////////////////////////////////////////////
+// senf::console::ReturnValueTraits< senf::console::ValueRange<T> >
+
template <class T>
prefix_ void senf::console::ReturnValueTraits< senf::console::ValueRange<T> >::
format(type const & value, std::ostream & os)
{
- os << value.low;
+ os << senf::console::str(value.low);
if (value.low != value.high)
- os << ':' << value.high;
+ os << ':' << senf::console::str(value.high);
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::ArgumentTraits< senf::console::FlagCollection<Enum> >
+
+template <class Enum>
+prefix_ void senf::console::ArgumentTraits< senf::console::FlagCollection<Enum> >::
+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 <class Enum>
+prefix_ std::string
+senf::console::ArgumentTraits< senf::console::FlagCollection<Enum> >::description()
+{
+ return ArgumentTraits<Enum>::description();
+}
+
+template <class Enum>
+prefix_ std::string
+senf::console::ArgumentTraits< senf::console::FlagCollection<Enum> >::str(type const & value)
+{
+ std::stringstream ss;
+ senf::console::format(value, ss);
+ return ss.str();
+}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::console::ReturnValueTraits< senf::console::FlagCollection<Enum> >
+
+template <class Enum>
+prefix_ void senf::console::ReturnValueTraits< senf::console::FlagCollection<Enum> >::
+format(type const & value, std::ostream & os)
+{
+ unsigned n (0);
+ std::stringstream ss;
+ unsigned long flag (1);
+ for (unsigned bit (0); bit<sizeof(value.value)*CHAR_BIT; ++bit, flag<<=1) {
+ if (value.value & flag) {
+ if (n++) ss << " ";
+ senf::console::format(static_cast<Enum>(flag), ss);
+ }
+ }
+ os << (n != 1 ? "(" + ss.str() + ")" : ss.str());
}
///////////////////////////////ct.e////////////////////////////////////////