Mercurial > minori
annotate src/core/ini.cc @ 305:91ac90a34003
core/time: remove Duration class, use regular functions instead
this class was pretty useless anyway
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 19 May 2024 15:56:20 -0400 |
parents | ec0a2b5493f8 |
children |
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 } |