2015-07-07 00:50:49 +02:00
|
|
|
#ifndef IOUTILITIES_INIFILE_H
|
|
|
|
#define IOUTILITIES_INIFILE_H
|
|
|
|
|
2016-08-29 15:35:48 +02:00
|
|
|
#include "../global.h"
|
2015-07-07 00:50:49 +02:00
|
|
|
|
|
|
|
#include <map>
|
2015-09-01 16:06:37 +02:00
|
|
|
#include <string>
|
2017-05-01 03:13:11 +02:00
|
|
|
#include <vector>
|
2015-07-07 00:50:49 +02:00
|
|
|
|
2019-06-10 21:56:46 +02:00
|
|
|
namespace CppUtilities {
|
2015-07-07 00:50:49 +02:00
|
|
|
|
2017-05-01 03:13:11 +02:00
|
|
|
class CPP_UTILITIES_EXPORT IniFile {
|
2015-07-07 00:50:49 +02:00
|
|
|
public:
|
|
|
|
IniFile();
|
|
|
|
|
2017-05-04 22:44:00 +02:00
|
|
|
std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> &data();
|
|
|
|
const std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> &data() const;
|
2015-07-07 00:50:49 +02:00
|
|
|
void parse(std::istream &inputStream);
|
|
|
|
void make(std::ostream &outputStream);
|
|
|
|
|
|
|
|
private:
|
2017-05-04 22:44:00 +02:00
|
|
|
std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> m_data;
|
2015-07-07 00:50:49 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructs an empty ini file.
|
|
|
|
*/
|
|
|
|
inline IniFile::IniFile()
|
2017-05-01 03:13:11 +02:00
|
|
|
{
|
|
|
|
}
|
2015-07-07 00:50:49 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the data of the file.
|
2016-06-10 22:59:22 +02:00
|
|
|
* \remarks
|
2016-01-18 23:41:30 +01:00
|
|
|
* - The returned pairs represent the [scope names] and the contained "key = value"-pairs.
|
|
|
|
* - The data might be modified and then saved using the make() method.
|
2015-07-07 00:50:49 +02:00
|
|
|
*/
|
2017-05-04 22:44:00 +02:00
|
|
|
inline std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> &IniFile::data()
|
2015-07-07 00:50:49 +02:00
|
|
|
{
|
|
|
|
return m_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the data of the file.
|
2016-06-10 22:59:22 +02:00
|
|
|
* \remarks The returned pairs represent the [scope names] and the contained "key = value"-pairs.
|
2015-07-07 00:50:49 +02:00
|
|
|
*/
|
2017-05-04 22:44:00 +02:00
|
|
|
inline const std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> &IniFile::data() const
|
2015-07-07 00:50:49 +02:00
|
|
|
{
|
|
|
|
return m_data;
|
|
|
|
}
|
|
|
|
|
2019-06-10 21:56:46 +02:00
|
|
|
} // namespace CppUtilities
|
2015-07-07 00:50:49 +02:00
|
|
|
|
|
|
|
#endif // IOUTILITIES_INIFILE_H
|