2 Commits
1.1 ... master

View File

@@ -675,6 +675,7 @@ minipp::EResult minipp::MiniPPFile::Values::ArrayValue::Parse(const std::string&
{ {
if (c == '[') if (c == '[')
{ {
// TODO: This would not be allowed by standard. Add EXT_ALLOW_MULTIDIMENSIONAL_ARRAY
if (++bracketCounter > 1) if (++bracketCounter > 1)
currentElement += c; currentElement += c;
} }
@@ -712,7 +713,7 @@ minipp::EResult minipp::MiniPPFile::Values::ArrayValue::Parse(const std::string&
EResult result; EResult result;
for (auto& elem : elements) for (auto& elem : elements)
{ {
auto parsed = ParseValue(elem, &result); auto parsed = ParseValue(elem, &result);
if (parsed == nullptr) if (parsed == nullptr)
return result; return result;
@@ -801,15 +802,31 @@ minipp::EResult minipp::MiniPPFile::Section::GetSubSection(const std::string& ke
minipp::EResult minipp::MiniPPFile::Section::SetSubSection(const std::string& name, std::unique_ptr<Section> value, bool allowOverwrite) noexcept minipp::EResult minipp::MiniPPFile::Section::SetSubSection(const std::string& name, std::unique_ptr<Section> value, bool allowOverwrite) noexcept
{ {
if (m_subSections.find(name) != m_subSections.end()) auto pathIndex = name.find('.');
if (!allowOverwrite) std::string thisName = name;
return EResult::SectionAlreadyPresent; std::string rest{};
else if (pathIndex != std::string::npos)
delete m_subSections[name]; {
thisName = name.substr(0, pathIndex);
rest = name.substr(pathIndex + 1);
}
m_subSections[name] = value.release(); if (rest.empty())
{
if (m_subSections.find(thisName) != m_subSections.end())
if (!allowOverwrite)
return EResult::SectionAlreadyPresent;
else
delete m_subSections[thisName];
return EResult::Success; m_subSections[thisName] = value.release();
return EResult::Success;
}
if (m_subSections.find(thisName) == m_subSections.end())
m_subSections[thisName] = new Section();
return m_subSections[thisName]->SetSubSection(rest, std::move(value), allowOverwrite);
} }
minipp::EResult minipp::MiniPPFile::WriteSection(const Section* section, std::ofstream& ofs, std::string partTreeName) noexcept minipp::EResult minipp::MiniPPFile::WriteSection(const Section* section, std::ofstream& ofs, std::string partTreeName) noexcept