git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1526
270642c3-0616-0410-b53a-bc976706d245
#include "Traits.ih"
// Custom includes
+#include <boost/format.hpp>
#include <senf/Utils/senfassert.hh>
//#include "Traits.mpp"
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;
template <class CharT>
prefix_ std::string senf::console::detail::CharArgumentTraits<CharT>::description()
{
- return prettyBaseName(typeid(CharT));
+ return std::numeric_limits<CharT>::is_signed ? "byte" : "unsigned byte";
}
///////////////////////////////cti.e///////////////////////////////////////
BOOST_CHECK_EQUAL( ss.str(), "disabled\n" "enabled\n" );
}
+BOOST_AUTO_UNIT_TEST(stringTraits)
+{
+ BOOST_CHECK_EQUAL(
+ senf::console::ArgumentTraits<std::string>::str("Test\nOf\nA \"String\"\x01\x7f\xa0\xff"),
+ "\"Test\\x0aOf\\x0aA \\\"String\\\"\\x01\\x7f\\xa0\\xff\"" );
+}
+
BOOST_AUTO_UNIT_TEST(enumSupport)
{
senf::console::Executor executor;