mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-30 21:50:47 +01:00
fixed GH# 398: PropertyFileConfiguration: input != output
This commit is contained in:
@@ -79,7 +79,32 @@ void PropertyFileConfiguration::save(std::ostream& ostr) const
|
|||||||
MapConfiguration::iterator ed = end();
|
MapConfiguration::iterator ed = end();
|
||||||
while (it != ed)
|
while (it != ed)
|
||||||
{
|
{
|
||||||
ostr << it->first << ": " << it->second << "\n";
|
ostr << it->first << ": ";
|
||||||
|
for (std::string::const_iterator its = it->second.begin(); its != it->second.end(); ++its)
|
||||||
|
{
|
||||||
|
switch (*its)
|
||||||
|
{
|
||||||
|
case '\t':
|
||||||
|
ostr << "\\t";
|
||||||
|
break;
|
||||||
|
case '\r':
|
||||||
|
ostr << "\\r";
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
ostr << "\\n";
|
||||||
|
break;
|
||||||
|
case '\f':
|
||||||
|
ostr << "\\f";
|
||||||
|
break;
|
||||||
|
case '\\':
|
||||||
|
ostr << "\\\\";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ostr << *its;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ostr << "\n";
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,12 +96,14 @@ void PropertyFileConfigurationTest::testSave()
|
|||||||
|
|
||||||
pConf->setString("prop1", "value1");
|
pConf->setString("prop1", "value1");
|
||||||
pConf->setInt("prop2", 42);
|
pConf->setInt("prop2", 42);
|
||||||
|
pConf->setString("prop3", "value\\1\txxx");
|
||||||
|
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
pConf->save(ostr);
|
pConf->save(ostr);
|
||||||
std::string propFile = ostr.str();
|
std::string propFile = ostr.str();
|
||||||
assert (propFile == "prop1: value1\n"
|
assert (propFile == "prop1: value1\n"
|
||||||
"prop2: 42\n");
|
"prop2: 42\n"
|
||||||
|
"prop3: value\\\\1\\txxx\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user