diff --git a/io/inifile.cpp b/io/inifile.cpp index 5feab80..9ec9264 100644 --- a/io/inifile.cpp +++ b/io/inifile.cpp @@ -25,7 +25,10 @@ void IniFile::parse(std::istream &inputStream) // define actions for state machine // called when key/value pair is complete const auto finishKeyValue = [&scope, &key, &value, &whitespace, this] { - m_data[scope].insert(make_pair(key, value)); + if(m_data.empty() || m_data.back().first != scope) { + m_data.emplace_back(make_pair(scope, decltype(m_data)::value_type::second_type())); + } + m_data.back().second.insert(make_pair(key, value)); key.clear(); value.clear(); whitespace = 0; diff --git a/io/inifile.h b/io/inifile.h index d5605eb..7ad0f19 100644 --- a/io/inifile.h +++ b/io/inifile.h @@ -3,6 +3,7 @@ #include "../application/global.h" +#include #include #include @@ -13,13 +14,13 @@ class LIB_EXPORT IniFile public: IniFile(); - std::map > &data(); - const std::map > &data() const; + std::vector > > &data(); + const std::vector > > &data() const; void parse(std::istream &inputStream); void make(std::ostream &outputStream); private: - std::map > m_data; + std::vector > > m_data; }; /*! @@ -35,7 +36,7 @@ inline IniFile::IniFile() * - The values in the returned map are maps representing "key = value"-pairs within the scope. * - The data might be modified an saved using the make() method. */ -inline std::map > &IniFile::data() +inline std::vector > > &IniFile::data() { return m_data; } @@ -46,7 +47,7 @@ inline std::map > &IniFile: * - The keys in the returned map represent the [scope name]s. * - The values in the returned map are maps representing "key = value"-pairs within the scope. */ -inline const std::map > &IniFile::data() const +inline const std::vector > > &IniFile::data() const { return m_data; }