annotate src/core/ini.cc @ 308:da2c5a8ff306

time: don't use time_t!
author Paper <paper@paper.us.eu.org>
date Tue, 11 Jun 2024 04:24:19 -0400
parents ec0a2b5493f8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
276
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
1 #include "core/ini.h"
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
2
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
3 namespace INI {
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
4
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
5 std::string GetIniString(const mINI::INIStructure& ini, const std::string& section, const std::string& key, const std::string& def) {
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
6 if (!ini.has(section) || !ini.get(section).has(key))
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
7 return def;
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
8
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
9 return ini.get(section).get(key);
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
10 }
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
11
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
12 bool GetIniBool(const mINI::INIStructure& ini, const std::string& section, const std::string& key, bool def) {
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
13 return Strings::ToBool(GetIniString(ini, section, key, ""), def);
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
14 }
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
15
ec0a2b5493f8 ini: simplify INI code, use templates less
Paper <paper@paper.us.eu.org>
parents:
diff changeset
16 }