Rework how the config file is read
Still need to remove reduntant code and test it much more thoroughly.
This commit is contained in:
+33
-19
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "ConfigUtils.h"
|
||||
#include "xml/XMLObject.h"
|
||||
|
||||
#include <map>
|
||||
@@ -11,29 +12,42 @@ static const std::string CONFIG_FILENAME = "makegen.xml";
|
||||
|
||||
class ConfigFile
|
||||
{
|
||||
public:
|
||||
private:
|
||||
ConfigCache cache;
|
||||
|
||||
XMLObject config;
|
||||
// Current configuration
|
||||
std::string target;
|
||||
|
||||
std::string configPath;
|
||||
|
||||
std::vector<std::string> libs;
|
||||
std::vector<std::string> libdirs;
|
||||
std::vector<std::string> includedirs;
|
||||
std::vector<std::string> defines;
|
||||
std::vector<std::string> flags;
|
||||
std::vector<std::string> dependencies;
|
||||
|
||||
std::string outputdir;
|
||||
std::string srcdir;
|
||||
std::string outputname;
|
||||
std::string projectname;
|
||||
std::string hFile;
|
||||
bool executable;
|
||||
bool shared;
|
||||
bool generateHFile;
|
||||
|
||||
std::vector<ConfigFile> dependencyConfigs;
|
||||
|
||||
bool hasInitError = false;
|
||||
|
||||
public:
|
||||
ConfigFile();
|
||||
// Generates a new default config file
|
||||
ConfigFile(const std::string& path, int);
|
||||
ConfigFile(const std::string& path);
|
||||
ConfigFile(XMLObject& config, const std::string& path);
|
||||
|
||||
void Save() const;
|
||||
|
||||
std::string& GetSettingString(ConfigSetting setting);
|
||||
bool GetSettingBool(ConfigSetting setting);
|
||||
std::vector<std::string>& GetSettingVectorString(ConfigSetting setting);
|
||||
std::vector<std::string> GetSetting(ConfigSetting setting);
|
||||
|
||||
bool SetSettingString(ConfigSetting setting, const std::string& value);
|
||||
bool AddSettingVectorString(ConfigSetting setting, const std::string& value);
|
||||
bool RemoveSettingVectorString(ConfigSetting setting, const std::string& value);
|
||||
|
||||
XMLObject& GetConfiguration();
|
||||
const std::string& GetConfigPath() const;
|
||||
ConfigFile& GetDependencyConfig(size_t i);
|
||||
private:
|
||||
void Init();
|
||||
|
||||
public:
|
||||
static ConfigFile Gen();
|
||||
static std::optional<ConfigFile> GetConfigFile(const std::string& filepath = "./");
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user