OpenMW
|
00001 #ifndef MWINIIMPORTER_IMPORTER 00002 #define MWINIIMPORTER_IMPORTER 1 00003 00004 #include <boost/iostreams/device/file.hpp> 00005 #include <boost/iostreams/stream.hpp> 00006 #include <string> 00007 #include <map> 00008 #include <vector> 00009 #include <exception> 00010 00011 #include <components/to_utf8/to_utf8.hpp> 00012 00013 class MwIniImporter { 00014 public: 00015 typedef std::map<std::string, std::string> strmap; 00016 typedef std::map<std::string, std::vector<std::string> > multistrmap; 00017 00018 MwIniImporter(); 00019 void setInputEncoding(const ToUTF8::FromType& encoding); 00020 void setVerbose(bool verbose); 00021 multistrmap loadIniFile(const std::string& filename) const; 00022 static multistrmap loadCfgFile(const std::string& filename); 00023 void merge(multistrmap &cfg, const multistrmap &ini) const; 00024 void mergeFallback(multistrmap &cfg, const multistrmap &ini) const; 00025 void importGameFiles(multistrmap &cfg, const multistrmap &ini) const; 00026 void importArchives(multistrmap &cfg, const multistrmap &ini) const; 00027 static void writeToFile(boost::iostreams::stream<boost::iostreams::file_sink> &out, const multistrmap &cfg); 00028 00029 private: 00030 static void insertMultistrmap(multistrmap &cfg, const std::string& key, const std::string& value); 00031 static std::string numberToString(int n); 00032 bool mVerbose; 00033 strmap mMergeMap; 00034 std::vector<std::string> mMergeFallback; 00035 ToUTF8::FromType mEncoding; 00036 }; 00037 00038 00039 #endif