mirror of
https://github.com/mariiaan/minipp.git
synced 2026-05-14 10:11:17 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 136789d68d | |||
| 2c2c567616 |
@@ -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;
|
||||||
}
|
}
|
||||||
@@ -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('.');
|
||||||
|
std::string thisName = name;
|
||||||
|
std::string rest{};
|
||||||
|
if (pathIndex != std::string::npos)
|
||||||
|
{
|
||||||
|
thisName = name.substr(0, pathIndex);
|
||||||
|
rest = name.substr(pathIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rest.empty())
|
||||||
|
{
|
||||||
|
if (m_subSections.find(thisName) != m_subSections.end())
|
||||||
if (!allowOverwrite)
|
if (!allowOverwrite)
|
||||||
return EResult::SectionAlreadyPresent;
|
return EResult::SectionAlreadyPresent;
|
||||||
else
|
else
|
||||||
delete m_subSections[name];
|
delete m_subSections[thisName];
|
||||||
|
|
||||||
m_subSections[name] = value.release();
|
|
||||||
|
|
||||||
|
m_subSections[thisName] = value.release();
|
||||||
return EResult::Success;
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user