// Custom includes
#include <sstream>
#include <boost/lexical_cast.hpp>
+#include <boost/format.hpp>
#include <senf/Utils/TypeInfo.hh>
#define prefix_ inline
template <class Type>
prefix_ std::string senf::console::ArgumentTraits<Type>::description()
{
- std::string type (prettyName(typeid(Type)));
- std::string::size_type i (type.rfind(':'));
- return i == std::string::npos ? type : type.substr(i+1);
+ return prettyBaseName(typeid(Type));
}
template <class Type>
{
std::stringstream ss;
senf::console::format(value, ss);
+ std::string rv (ss.str());
+
+ if (rv.empty() || ! boost::algorithm::all(rv, CommandParser::isWordChar)) {
+ for (std::string::size_type i (0); i < rv.size(); ++i)
+ if (rv[i] == '"' || rv[i] == '\\')
+ rv.insert(i++,"\\");
+ else if (rv[i] < ' ' || rv[i] > 126) {
+ rv.insert(i+1, (boost::format("x%02x")
+ % unsigned(static_cast<unsigned char>(rv[i]))).str().c_str());
+ rv[i] = '\\';
+ i += 3;
+ }
+
+ rv.insert(0,"\"");
+ rv.push_back('"');
+ return rv;
+ }
+
return ss.str();
}
+///////////////////////////////////////////////////////////////////////////
+// senf::console::detail::CharArgumentTraits<CharT>
+
+template <class CharT>
+prefix_ void senf::console::detail::CharArgumentTraits<CharT>::
+parse(ParseCommandInfo::TokensRange const & tokens, CharT & out)
+{
+ typename base::type v;
+ base::parse(tokens,v);
+ out = v;
+}
+
+template <class CharT>
+prefix_ std::string senf::console::detail::CharArgumentTraits<CharT>::description()
+{
+ return std::numeric_limits<CharT>::is_signed ? "byte" : "ubyte";
+}
+
///////////////////////////////cti.e///////////////////////////////////////
#undef prefix_