mirror of
https://github.com/mariiaan/minipp.git
synced 2026-05-14 10:11:17 +02:00
Fix another bug in section names when writing
This commit is contained in:
@@ -197,7 +197,7 @@ namespace minipp
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unique_ptr<Value> ParseValue(std::string value);
|
static std::unique_ptr<Value> ParseValue(std::string value);
|
||||||
static minipp::EResult WriteSection(const Section* section, std::ofstream& ofs, const std::string& partTreeName) noexcept;
|
static minipp::EResult WriteSection(const Section* section, std::ofstream& ofs, std::string partTreeName) noexcept;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EResult Parse(const std::string& path) noexcept;
|
EResult Parse(const std::string& path) noexcept;
|
||||||
@@ -695,7 +695,7 @@ std::unique_ptr<minipp::MiniPPFile::Value> minipp::MiniPPFile::ParseValue(std::s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minipp::EResult minipp::MiniPPFile::WriteSection(const Section* section, std::ofstream& ofs, const std::string& partTreeName) noexcept
|
minipp::EResult minipp::MiniPPFile::WriteSection(const Section* section, std::ofstream& ofs, std::string partTreeName) noexcept
|
||||||
{
|
{
|
||||||
if (section->m_values.size() > 0)
|
if (section->m_values.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -719,6 +719,8 @@ minipp::EResult minipp::MiniPPFile::WriteSection(const Section* section, std::of
|
|||||||
}
|
}
|
||||||
ofs << std::endl;
|
ofs << std::endl;
|
||||||
}
|
}
|
||||||
|
if (!partTreeName.empty())
|
||||||
|
partTreeName += ".";
|
||||||
|
|
||||||
for (const auto& pair : section->m_subSections)
|
for (const auto& pair : section->m_subSections)
|
||||||
{
|
{
|
||||||
@@ -731,11 +733,8 @@ minipp::EResult minipp::MiniPPFile::WriteSection(const Section* section, std::of
|
|||||||
for (const auto& comment : pair.second->m_comments)
|
for (const auto& comment : pair.second->m_comments)
|
||||||
ofs << comment << std::endl;
|
ofs << comment << std::endl;
|
||||||
|
|
||||||
ofs << "[";
|
ofs << "[" << partTreeName << pair.first << "]" << std::endl;
|
||||||
if (!partTreeName.empty())
|
auto result = WriteSection(pair.second, ofs, partTreeName + pair.first);
|
||||||
ofs << partTreeName << ".";
|
|
||||||
ofs << pair.first << "]" << std::endl;
|
|
||||||
auto result = WriteSection(pair.second, ofs, (partTreeName.empty() ? "" : (partTreeName + ".")) + pair.first);
|
|
||||||
if (!IsResultOk(result))
|
if (!IsResultOk(result))
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user