8 #include <Utils/IniParser.h> 9 #include <Utils/Ulog.h> 21 return GetParser().PopErrorLog();
27 return GetParser().GetUnreadableRecords();
31 static bool LoadFile(
const std::string &file_name)
33 return GetParser().LoadFile(file_name);
43 static bool Exists(
const std::string &key)
45 return GetParser().Exists(key);
49 static std::string
GetStr(
const std::string &key,
const std::string &default_val =
"")
51 auto str = GetParser().GetStr(key, default_val);
54 ulog::Warn(
"Unsupported non-international character in config file: '" + key +
"'. Using default value '" + default_val +
"'.",
"Config::GetStr");
58 #if defined(REPO_DIR) && !defined(_DEPLOY) 65 static bool GetBool(
const std::string &key,
const bool default_val =
false)
67 return GetParser().GetBool(key, default_val);
71 static size_t GetSizeT(
const std::string &key,
const size_t default_val = 0)
73 return GetParser().GetSizeT(key, default_val);
78 static T
GetUint(
const std::string &key,
const T default_val = 0)
80 return GetParser().GetUint<T>(key, default_val);
84 static int GetInt(
const std::string &key,
const int default_val = 0)
86 return GetParser().GetInt(key, default_val);
90 static float GetFloat(
const std::string &key,
const float default_val = 0.0f)
92 return GetParser().GetFloat(key, default_val);
96 static double GetDouble(
const std::string &key,
const double default_val = 0.0)
98 return GetParser().GetDouble(key, default_val);
102 template <glm::length_t N,
typename Type>
103 static glm::vec<N, Type, glm::highp>
GetVec(
const std::string &key,
const glm::vec<N, Type, glm::highp> default_val = glm::vec<N, Type, glm::highp>(0))
105 return GetParser().GetVec(key, default_val);
109 static std::vector<std::string>
GetArray(
const std::string &key,
const std::vector<std::string> &default_val = {})
111 return GetParser().GetArray(key, default_val);
115 static std::vector<float>
GetFloatArray(
const std::string &key,
const std::vector<float> &default_val = {})
117 return GetParser().GetFloatArray(key, default_val);
121 static std::vector<int>
GetIntArray(
const std::string &key,
const std::vector<int> &default_val = {})
123 return GetParser().GetIntArray(key, default_val);
127 static std::vector<bool>
GetBoolArray(
const std::string &key,
const std::vector<bool> &default_val = {})
129 return GetParser().GetBoolArray(key, default_val);
134 utils::IniParser parser_;
145 static utils::IniParser &GetParser()
147 return Self().parser_;
static void Clear()
Clears config data.
Definition: Config.h:37
static bool GetBool(const std::string &key, const bool default_val=false)
Returns a bool value for the key if the key does exist.
Definition: Config.h:65
static T GetUint(const std::string &key, const T default_val=0)
Returns an unsigned integer value for the key if the key does exist.
Definition: Config.h:78
static bool Exists(const std::string &key)
If the key does exist in the singletons data, returns true.
Definition: Config.h:43
static std::string PopErrorLog()
Returns the error log as a string.
Definition: Config.h:19
static double GetDouble(const std::string &key, const double default_val=0.0)
Returns a double value for the key if the key does exist.
Definition: Config.h:96
bool IsASCII(const std::string &s)
Check std::string for non-ASCII characters.
Definition: ExtSTD.h:1011
Singleton for holding and requesting configuration file parameters.
Definition: Config.h:14
static glm::vec< N, Type, glm::highp > GetVec(const std::string &key, const glm::vec< N, Type, glm::highp > default_val=glm::vec< N, Type, glm::highp >(0))
Returns a glm::vec value for the key if the key does exist.
Definition: Config.h:103
static bool LoadFile(const std::string &file_name)
Loads config file into the config singleton.
Definition: Config.h:31
static int GetInt(const std::string &key, const int default_val=0)
Returns an int value for the key if the key does exist.
Definition: Config.h:84
static std::vector< int > GetIntArray(const std::string &key, const std::vector< int > &default_val={})
Returns a std::vector<int> value for the key if the key does exist.
Definition: Config.h:121
static size_t GetSizeT(const std::string &key, const size_t default_val=0)
Returns a size_t value for the key if the key does exist.
Definition: Config.h:71
static std::string GetStr(const std::string &key, const std::string &default_val="")
Returns a string value for the key, if the exists.
Definition: Config.h:49
static std::vector< float > GetFloatArray(const std::string &key, const std::vector< float > &default_val={})
Returns a std::vector<float> value for the key if the key does exist.
Definition: Config.h:115
std::string Replace(const std::string &text, const std::string &key_to_search, const std::string &replace_text)
Replaces all occurrences of key_to_search with replace_text in specified text.
Definition: ExtSTD.h:117
static const std::unordered_set< std::string > & GetUnreadableRecords()
Get skipped unreadable (most likely non-ASCII) records.
Definition: Config.h:25
static float GetFloat(const std::string &key, const float default_val=0.0f)
Returns an float value for the key if the key does exist.
Definition: Config.h:90
static std::vector< std::string > GetArray(const std::string &key, const std::vector< std::string > &default_val={})
Returns a std::vector<std::string> value for the key if the key does exist.
Definition: Config.h:109
static std::vector< bool > GetBoolArray(const std::string &key, const std::vector< bool > &default_val={})
Returns a std::vector<bool> value for the key if the key does exist.
Definition: Config.h:127