[nostalgia] Replace unnecessary ox::Strings with ox::StringViews

This commit is contained in:
Gary Talent 2022-12-31 15:48:47 -06:00
parent 5a09918b64
commit 6cfa8dd40d
8 changed files with 11 additions and 10 deletions

View File

@ -2,7 +2,8 @@
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include "ox/std/memory.hpp"
#include <ox/std/memory.hpp>
#include "paletteeditor-imgui.hpp"
#include "tilesheeteditor-imgui.hpp"
@ -14,7 +15,7 @@ ox::Vector<studio::EditorMaker> Module::editors(core::Context *ctx) noexcept {
return {
{
{"ng"},
[ctx](const ox::String &path) -> ox::Result<studio::BaseEditor*> {
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
try {
return ox::make<TileSheetEditorImGui>(ctx, path);
} catch (const ox::Exception &ex) {
@ -24,7 +25,7 @@ ox::Vector<studio::EditorMaker> Module::editors(core::Context *ctx) noexcept {
},
{
{"npal"},
[ctx](const ox::String &path) -> ox::Result<studio::BaseEditor*> {
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
return PaletteEditorImGui::make(ctx, path);
}
}

View File

@ -13,7 +13,7 @@
namespace nostalgia::core {
ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(Context *ctx, const ox::String &path) noexcept {
ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(Context *ctx, ox::CRStringView path) noexcept {
auto out = ox::UniquePtr<PaletteEditorImGui>(new PaletteEditorImGui);
out->m_ctx = ctx;
out->m_itemPath = path;

View File

@ -21,7 +21,7 @@ class PaletteEditorImGui: public studio::Editor {
PaletteEditorImGui() noexcept = default;
public:
static ox::Result<PaletteEditorImGui*> make(Context *ctx, const ox::String &path) noexcept;
static ox::Result<PaletteEditorImGui*> make(Context *ctx, ox::CRStringView path) noexcept;
/**
* Returns the name of item being edited.

View File

@ -38,7 +38,7 @@ ox::Error toPngFile(const ox::String &path, const TileSheet::SubSheet &s, const
return OxError(lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8));
}
TileSheetEditorImGui::TileSheetEditorImGui(Context *ctx, const ox::String &path): m_tileSheetEditor(ctx, path) {
TileSheetEditorImGui::TileSheetEditorImGui(Context *ctx, ox::CRStringView path): m_tileSheetEditor(ctx, path) {
m_ctx = ctx;
m_itemPath = path;
const auto lastSlash = ox::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset();

View File

@ -54,7 +54,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
Tool m_tool = Tool::Draw;
public:
TileSheetEditorImGui(Context *ctx, const ox::String &path);
TileSheetEditorImGui(Context *ctx, ox::CRStringView path);
~TileSheetEditorImGui() override = default;

View File

@ -10,7 +10,7 @@
namespace nostalgia::core {
TileSheetEditorView::TileSheetEditorView(Context *ctx, const ox::String &path): m_model(ctx, path), m_pixelsDrawer(&m_model) {
TileSheetEditorView::TileSheetEditorView(Context *ctx, ox::CRStringView path): m_model(ctx, path), m_pixelsDrawer(&m_model) {
// build shaders
oxThrowError(m_pixelsDrawer.buildShader());
oxThrowError(m_pixelGridDrawer.buildShader());

View File

@ -49,7 +49,7 @@ class TileSheetEditorView: public ox::SignalHandler {
std::size_t m_palIdx = 0;
public:
TileSheetEditorView(Context *ctx, const ox::String &path);
TileSheetEditorView(Context *ctx, ox::CRStringView path);
~TileSheetEditorView() override = default;

View File

@ -17,7 +17,7 @@ namespace nostalgia::studio {
class ItemMaker;
struct EditorMaker {
using Func = std::function<ox::Result<class BaseEditor*>(const ox::String&)>;
using Func = std::function<ox::Result<class BaseEditor*>(ox::CRStringView)>;
ox::Vector<ox::String> fileTypes;
Func make;
};