1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-03 17:37:18 +00:00
OpenMW/apps/mwiniimporter/importer.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
2.0 KiB
C++
Raw Normal View History

2012-03-30 18:59:44 +00:00
#ifndef MWINIIMPORTER_IMPORTER
#define MWINIIMPORTER_IMPORTER 1
2012-03-30 20:58:54 +00:00
#include <exception>
#include <filesystem>
#include <iosfwd>
2012-03-30 20:58:54 +00:00
#include <map>
2012-03-30 18:59:44 +00:00
#include <string>
2012-03-31 19:06:48 +00:00
#include <vector>
2012-03-30 20:58:54 +00:00
2013-01-02 22:39:21 +00:00
#include <components/to_utf8/to_utf8.hpp>
2012-03-30 18:59:44 +00:00
class MwIniImporter
{
public:
typedef std::map<std::string, std::string> strmap;
typedef std::map<std::string, std::vector<std::string>> multistrmap;
2018-05-08 15:32:06 +00:00
typedef std::vector<std::pair<std::string, std::vector<std::string>>> dependencyList;
2012-03-31 14:54:53 +00:00
MwIniImporter();
void setInputEncoding(const ToUTF8::FromType& encoding);
2013-06-17 16:47:12 +00:00
void setVerbose(bool verbose);
multistrmap loadIniFile(const std::filesystem::path& filename) const;
static multistrmap loadCfgFile(const std::filesystem::path& 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 std::filesystem::path& iniFilename) const;
void importArchives(multistrmap& cfg, const multistrmap& ini) const;
static void writeToFile(std::ostream& out, const multistrmap& cfg);
2018-05-08 15:32:06 +00:00
static std::vector<std::string> dependencySort(MwIniImporter::dependencyList source);
2012-03-30 18:59:44 +00:00
private:
2018-05-08 15:32:06 +00:00
static void dependencySortStep(
std::string& element, MwIniImporter::dependencyList& source, std::vector<std::string>& result);
static std::vector<std::string>::iterator findString(std::vector<std::string>& source, const std::string& string);
static void insertMultistrmap(multistrmap& cfg, const std::string& key, const std::string& value);
static void addPaths(std::vector<std::filesystem::path>& output, std::vector<std::string> input);
/// \return file's "last modified time", used in original MW to determine plug-in load order
static std::time_t lastWriteTime(const std::filesystem::path& filename, std::time_t defaultTime);
2012-03-30 20:58:54 +00:00
bool mVerbose;
strmap mMergeMap;
2012-04-02 22:44:26 +00:00
std::vector<std::string> mMergeFallback;
ToUTF8::FromType mEncoding;
2012-03-30 18:59:44 +00:00
};
#endif