mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 02:22:57 +01:00
format support both raw and STL strings
This commit is contained in:
parent
fd6433eb4e
commit
a499447b6a
@ -226,8 +226,16 @@ namespace
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
str << RefAnyCast<std::string>(*itVal++);
|
||||
{
|
||||
const Any& val = *itVal++;
|
||||
if (val.type() == typeid(char*))
|
||||
str << AnyCast<char*>(val);
|
||||
else if (val.type() == typeid(const char*))
|
||||
str << AnyCast<const char*>(val);
|
||||
else
|
||||
str << RefAnyCast<std::string>(val);
|
||||
break;
|
||||
}
|
||||
case 'z':
|
||||
str << AnyCast<std::size_t>(*itVal++);
|
||||
break;
|
||||
|
@ -325,7 +325,13 @@ void FormatTest::testString()
|
||||
std::string foo("foo");
|
||||
std::string s(format("%s", foo));
|
||||
assert (s == "foo");
|
||||
|
||||
|
||||
s = format("%s", "foo");
|
||||
assert (s == "foo");
|
||||
|
||||
s = format("%s", static_cast<const char*>("foo"));
|
||||
assert (s == "foo");
|
||||
|
||||
s = format("%5s", foo);
|
||||
assert (s == " foo");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user