update ConfigIni::Save

This commit is contained in:
Nomango 2020-05-31 22:10:49 +08:00
parent a62f1f4d2d
commit 7f902e3343
1 changed files with 10 additions and 6 deletions

View File

@ -158,16 +158,20 @@ bool ConfigIni::Save(std::ostream& os)
std::sort(keys.begin(), keys.end()); std::sort(keys.begin(), keys.end());
// Output to ini // Output to ini
for (const auto& key : keys) std::ostream::sentry ok(os);
if (ok)
{ {
os << '[' << key << ']' << std::endl; for (const auto& key : keys)
for (const auto& pair : sections_[key])
{ {
os << pair.first << " = " << pair.second << std::endl; os << '[' << key << ']' << std::endl;
for (const auto& pair : sections_[key])
{
os << pair.first << " = " << pair.second << std::endl;
}
os << std::endl;
} }
os << std::endl;
} }
return false; return !os.fail();
} }
ConfigIni::SectionMap ConfigIni::GetSectionMap() const ConfigIni::SectionMap ConfigIni::GetSectionMap() const