[keel,studio] Cleanup string handling
This commit is contained in:
parent
ce514d586c
commit
26a2d340d6
@ -233,7 +233,7 @@ class AssetManager {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
AssetTypeManager<T> *getTypeManager() noexcept {
|
AssetTypeManager<T> *getTypeManager() noexcept {
|
||||||
constexpr auto typeName = ox::requireModelTypeName<T>();
|
constexpr auto typeName = ox::requireModelTypeName<T>();
|
||||||
static_assert(ox_strcmp(typeName, "") != 0, "Types must have TypeName to use AssetManager");
|
static_assert(ox::StringView(typeName) != "", "Types must have TypeName to use AssetManager");
|
||||||
auto &am = m_assetTypeManagers[typeName];
|
auto &am = m_assetTypeManagers[typeName];
|
||||||
if (!am) {
|
if (!am) {
|
||||||
am = ox::make_unique<AssetTypeManager<T>>();
|
am = ox::make_unique<AssetTypeManager<T>>();
|
||||||
|
@ -24,10 +24,10 @@ ox::Result<char*> loadRom(ox::CRStringView path) noexcept {
|
|||||||
auto buff = new char[static_cast<std::size_t>(size)];
|
auto buff = new char[static_cast<std::size_t>(size)];
|
||||||
file.read(buff, size);
|
file.read(buff, size);
|
||||||
return buff;
|
return buff;
|
||||||
} catch (const std::ios_base::failure &e) {
|
} catch (std::ios_base::failure const&e) {
|
||||||
oxErrorf("Could not read ROM file due to file IO failure: {}", e.what());
|
oxErrorf("Could not read ROM file due to file IO failure: {}", e.what());
|
||||||
return OxError(2, "Could not read ROM file");
|
return OxError(2, "Could not read ROM file");
|
||||||
} catch (const std::bad_alloc &e) {
|
} catch (std::bad_alloc const&e) {
|
||||||
oxErrorf("Could not read ROM file due to new failure: {}", e.what());
|
oxErrorf("Could not read ROM file due to new failure: {}", e.what());
|
||||||
return OxError(2, "Could not allocate memory for ROM file");
|
return OxError(2, "Could not allocate memory for ROM file");
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ ox::Error writeConfig(keel::Context *ctx, T *data) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename Func>
|
template<typename T, typename Func>
|
||||||
void openConfig(keel::Context *ctx, const auto &name, Func f) noexcept {
|
void openConfig(keel::Context *ctx, ox::CRStringView name, Func f) noexcept {
|
||||||
oxAssert(name != "", "Config type has no TypeName");
|
oxAssert(name != "", "Config type has no TypeName");
|
||||||
const auto [c, err] = readConfig<T>(ctx, name);
|
const auto [c, err] = readConfig<T>(ctx, name);
|
||||||
oxLogError(err);
|
oxLogError(err);
|
||||||
@ -78,8 +78,8 @@ void openConfig(keel::Context *ctx, Func f) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, typename Func>
|
template<typename T, typename Func>
|
||||||
void editConfig(keel::Context *ctx, const auto &name, Func f) noexcept {
|
void editConfig(keel::Context *ctx, ox::CRStringView name, Func f) noexcept {
|
||||||
oxAssert(ox_strcmp(name, ""), "Config type has no TypeName");
|
oxAssert(name != "", "Config type has no TypeName");
|
||||||
auto [c, err] = readConfig<T>(ctx, name);
|
auto [c, err] = readConfig<T>(ctx, name);
|
||||||
oxLogError(err);
|
oxLogError(err);
|
||||||
f(&c);
|
f(&c);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user