feat(Core/Config): implement loading files optional (#8198)

This commit is contained in:
Kargatum
2021-12-10 17:53:31 +07:00
committed by GitHub
parent e5cbba1c4c
commit 0f1c0c154d
6 changed files with 142 additions and 101 deletions

View File

@@ -20,7 +20,7 @@
#include "Define.h"
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>
class ConfigMgr
@@ -31,15 +31,15 @@ class ConfigMgr
~ConfigMgr() = default;
public:
bool LoadAppConfigs();
bool LoadModulesConfigs();
bool LoadAppConfigs(bool isReload = false);
bool LoadModulesConfigs(bool isReload = false, bool isNeedPrintInfo = true);
void Configure(std::string const& initFileName, std::vector<std::string> args, std::string const& modulesConfigList = "");
static ConfigMgr* instance();
bool Reload();
std::string const& GetFilename();
std::string const GetFilename();
std::string const GetConfigPath();
std::vector<std::string> const& GetArguments() const;
std::vector<std::string> GetKeysByString(std::string const& name);
@@ -51,16 +51,16 @@ public:
* Deprecated geters. This geters will be deleted
*/
// @deprecated DO NOT USE - use GetOption<std::string> instead.
[[deprecated("Use GetOption<std::string> instead")]]
std::string GetStringDefault(std::string const& name, const std::string& def, bool showLogs = true);
// @deprecated DO NOT USE - use GetOption<bool> instead.
[[deprecated("Use GetOption<bool> instead")]]
bool GetBoolDefault(std::string const& name, bool def, bool showLogs = true);
// @deprecated DO NOT USE - use GetOption<int32> instead.
[[deprecated("Use GetOption<int32> instead")]]
int GetIntDefault(std::string const& name, int def, bool showLogs = true);
// @deprecated DO NOT USE - use GetOption<float> instead.
[[deprecated("Use GetOption<float> instead")]]
float GetFloatDefault(std::string const& name, float def, bool showLogs = true);
/*
@@ -70,12 +70,10 @@ public:
bool isDryRun() { return dryRun; }
void setDryRun(bool mode) { dryRun = mode; }
void PrintLoadedModulesConfigs();
private:
/// Method used only for loading main configuration files (authserver.conf and worldserver.conf)
bool LoadInitial(std::string const& file);
bool LoadAdditionalFile(std::string file);
bool LoadInitial(std::string const& file, bool isReload = false);
bool LoadAdditionalFile(std::string file, bool isOptional = false, bool isReload = false);
template<class T>
T GetValueDefault(std::string const& name, T const& def, bool showLogs = true) const;