mirror of
https://github.com/mariiaan/minipp.git
synced 2026-05-14 10:11:17 +02:00
Fix bug in section writing
This commit is contained in:
@@ -23,7 +23,7 @@ namespace minipp
|
|||||||
FileIOError = -5,
|
FileIOError = -5,
|
||||||
InvalidDataType = -6,
|
InvalidDataType = -6,
|
||||||
FormatError = -7,
|
FormatError = -7,
|
||||||
ArrayDataTypeInconsistency = -8,
|
ArrayDataTypeInconsistency = -8,
|
||||||
|
|
||||||
/* OK Codes */
|
/* OK Codes */
|
||||||
Success = +1,
|
Success = +1,
|
||||||
@@ -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) noexcept;
|
static minipp::EResult WriteSection(const Section* section, std::ofstream& ofs, const 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) noexcept
|
minipp::EResult minipp::MiniPPFile::WriteSection(const Section* section, std::ofstream& ofs, const std::string& partTreeName) noexcept
|
||||||
{
|
{
|
||||||
if (section->m_values.size() > 0)
|
if (section->m_values.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -731,8 +731,11 @@ 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 << "[" << pair.first << "]" << std::endl;
|
ofs << "[";
|
||||||
auto result = WriteSection(pair.second, ofs);
|
if (!partTreeName.empty())
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
@@ -858,7 +861,7 @@ void minipp::MiniPPFile::Write(const std::string& path) const noexcept
|
|||||||
if (!ofs.is_open())
|
if (!ofs.is_open())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WriteSection(&m_rootSection, ofs);
|
WriteSection(&m_rootSection, ofs, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool minipp::MiniPPFile::IsResultOk(EResult result) noexcept
|
bool minipp::MiniPPFile::IsResultOk(EResult result) noexcept
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ is_completed = false
|
|||||||
|
|
||||||
# This section is about
|
# This section is about
|
||||||
# the settings of a game window
|
# the settings of a game window
|
||||||
[window]
|
[game.window]
|
||||||
dimensions = [1280, 720]
|
dimensions = [1280, 720]
|
||||||
close_flags = 101011b
|
close_flags = 101011b
|
||||||
hex_test = deadbeefh
|
hex_test = deadbeefh
|
||||||
|
|
||||||
[platform]
|
[game.window.platform]
|
||||||
targets = ["win32", "macOS", "linux"]
|
targets = ["win32", "macOS", "linux"]
|
||||||
points = [[0, 0], [1, 0], [1, 1], [0, 1]]
|
points = [[0, 0], [1, 0], [1, 1], [0, 1]]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user