From 6908199428636788da3328b413a88baabe81adde Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 10 Jul 2022 15:51:04 -0500 Subject: [PATCH] [nostalgia/studio] Change configio functions to take auto string type --- src/nostalgia/studio/lib/configio.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/nostalgia/studio/lib/configio.hpp b/src/nostalgia/studio/lib/configio.hpp index 65e53c40..53774b15 100644 --- a/src/nostalgia/studio/lib/configio.hpp +++ b/src/nostalgia/studio/lib/configio.hpp @@ -36,8 +36,8 @@ constexpr auto ConfigDir = [] { }(); template -ox::Result readConfig(core::Context *ctx, const ox::String &name) noexcept { - oxAssert(name != "", "Config type has no TypeName"); +ox::Result readConfig(core::Context *ctx, const char *name) noexcept { + oxAssert(ox_strcmp(name, ""), "Config type has no TypeName"); const auto homeDir = std::getenv("HOME"); const auto configPath = ox::sfmt(ConfigDir, homeDir, ctx->appName).toStdString(); const auto path = ox::sfmt("{}/{}.json", configPath, name).toStdString(); @@ -65,8 +65,8 @@ ox::Result readConfig(core::Context *ctx) noexcept { } template -ox::Error writeConfig(core::Context *ctx, const ox::String &name, T *data) noexcept { - oxAssert(name != "", "Config type has no TypeName"); +ox::Error writeConfig(core::Context *ctx, const auto &name, T *data) noexcept { + oxAssert(ox_strcmp(name, ""), "Config type has no TypeName"); const auto homeDir = std::getenv("HOME"); const auto configPath = ox::sfmt(ConfigDir, homeDir, ctx->appName).toStdString(); const auto path = ox::sfmt("{}/{}.json", configPath, name).toStdString(); @@ -98,7 +98,7 @@ ox::Error writeConfig(core::Context *ctx, T *data) noexcept { } template -void openConfig(core::Context *ctx, const ox::String &name, Func f) noexcept { +void openConfig(core::Context *ctx, const auto &name, Func f) noexcept { oxAssert(name != "", "Config type has no TypeName"); const auto c = readConfig(ctx, name); f(&c.value); @@ -111,8 +111,8 @@ void openConfig(core::Context *ctx, Func f) noexcept { } template -void editConfig(core::Context *ctx, const ox::String &name, Func f) noexcept { - oxAssert(name != "", "Config type has no TypeName"); +void editConfig(core::Context *ctx, const auto &name, Func f) noexcept { + oxAssert(ox_strcmp(name, ""), "Config type has no TypeName"); auto c = readConfig(ctx, name); f(&c.value); oxLogError(writeConfig(ctx, name, &c.value));