diff src/core/ini.cc @ 276:ec0a2b5493f8

ini: simplify INI code, use templates less less magic voodoo code
author Paper <paper@paper.us.eu.org>
date Mon, 22 Apr 2024 19:10:28 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/ini.cc	Mon Apr 22 19:10:28 2024 -0400
@@ -0,0 +1,16 @@
+#include "core/ini.h"
+
+namespace INI {
+
+std::string GetIniString(const mINI::INIStructure& ini, const std::string& section, const std::string& key, const std::string& def) {
+	if (!ini.has(section) || !ini.get(section).has(key))
+		return def;
+
+	return ini.get(section).get(key);
+}
+
+bool GetIniBool(const mINI::INIStructure& ini, const std::string& section, const std::string& key, bool def) {
+	return Strings::ToBool(GetIniString(ini, section, key, ""), def);
+}
+
+}