Use type aliases in IniFile

This commit is contained in:
Martchus 2019-12-27 01:46:21 +01:00
parent 1ce06517cc
commit c554aebf07
1 changed files with 11 additions and 6 deletions

View File

@ -3,6 +3,7 @@
#include "../global.h" #include "../global.h"
#include <iosfwd>
#include <map> #include <map>
#include <string> #include <string>
#include <vector> #include <vector>
@ -11,15 +12,19 @@ namespace CppUtilities {
class CPP_UTILITIES_EXPORT IniFile { class CPP_UTILITIES_EXPORT IniFile {
public: public:
IniFile(); using ScopeName = std::string;
using ScopeData = std::multimap<std::string, std::string>;
using Scope = std::pair<ScopeName, ScopeData>;
using ScopeList = std::vector<Scope>;
std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> &data(); IniFile();
const std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> &data() const; ScopeList &data();
const ScopeList &data() const;
void parse(std::istream &inputStream); void parse(std::istream &inputStream);
void make(std::ostream &outputStream); void make(std::ostream &outputStream);
private: private:
std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> m_data; ScopeList m_data;
}; };
/*! /*!
@ -35,7 +40,7 @@ inline IniFile::IniFile()
* - The returned pairs represent the [scope names] and the contained "key = value"-pairs. * - 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. * - The data might be modified and then saved using the make() method.
*/ */
inline std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> &IniFile::data() inline IniFile::ScopeList &IniFile::data()
{ {
return m_data; return m_data;
} }
@ -44,7 +49,7 @@ inline std::vector<std::pair<std::string, std::multimap<std::string, std::string
* \brief Returns the data of the file. * \brief Returns the data of the file.
* \remarks The returned pairs represent the [scope names] and the contained "key = value"-pairs. * \remarks The returned pairs represent the [scope names] and the contained "key = value"-pairs.
*/ */
inline const std::vector<std::pair<std::string, std::multimap<std::string, std::string>>> &IniFile::data() const inline const IniFile::ScopeList &IniFile::data() const
{ {
return m_data; return m_data;
} }