diff options
Diffstat (limited to 'src/mmo/config_parse.cpp')
-rw-r--r-- | src/mmo/config_parse.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/mmo/config_parse.cpp b/src/mmo/config_parse.cpp index b954e8b..8362810 100644 --- a/src/mmo/config_parse.cpp +++ b/src/mmo/config_parse.cpp @@ -18,6 +18,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. +#include <algorithm> + #include "../strings/xstring.hpp" #include "../strings/zstring.hpp" @@ -28,9 +30,12 @@ #include "../poison.hpp" + +namespace tmwa +{ bool is_comment(XString line) { - return not line or line.startswith("//"); + return not line or line.startswith("//"_s); } template<class ZS> @@ -72,7 +77,7 @@ bool load_config_file(ZString filename, ConfigItemParser slave) io::LineReader in(filename); if (!in.is_open()) { - PRINTF("Unable to open file: %s\n", filename); + PRINTF("Unable to open file: %s\n"_fmt, filename); return false; } io::Line line; @@ -85,16 +90,16 @@ bool load_config_file(ZString filename, ConfigItemParser slave) ZString value; if (!config_split(line.text, &key, &value)) { - line.error("Bad config line"); + line.error("Bad config line"_s); rv = false; continue; } - if (key == "import") + if (key == "import"_s) { rv &= load_config_file(value, slave); continue; } - else if (key == "version-lt") + else if (key == "version-lt"_s) { Version vers; if (!extract(value, &vers)) @@ -106,7 +111,7 @@ bool load_config_file(ZString filename, ConfigItemParser slave) continue; break; } - else if (key == "version-le") + else if (key == "version-le"_s) { Version vers; if (!extract(value, &vers)) @@ -118,7 +123,7 @@ bool load_config_file(ZString filename, ConfigItemParser slave) continue; break; } - else if (key == "version-gt") + else if (key == "version-gt"_s) { Version vers; if (!extract(value, &vers)) @@ -130,7 +135,7 @@ bool load_config_file(ZString filename, ConfigItemParser slave) continue; break; } - else if (key == "version-ge") + else if (key == "version-ge"_s) { Version vers; if (!extract(value, &vers)) @@ -144,7 +149,7 @@ bool load_config_file(ZString filename, ConfigItemParser slave) } else if (!slave(key, value)) { - line.error("Bad config key or value"); + line.error("Bad config key or value"_s); rv = false; continue; } @@ -152,3 +157,4 @@ bool load_config_file(ZString filename, ConfigItemParser slave) } return rv; } +} // namespace tmwa |