2012-03-30 18:59:44 +00:00
|
|
|
#ifndef MWINIIMPORTER_IMPORTER
|
|
|
|
#define MWINIIMPORTER_IMPORTER 1
|
|
|
|
|
2012-03-31 19:06:48 +00:00
|
|
|
#include <boost/iostreams/device/file.hpp>
|
|
|
|
#include <boost/iostreams/stream.hpp>
|
2012-03-30 18:59:44 +00:00
|
|
|
#include <string>
|
2012-03-30 20:58:54 +00:00
|
|
|
#include <map>
|
2012-03-31 19:06:48 +00:00
|
|
|
#include <vector>
|
2012-03-30 20:58:54 +00:00
|
|
|
#include <exception>
|
|
|
|
|
2013-01-02 22:39:21 +00:00
|
|
|
#include <components/to_utf8/to_utf8.hpp>
|
2013-01-01 20:59:30 +00:00
|
|
|
|
2012-03-30 18:59:44 +00:00
|
|
|
class MwIniImporter {
|
|
|
|
public:
|
2012-03-31 20:48:50 +00:00
|
|
|
typedef std::map<std::string, std::string> strmap;
|
|
|
|
typedef std::map<std::string, std::vector<std::string> > multistrmap;
|
|
|
|
|
2012-03-31 14:54:53 +00:00
|
|
|
MwIniImporter();
|
2013-01-01 20:59:30 +00:00
|
|
|
void setInputEncoding(const ToUTF8::FromType& encoding);
|
2013-06-17 01:11:26 +00:00
|
|
|
void setVerbose(const bool verbose);
|
|
|
|
multistrmap loadIniFile(const std::string& filename) const;
|
|
|
|
static multistrmap loadCfgFile(const std::string& filename);
|
|
|
|
void merge(multistrmap &cfg, const multistrmap &ini) const;
|
|
|
|
void mergeFallback(multistrmap &cfg, const multistrmap &ini) const;
|
|
|
|
void importGameFiles(multistrmap &cfg, const multistrmap &ini) const;
|
|
|
|
void importArchives(multistrmap &cfg, const multistrmap &ini) const;
|
|
|
|
static void writeToFile(boost::iostreams::stream<boost::iostreams::file_sink> &out, const multistrmap &cfg);
|
|
|
|
|
2012-03-30 18:59:44 +00:00
|
|
|
private:
|
2013-06-17 01:11:26 +00:00
|
|
|
static void insertMultistrmap(multistrmap &cfg, const std::string& key, const std::string& value);
|
|
|
|
static std::string numberToString(const int n);
|
2012-03-30 20:58:54 +00:00
|
|
|
bool mVerbose;
|
2012-03-31 12:28:19 +00:00
|
|
|
strmap mMergeMap;
|
2012-04-02 22:44:26 +00:00
|
|
|
std::vector<std::string> mMergeFallback;
|
2013-01-01 20:59:30 +00:00
|
|
|
ToUTF8::FromType mEncoding;
|
2012-03-30 18:59:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|