#ifndef GERMANAIRLINESVA_FILE_CONFIG_CONFIG_H #define GERMANAIRLINESVA_FILE_CONFIG_CONFIG_H #include #include #include #include #include #include "constants.h" #include "util.hpp" namespace germanairlinesva { namespace file { namespace config { class Config { private: std::string user; std::string scenery; std::string token; std::string FSXPath; std::string FSXSEPath; std::string P3D3Path; std::string P3D4Path; std::string P3D5Path; std::string MSFSPath; inline void writeFile() const { std::ofstream out(BASE_DIRECTORY CONFIG); out << "scenery=" << this->scenery << "\n"; out << "user=" << this->user << "\n"; out << "token=" << this->token << "\n"; out << "fsxPath=" << this->FSXPath << "\n"; out << "fsxSEPath=" << this->FSXSEPath << "\n"; out << "p3d3Path=" << this->P3D3Path << "\n"; out << "p3d4Path=" << this->P3D4Path << "\n"; out << "p3d5Path=" << this->P3D5Path << "\n"; out << "msfsPath=" << this->MSFSPath << "\n"; out.close(); } public: inline Config() { std::ifstream in(BASE_DIRECTORY CONFIG); std::string line; while (std::getline(in, line)) { std::vector fields = utilities::split(line, '='); if (fields.size() >= 2) { utilities::trim(fields[0]); utilities::trim(fields[1]); if (fields[0] == "scenery") { this->scenery = fields[1]; } else if (fields[0] == "user") { this->user = fields[1]; } else if (fields[0] == "token") { this->token = fields[1]; } else if (fields[0] == "fsxPath") { this->FSXPath = fields[1]; } else if (fields[0] == "fsxSEPath") { this->FSXSEPath = fields[1]; } else if (fields[0] == "p3d3Path") { this->P3D3Path = fields[1]; } else if (fields[0] == "p3d4Paht") { this->P3D4Path = fields[1]; } else if (fields[0] == "p3d5Path") { this->P3D5Path = fields[1]; } else if (fields[0] == "msfsPath") { this->MSFSPath = fields[1]; } } } in.close(); } inline void updateScenery(std::string scenery) { this->scenery = scenery; this->writeFile(); } inline const std::string getUser() const { return this->user; } inline const std::string getScenery() const { return this->scenery; } inline const std::string getToken() const { return this->token; } inline const std::string getFSXPath() const { return this->FSXPath; } inline const std::string getFSXSEPath() const { return this->FSXSEPath; } inline const std::string getP3D3Path() const { return this->P3D3Path; } inline const std::string getP3D4Path() const { return this->P3D4Path; } inline const std::string getP3D5Path() const { return this->P3D5Path; } inline const std::string getMSFSPath() const { return this->MSFSPath; } }; } // namespace config } // namespace file } // namespace germanairlinesva #endif