diff --git a/source/ps/ConfigDB.cpp b/source/ps/ConfigDB.cpp index 64d873baef..8896f515b5 100644 --- a/source/ps/ConfigDB.cpp +++ b/source/ps/ConfigDB.cpp @@ -86,10 +86,8 @@ std::string EscapeString(const CStr& str) } // anonymous namespace -typedef std::map TConfigMap; - #define GETVAL(type)\ - void CConfigDB::GetValue(EConfigNamespace ns, const CStr& name, type& value)\ + void CConfigDB::GetValue(EConfigNamespace ns, const std::string_view name, type& value)\ {\ CHECK_NS(;);\ std::lock_guard s(m_Mutex);\ diff --git a/source/ps/ConfigDB.h b/source/ps/ConfigDB.h index 542cc3183f..093e8fca36 100644 --- a/source/ps/ConfigDB.h +++ b/source/ps/ConfigDB.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -84,31 +85,30 @@ public: * will search CFG_COMMAND first, and then all namespaces from the specified * namespace down. */ - void GetValue(EConfigNamespace ns, const CStr& name, bool& value); + void GetValue(EConfigNamespace ns, const std::string_view name, bool& value); ///@copydoc CConfigDB::GetValue - void GetValue(EConfigNamespace ns, const CStr& name, int& value); + void GetValue(EConfigNamespace ns, const std::string_view name, int& value); ///@copydoc CConfigDB::GetValue - void GetValue(EConfigNamespace ns, const CStr& name, u32& value); + void GetValue(EConfigNamespace ns, const std::string_view name, u32& value); ///@copydoc CConfigDB::GetValue - void GetValue(EConfigNamespace ns, const CStr& name, float& value); + void GetValue(EConfigNamespace ns, const std::string_view name, float& value); ///@copydoc CConfigDB::GetValue - void GetValue(EConfigNamespace ns, const CStr& name, double& value); + void GetValue(EConfigNamespace ns, const std::string_view name, double& value); ///@copydoc CConfigDB::GetValue - void GetValue(EConfigNamespace ns, const CStr& name, std::string& value); + void GetValue(EConfigNamespace ns, const std::string_view name, std::string& value); template - [[nodiscard]] T Get(std::string name, T value, const EConfigNamespace ns = CFG_USER) + [[nodiscard]] T Get(const std::string_view name, T value, const EConfigNamespace ns = CFG_USER) { - GetValue(ns, std::move(name), value); + GetValue(ns, name, value); return value; } template - [[nodiscard]] static T GetIfInitialised(std::string name, T defaultValue, + [[nodiscard]] static T GetIfInitialised(const std::string_view name, T defaultValue, const EConfigNamespace ns = CFG_USER) { - return IsInitialised() ? g_ConfigDB.Get(std::move(name), std::move(defaultValue), ns) : - defaultValue; + return IsInitialised() ? g_ConfigDB.Get(name, std::move(defaultValue), ns) : defaultValue; } /** @@ -217,7 +217,8 @@ public: void UnregisterHook(std::unique_ptr hook); private: - std::array, CFG_LAST> m_Map; + using TConfigMap = std::map>; + std::array m_Map; std::multimap> m_Hooks; std::array m_ConfigFile; std::array m_HasChanges;