mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 18:45:10 +01:00
Merge pull request #266 from tokiloki/format
format support both raw and STL strings
This commit is contained in:
commit
89b7228461
@ -206,8 +206,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;
|
||||
|
@ -305,7 +305,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