2012-03-30 18:59:44 +00:00
|
|
|
#ifndef MWINIIMPORTER_IMPORTER
|
|
|
|
#define MWINIIMPORTER_IMPORTER 1
|
|
|
|
|
|
|
|
#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>
|
2014-05-19 12:56:41 +00:00
|
|
|
#include <iosfwd>
|
2015-02-21 21:02:25 +00:00
|
|
|
#include <boost/filesystem/path.hpp>
|
2012-03-30 20:58:54 +00:00
|
|
|
|
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 16:47:12 +00:00
|
|
|
void setVerbose(bool verbose);
|
2015-02-21 21:02:25 +00:00
|
|
|
multistrmap loadIniFile(const boost::filesystem::path& filename) const;
|
|
|
|
static multistrmap loadCfgFile(const boost::filesystem::path& filename);
|
2013-06-17 01:11:26 +00:00
|
|
|
void merge(multistrmap &cfg, const multistrmap &ini) const;
|
|
|
|
void mergeFallback(multistrmap &cfg, const multistrmap &ini) const;
|
2015-02-21 21:02:25 +00:00
|
|
|
void importGameFiles(multistrmap &cfg, const multistrmap &ini,
|
|
|
|
const boost::filesystem::path& iniFilename) const;
|
2013-06-17 01:11:26 +00:00
|
|
|
void importArchives(multistrmap &cfg, const multistrmap &ini) const;
|
2014-05-19 12:56:41 +00:00
|
|
|
static void writeToFile(std::ostream &out, const multistrmap &cfg);
|
2013-06-17 01:11:26 +00:00
|
|
|
|
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);
|
2013-06-17 16:47:12 +00:00
|
|
|
static std::string numberToString(int n);
|
2015-02-21 21:02:25 +00:00
|
|
|
|
|
|
|
/// \return file's "last modified time", used in original MW to determine plug-in load order
|
|
|
|
static std::time_t lastWriteTime(const boost::filesystem::path& filename, std::time_t defaultTime);
|
|
|
|
|
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
|