[olympic,nostalgia] Rename CRStringView to StringViewCR

This commit is contained in:
Gary Talent 2024-09-28 16:10:44 -05:00
parent 256be6dae0
commit a1b5b56553
38 changed files with 109 additions and 109 deletions

View File

@ -200,7 +200,7 @@ uint_t spriteCount(Context &ctx) noexcept;
ox::Error initConsole(Context &ctx) noexcept;
void puts(Context &ctx, int column, int row, ox::CRStringView str) noexcept;
void puts(Context &ctx, int column, int row, ox::StringViewCR str) noexcept;
}

View File

@ -306,9 +306,9 @@ uint8_t getPixel8Bpp(
ox::Point const&pt,
TileSheet::SubSheetIdx const&subsheetIdx) noexcept;
ox::Result<SubSheetId> getIdFor(TileSheet const&ts, ox::CRStringView path) noexcept;
ox::Result<SubSheetId> getIdFor(TileSheet const&ts, ox::StringViewCR path) noexcept;
ox::Result<unsigned> getTileOffset(TileSheet const&ts, ox::CRStringView pNamePath) noexcept;
ox::Result<unsigned> getTileOffset(TileSheet const&ts, ox::StringViewCR pNamePath) noexcept;
ox::Result<ox::StringView> getNameFor(TileSheet::SubSheet const&ss, SubSheetId pId) noexcept;

View File

@ -168,7 +168,7 @@ void puts(
Context &ctx,
int const column,
int const row,
ox::CRStringView str) noexcept {
ox::StringViewCR str) noexcept {
auto const col = static_cast<uint_t>(column);
for (auto i = 0u; i < str.bytes(); ++i) {
setBgTile(

View File

@ -9,7 +9,7 @@ namespace nostalgia::core {
core::PaletteChangeCommand::PaletteChangeCommand(
TileSheet::SubSheetIdx idx,
TileSheet &img,
ox::CRStringView newPalette) noexcept:
ox::StringViewCR newPalette) noexcept:
m_img(img),
m_idx(std::move(idx)),
m_oldPalette(m_img.defaultPalette),

View File

@ -19,7 +19,7 @@ class PaletteChangeCommand: public TileSheetCommand {
PaletteChangeCommand(
TileSheet::SubSheetIdx idx,
TileSheet &img,
ox::CRStringView newPalette) noexcept;
ox::StringViewCR newPalette) noexcept;
ox::Error redo() noexcept final;

View File

@ -348,7 +348,7 @@ static ox::Result<SubSheetId> getIdFor(
return OxError(1, "SubSheet not found");
}
ox::Result<SubSheetId> getIdFor(TileSheet const&ts, ox::CRStringView path) noexcept {
ox::Result<SubSheetId> getIdFor(TileSheet const&ts, ox::StringViewCR path) noexcept {
return getIdFor(ts.subsheet, ox::split<8>(path, '.'));
}
@ -379,7 +379,7 @@ static ox::Result<unsigned> getTileOffset(
return OxError(1, "SubSheet not found");
}
ox::Result<unsigned> getTileOffset(TileSheet const&ts, ox::CRStringView pNamePath) noexcept {
ox::Result<unsigned> getTileOffset(TileSheet const&ts, ox::StringViewCR pNamePath) noexcept {
return core::getTileOffset(ts.subsheet, ox::split<8>(pNamePath, '.'), ts.bpp);
}

View File

@ -8,7 +8,7 @@
namespace nostalgia::scene {
SceneEditor::SceneEditor(turbine::Context &ctx, ox::CRStringView path):
SceneEditor::SceneEditor(turbine::Context &ctx, ox::StringViewCR path):
m_ctx(ctx),
m_scene(*keel::readObj<SceneStatic>(keelCtx(m_ctx), path).unwrapThrow()) {
}

View File

@ -19,7 +19,7 @@ class SceneEditor {
SceneStatic m_scene;
public:
SceneEditor(turbine::Context &ctx, ox::CRStringView path);
SceneEditor(turbine::Context &ctx, ox::StringViewCR path);
[[nodiscard]]
SceneStatic const&scene() const noexcept {

View File

@ -17,10 +17,10 @@ namespace keel {
ox::Error init(
keel::Context &ctx,
ox::UPtr<ox::FileSystem> &&fs,
ox::CRStringView appName) noexcept;
ox::StringViewCR appName) noexcept;
ox::Result<ox::UPtr<Context>> init(
ox::UPtr<ox::FileSystem> &&fs,
ox::CRStringView appName) noexcept;
ox::StringViewCR appName) noexcept;
}

View File

@ -30,14 +30,14 @@ oxModelBegin(PreloadPtr)
oxModelEnd()
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::FileAddress const&file) noexcept;
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::CRStringView file) noexcept;
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::StringViewCR file) noexcept;
void createUuidMapping(Context &ctx, ox::StringView filePath, ox::UUID const&uuid) noexcept;
ox::Error buildUuidMap(Context &ctx) noexcept;
ox::Result<ox::UUID> pathToUuid(Context &ctx, ox::CRStringView path) noexcept;
ox::Result<ox::UUID> pathToUuid(Context &ctx, ox::StringViewCR path) noexcept;
ox::Result<ox::UUID> getUuid(Context &ctx, ox::FileAddress const&fileAddr) noexcept;
@ -53,7 +53,7 @@ constexpr ox::Result<ox::UUID> uuidUrlToUuid(ox::StringView uuidUrl) noexcept {
ox::Result<ox::CStringView> uuidUrlToPath(Context &ctx, ox::StringView uuid) noexcept;
ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::CRStringView uuid) noexcept;
ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::StringViewCR uuid) noexcept;
ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::UUID const&uuid) noexcept;
@ -114,7 +114,7 @@ ox::Result<keel::AssetRef<T>> readObjFile(
template<typename T>
ox::Result<keel::AssetRef<T>> readObjNoCache(
keel::Context &ctx,
ox::CRStringView assetId) noexcept {
ox::StringViewCR assetId) noexcept {
if constexpr(ox::preloadable<T>::value) {
oxRequire(addr, getPreloadAddr(ctx, assetId));
return keel::AssetRef<T>(std::bit_cast<T const*>(uintptr_t{addr}));
@ -130,7 +130,7 @@ ox::Error reloadAsset(keel::Context &ctx, ox::StringView assetId) noexcept;
template<typename T>
ox::Result<keel::AssetRef<T>> readObj(
keel::Context &ctx,
ox::CRStringView assetId,
ox::StringViewCR assetId,
[[maybe_unused]] bool forceLoad = false) noexcept {
#ifndef OX_BARE_METAL
return readObjFile<T>(ctx, assetId, forceLoad);
@ -169,9 +169,9 @@ ox::Error writeObj(
ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> &&fs) noexcept;
ox::Result<ox::UniquePtr<ox::FileSystem>> loadRomFs(ox::CRStringView path) noexcept;
ox::Result<ox::UniquePtr<ox::FileSystem>> loadRomFs(ox::StringViewCR path) noexcept;
ox::Result<char*> loadRom(ox::CRStringView path = "") noexcept;
ox::Result<char*> loadRom(ox::StringViewCR path = "") noexcept;
void unloadRom(char*) noexcept;

View File

@ -142,7 +142,7 @@ ox::Error preloadDir(
ox::TypeStore &ts,
ox::FileSystem &romFs,
ox::Preloader<PlatSpec> &pl,
ox::CRStringView path) noexcept {
ox::StringViewCR path) noexcept {
// copy
oxTracef("pack.preload", "path: {}", path);
oxRequire(fileList, romFs.ls(path));

View File

@ -60,10 +60,10 @@ class BaseConverter {
constexpr virtual int srcTypeVersion() const noexcept = 0;
[[nodiscard]]
constexpr virtual bool srcMatches(ox::CRStringView pSrcTypeName, int pSrcTypeVersion) const noexcept = 0;
constexpr virtual bool srcMatches(ox::StringViewCR pSrcTypeName, int pSrcTypeVersion) const noexcept = 0;
[[nodiscard]]
constexpr virtual bool dstMatches(ox::CRStringView dstTypeName, int dstTypeVersion) const noexcept = 0;
constexpr virtual bool dstMatches(ox::StringViewCR dstTypeName, int dstTypeVersion) const noexcept = 0;
virtual ox::Result<ox::UPtr<Wrap>> convertPtrToPtr(keel::Context &ctx, Wrap &src) const noexcept = 0;
@ -72,8 +72,8 @@ class BaseConverter {
[[nodiscard]]
constexpr bool matches(
ox::CRStringView srcTypeName, int srcTypeVersion,
ox::CRStringView dstTypeName, int dstTypeVersion) const noexcept {
ox::StringViewCR srcTypeName, int srcTypeVersion,
ox::StringViewCR dstTypeName, int dstTypeVersion) const noexcept {
return srcMatches(srcTypeName, srcTypeVersion)
&& dstMatches(dstTypeName, dstTypeVersion);
}
@ -94,7 +94,7 @@ class Converter: public BaseConverter {
}
[[nodiscard]]
constexpr bool srcMatches(ox::CRStringView pSrcTypeName, int pSrcTypeVersion) const noexcept final {
constexpr bool srcMatches(ox::StringViewCR pSrcTypeName, int pSrcTypeVersion) const noexcept final {
constexpr auto SrcTypeName = ox::requireModelTypeName<SrcType>();
constexpr auto SrcTypeVersion = ox::requireModelTypeVersion<SrcType>();
return pSrcTypeName == SrcTypeName
@ -102,7 +102,7 @@ class Converter: public BaseConverter {
}
[[nodiscard]]
constexpr bool dstMatches(ox::CRStringView dstTypeName, int dstTypeVersion) const noexcept final {
constexpr bool dstMatches(ox::StringViewCR dstTypeName, int dstTypeVersion) const noexcept final {
constexpr auto DstTypeName = ox::StringView{ox::requireModelTypeName<DstType>()};
constexpr auto DstTypeVersion = ox::requireModelTypeVersion<DstType>();
return dstTypeName == DstTypeName
@ -133,7 +133,7 @@ class Converter: public BaseConverter {
ox::Result<ox::UPtr<Wrap>> convert(
keel::Context &ctx,
ox::BufferView const&srcBuffer,
ox::CRStringView dstTypeName,
ox::StringViewCR dstTypeName,
int dstTypeVersion) noexcept;
template<typename DstType>

View File

@ -9,7 +9,7 @@ namespace keel {
ox::Error init(
keel::Context &ctx,
ox::UPtr<ox::FileSystem> &&fs,
ox::CRStringView appName) noexcept {
ox::StringViewCR appName) noexcept {
ctx.appName = appName;
std::ignore = setRomFs(ctx, std::move(fs));
#ifndef OX_BARE_METAL
@ -28,7 +28,7 @@ ox::Error init(
return {};
}
ox::Result<ox::UPtr<Context>> init(ox::UPtr<ox::FileSystem> &&fs, ox::CRStringView appName) noexcept {
ox::Result<ox::UPtr<Context>> init(ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept {
auto ctx = ox::make_unique<Context>();
oxReturnError(keel::init(*ctx, std::move(fs), appName));
return ctx;

View File

@ -12,7 +12,7 @@
namespace keel {
ox::Result<char*> loadRom(ox::CRStringView path) noexcept {
ox::Result<char*> loadRom(ox::StringViewCR path) noexcept {
std::ifstream file(std::string(toStdStringView(path)), std::ios::binary | std::ios::ate);
if (!file.good()) {
oxErrorf("Could not find ROM file: {}", path);
@ -47,7 +47,7 @@ void createUuidMapping(Context &ctx, ox::StringView filePath, ox::UUID const&uui
ctx.uuidToPath[uuid.toString()] = filePath;
}
static ox::Error buildUuidMap(Context &ctx, ox::CRStringView path) noexcept {
static ox::Error buildUuidMap(Context &ctx, ox::StringViewCR path) noexcept {
oxRequire(files, ctx.rom->ls(path));
for (auto const&f : files) {
oxRequireM(filePath, ox::join("/", ox::Array<ox::StringView, 2>{path, f}));
@ -74,7 +74,7 @@ ox::Error buildUuidMap(Context &ctx) noexcept {
return buildUuidMap(ctx, "");
}
ox::Result<ox::UUID> pathToUuid(Context &ctx, ox::CRStringView path) noexcept {
ox::Result<ox::UUID> pathToUuid(Context &ctx, ox::StringViewCR path) noexcept {
#ifndef OX_BARE_METAL
oxRequire(out, ctx.pathToUuid.at(path));
return *out;
@ -136,7 +136,7 @@ ox::Result<ox::CStringView> uuidUrlToPath(Context &ctx, ox::StringView uuid) noe
#endif
}
ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::CRStringView uuid) noexcept {
ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::StringViewCR uuid) noexcept {
#ifndef OX_BARE_METAL
oxRequireM(out, ctx.uuidToPath.at(uuid));
return ox::CStringView(*out);
@ -186,7 +186,7 @@ ox::Error buildUuidMap(Context&) noexcept {
return {};
}
ox::Result<char*> loadRom(ox::CRStringView) noexcept {
ox::Result<char*> loadRom(ox::StringViewCR) noexcept {
// put the header in the wrong order to prevent mistaking this code for the
// media section
constexpr auto headerP2 = "R_______________";
@ -206,7 +206,7 @@ ox::Result<char*> loadRom(ox::CRStringView) noexcept {
void unloadRom(char*) noexcept {
}
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::CRStringView path) noexcept {
ox::Result<std::size_t> getPreloadAddr(keel::Context &ctx, ox::StringViewCR path) noexcept {
oxRequire(stat, ctx.rom->stat(path));
oxRequire(buff, static_cast<ox::MemFS*>(ctx.rom.get())->directAccess(path));
PreloadPtr p;
@ -238,7 +238,7 @@ ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> &&fs) noexcept {
return buildUuidMap(ctx);
}
ox::Result<ox::UniquePtr<ox::FileSystem>> loadRomFs(ox::CRStringView path) noexcept {
ox::Result<ox::UniquePtr<ox::FileSystem>> loadRomFs(ox::StringViewCR path) noexcept {
auto const lastDot = ox::lastIndexOf(path, '.');
if (!lastDot.error && substr(path, lastDot.value) == ".oxfs") {
oxRequire(rom, loadRom(path));

View File

@ -107,7 +107,7 @@ static ox::Error doTransformations(
keel::Context &ctx,
ox::TypeStore &ts,
ox::FileSystem &dest,
ox::CRStringView filePath) noexcept {
ox::StringViewCR filePath) noexcept {
// load file
oxRequire(s, dest.stat(filePath));
// do transformations
@ -130,7 +130,7 @@ static ox::Error transformClaw(
keel::Context &ctx,
ox::TypeStore &ts,
ox::FileSystem &dest,
ox::CRStringView path) noexcept {
ox::StringViewCR path) noexcept {
// copy
oxTracef("pack.transformClaw", "path: {}", path);
oxRequire(fileList, dest.ls(path));
@ -155,8 +155,8 @@ static ox::Error copy(
Manifest &manifest,
ox::FileSystem &src,
ox::FileSystem &dest,
ox::CRStringView path,
ox::CRStringView logPrefix = "") noexcept {
ox::StringViewCR path,
ox::StringViewCR logPrefix = "") noexcept {
oxOutf("{}copying directory: {}\n", logPrefix, path);
auto const childLogPrefix = ox::sfmt("{}\t", logPrefix);
// copy

View File

@ -11,9 +11,9 @@ namespace keel {
static ox::Result<BaseConverter const*> findConverter(
ox::SpanView<BaseConverter const*> const&converters,
ox::CRStringView srcTypeName,
ox::StringViewCR srcTypeName,
int srcTypeVersion,
ox::CRStringView dstTypeName,
ox::StringViewCR dstTypeName,
int dstTypeVersion) noexcept {
for (auto const&c : converters) {
if (c->matches(srcTypeName, srcTypeVersion, dstTypeName, dstTypeVersion)) {
@ -27,9 +27,9 @@ static ox::Result<ox::UPtr<Wrap>> convert(
keel::Context &ctx,
ox::SpanView<BaseConverter const*> const&converters,
ox::BufferView const&srcBuffer,
ox::CRStringView srcTypeName,
ox::StringViewCR srcTypeName,
int srcTypeVersion,
ox::CRStringView dstTypeName,
ox::StringViewCR dstTypeName,
int dstTypeVersion) noexcept {
// look for direct converter
auto [c, err] = findConverter(
@ -55,7 +55,7 @@ static ox::Result<ox::UPtr<Wrap>> convert(
ox::Result<ox::UPtr<Wrap>> convert(
keel::Context &ctx,
ox::BufferView const&srcBuffer,
ox::CRStringView dstTypeName,
ox::StringViewCR dstTypeName,
int dstTypeVersion) noexcept {
oxRequire(hdr, readAssetHeader(srcBuffer));
return convert(

View File

@ -93,7 +93,7 @@ void ClawEditor::drawRow(ox::ModelValue const&value) noexcept {
ImGui::Text("%s", val.c_str());
}
void ClawEditor::drawVar(ObjPath &path, ox::CRStringView name, ox::ModelValue const&value) noexcept {
void ClawEditor::drawVar(ObjPath &path, ox::StringViewCR name, ox::ModelValue const&value) noexcept {
using Str = ox::BasicString<100>;
path.push_back(name);
if (value.type() == ox::ModelValue::Type::Object) {

View File

@ -23,7 +23,7 @@ class ClawEditor: public Editor {
private:
static void drawRow(ox::ModelValue const&value) noexcept;
void drawVar(ObjPath &path, ox::CRStringView name, ox::ModelValue const&value) noexcept;
void drawVar(ObjPath &path, ox::StringViewCR name, ox::ModelValue const&value) noexcept;
void drawTree(ObjPath &path, ox::ModelObject const&obj) noexcept;
};

View File

@ -34,8 +34,8 @@ static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down)
}
static ox::Error runApp(
ox::CRStringView appName,
ox::CRStringView projectDataDir,
ox::StringViewCR appName,
ox::StringViewCR projectDataDir,
ox::UPtr<ox::FileSystem> &&fs) noexcept {
oxRequireM(ctx, turbine::init(std::move(fs), appName));
turbine::setWindowTitle(*ctx, keelCtx(*ctx).appName);
@ -50,8 +50,8 @@ static ox::Error runApp(
}
static ox::Error run(
ox::CRStringView appName,
ox::CRStringView projectDataDir,
ox::StringViewCR appName,
ox::StringViewCR projectDataDir,
int,
char const**) {
// seed UUID generator

View File

@ -51,7 +51,7 @@ void ProjectExplorer::setModel(ox::UPtr<ProjectTreeModel> &&model) noexcept {
m_treeModel = std::move(model);
}
ox::Error ProjectExplorer::refreshProjectTreeModel(ox::CRStringView) noexcept {
ox::Error ProjectExplorer::refreshProjectTreeModel(ox::StringViewCR) noexcept {
oxRequireM(model, buildProjectTreeModel(*this, "Project", "/", nullptr));
setModel(std::move(model));
return OxError(0);

View File

@ -23,7 +23,7 @@ class ProjectExplorer: public studio::Widget {
void setModel(ox::UPtr<ProjectTreeModel> &&model) noexcept;
ox::Error refreshProjectTreeModel(ox::CRStringView = {}) noexcept;
ox::Error refreshProjectTreeModel(ox::StringViewCR = {}) noexcept;
[[nodiscard]]
inline ox::FileSystem *romFs() noexcept {

View File

@ -318,7 +318,7 @@ void StudioUI::handleKeyInput() noexcept {
}
}
ox::Error StudioUI::createOpenProject(ox::CRStringView path) noexcept {
ox::Error StudioUI::createOpenProject(ox::StringViewCR path) noexcept {
std::error_code ec;
std::filesystem::create_directories(toStdStringView(path), ec);
oxReturnError(OxError(ec.value() != 0, "Could not create project directory"));
@ -346,11 +346,11 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
return m_projectExplorer.refreshProjectTreeModel();
}
ox::Error StudioUI::openFile(ox::CRStringView path) noexcept {
ox::Error StudioUI::openFile(ox::StringViewCR path) noexcept {
return openFileActiveTab(path, true);
}
ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab) noexcept {
ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool makeActiveTab) noexcept {
if (!m_project) {
return OxError(1, "No project open to open a file from");
}
@ -394,7 +394,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
return {};
}
ox::Error StudioUI::closeFile(ox::CRStringView path) noexcept {
ox::Error StudioUI::closeFile(ox::StringViewCR path) noexcept {
if (!m_openFiles.contains(path)) {
return {};
}

View File

@ -83,15 +83,15 @@ class StudioUI: public ox::SignalHandler {
void handleKeyInput() noexcept;
ox::Error createOpenProject(ox::CRStringView path) noexcept;
ox::Error createOpenProject(ox::StringViewCR path) noexcept;
ox::Error openProjectPath(ox::StringParam path) noexcept;
ox::Error openFile(ox::CRStringView path) noexcept;
ox::Error openFile(ox::StringViewCR path) noexcept;
ox::Error openFileActiveTab(ox::CRStringView path, bool makeActiveTab) noexcept;
ox::Error openFileActiveTab(ox::StringViewCR path, bool makeActiveTab) noexcept;
ox::Error closeFile(ox::CRStringView path) noexcept;
ox::Error closeFile(ox::StringViewCR path) noexcept;
};
}

View File

@ -33,7 +33,7 @@ inline ox::String slashesToPct(ox::StringView str) noexcept {
ox::String configPath(keel::Context const&ctx) noexcept;
template<typename T>
ox::Result<T> readConfig(keel::Context &ctx, ox::CRStringView name) noexcept {
ox::Result<T> readConfig(keel::Context &ctx, ox::StringViewCR name) noexcept {
oxAssert(name != "", "Config type has no TypeName");
auto const path = ox::sfmt("/{}.json", detail::slashesToPct(name));
ox::PassThroughFS fs(configPath(ctx));
@ -52,7 +52,7 @@ ox::Result<T> readConfig(keel::Context &ctx) noexcept {
}
template<typename T>
ox::Error writeConfig(keel::Context &ctx, ox::CRStringView name, T const&data) noexcept {
ox::Error writeConfig(keel::Context &ctx, ox::StringViewCR name, T const&data) noexcept {
oxAssert(name != "", "Config type has no TypeName");
auto const path = ox::sfmt("/{}.json", detail::slashesToPct(name));
ox::PassThroughFS fs(configPath(ctx));
@ -76,7 +76,7 @@ ox::Error writeConfig(keel::Context &ctx, T const&data) noexcept {
}
template<typename T, typename Func>
void openConfig(keel::Context &ctx, ox::CRStringView name, Func f) noexcept {
void openConfig(keel::Context &ctx, ox::StringViewCR name, Func f) noexcept {
oxAssert(name != "", "Config type has no TypeName");
auto const [c, err] = readConfig<T>(ctx, name);
oxLogError(err);
@ -90,7 +90,7 @@ void openConfig(keel::Context &ctx, Func f) noexcept {
}
template<typename T, typename Func>
void editConfig(keel::Context &ctx, ox::CRStringView name, Func f) noexcept {
void editConfig(keel::Context &ctx, ox::StringViewCR name, Func f) noexcept {
oxAssert(name != "", "Config type has no TypeName");
auto [c, err] = readConfig<T>(ctx, name);
oxLogError(err);

View File

@ -17,7 +17,7 @@ struct FDFilterItem {
String name{};
String spec{};
constexpr FDFilterItem() noexcept = default;
FDFilterItem(ox::CRStringView pName, ox::CRStringView pSpec) noexcept;
FDFilterItem(ox::StringViewCR pName, ox::StringViewCR pSpec) noexcept;
};
ox::Result<ox::String> saveFile(ox::Vector<FDFilterItem> const&exts) noexcept;

View File

@ -18,7 +18,7 @@ namespace studio {
class ItemMaker;
struct EditorMaker {
using Func = std::function<ox::Result<class BaseEditor*>(ox::CRStringView)>;
using Func = std::function<ox::Result<class BaseEditor*>(ox::StringViewCR)>;
ox::Vector<ox::String> fileTypes;
Func make;
};
@ -38,7 +38,7 @@ template<typename Editor>
studio::EditorMaker editorMaker(studio::StudioContext &ctx, ox::StringParam ext) noexcept {
return {
{std::move(ext)},
[&ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
[&ctx](ox::StringViewCR path) -> ox::Result<studio::BaseEditor*> {
return ox::makeCatch<Editor>(ctx, path);
}
};

View File

@ -28,7 +28,7 @@ enum class ProjectEvent {
};
[[nodiscard]]
constexpr ox::Result<ox::StringView> fileExt(ox::CRStringView path) noexcept {
constexpr ox::Result<ox::StringView> fileExt(ox::StringViewCR path) noexcept {
auto const extStart = ox::find(path.crbegin(), path.crend(), '.').offset();
if (!extStart) {
return OxError(1, "file path does not have valid extension");
@ -57,7 +57,7 @@ class Project {
ox::HashMap<ox::String, ox::Vector<ox::String>> m_fileExtFileMap;
public:
explicit Project(keel::Context &ctx, ox::String path, ox::CRStringView projectDataDir);
explicit Project(keel::Context &ctx, ox::String path, ox::StringViewCR projectDataDir);
ox::Error create() noexcept;
@ -67,14 +67,14 @@ class Project {
[[nodiscard]]
ox::FileSystem &romFs() noexcept;
ox::Error mkdir(ox::CRStringView path) const noexcept;
ox::Error mkdir(ox::StringViewCR path) const noexcept;
/**
* Writes a MetalClaw object to the project at the given path.
*/
template<typename T>
ox::Error writeObj(
ox::CRStringView path,
ox::StringViewCR path,
T const&obj,
ox::ClawFormat fmt) noexcept;
@ -83,53 +83,53 @@ class Project {
*/
template<typename T>
ox::Error writeObj(
ox::CRStringView path,
ox::StringViewCR path,
T const&obj) noexcept;
template<typename T>
ox::Result<T> loadObj(ox::CRStringView path) const noexcept;
ox::Result<T> loadObj(ox::StringViewCR path) const noexcept;
ox::Result<ox::FileStat> stat(ox::CRStringView path) const noexcept;
ox::Result<ox::FileStat> stat(ox::StringViewCR path) const noexcept;
[[nodiscard]]
bool exists(ox::CRStringView path) const noexcept;
bool exists(ox::StringViewCR path) const noexcept;
template<typename Functor>
ox::Error subscribe(ProjectEvent e, ox::SignalHandler *tgt, Functor &&slot) const noexcept;
[[nodiscard]]
ox::Vector<ox::String> const&fileList(ox::CRStringView ext) noexcept;
ox::Vector<ox::String> const&fileList(ox::StringViewCR ext) noexcept;
ox::Error writeTypeStore() noexcept;
private:
void buildFileIndex() noexcept;
void indexFile(ox::CRStringView path) noexcept;
void indexFile(ox::StringViewCR path) noexcept;
ox::Error writeBuff(ox::CRStringView path, ox::BufferView const&buff) noexcept;
ox::Error writeBuff(ox::StringViewCR path, ox::BufferView const&buff) noexcept;
ox::Result<ox::Buffer> loadBuff(ox::CRStringView path) const noexcept;
ox::Result<ox::Buffer> loadBuff(ox::StringViewCR path) const noexcept;
ox::Error lsProcDir(ox::Vector<ox::String> *paths, ox::CRStringView path) const noexcept;
ox::Error lsProcDir(ox::Vector<ox::String> *paths, ox::StringViewCR path) const noexcept;
ox::Result<ox::Vector<ox::String>> listFiles(ox::CRStringView path = "") const noexcept;
ox::Result<ox::Vector<ox::String>> listFiles(ox::StringViewCR path = "") const noexcept;
// signals
public:
ox::Signal<ox::Error(ProjectEvent, ox::CRStringView)> fileEvent;
ox::Signal<ox::Error(ox::CRStringView)> fileAdded;
ox::Signal<ox::Error(ProjectEvent, ox::StringViewCR)> fileEvent;
ox::Signal<ox::Error(ox::StringViewCR)> fileAdded;
// FileRecognized is triggered for all matching files upon a new
// subscription to a section of the project and upon the addition of a
// file.
ox::Signal<ox::Error(ox::CRStringView)> fileRecognized;
ox::Signal<ox::Error(ox::CRStringView)> fileDeleted;
ox::Signal<ox::Error(ox::StringViewCR)> fileRecognized;
ox::Signal<ox::Error(ox::StringViewCR)> fileDeleted;
ox::Signal<ox::Error(ox::StringView, ox::UUID)> fileUpdated;
};
template<typename T>
ox::Error Project::writeObj(ox::CRStringView path, T const&obj, ox::ClawFormat fmt) noexcept {
ox::Error Project::writeObj(ox::StringViewCR path, T const&obj, ox::ClawFormat fmt) noexcept {
oxRequireM(buff, ox::writeClaw(obj, fmt));
// write to FS
oxReturnError(mkdir(parentDir(path)));
@ -151,14 +151,14 @@ ox::Error Project::writeObj(ox::CRStringView path, T const&obj, ox::ClawFormat f
}
template<typename T>
ox::Error Project::writeObj(ox::CRStringView path, T const&obj) noexcept {
ox::Error Project::writeObj(ox::StringViewCR path, T const&obj) noexcept {
oxRequire(ext, fileExt(path));
auto const fmt = m_typeFmt[ext].or_value(ox::ClawFormat::Metal);
return writeObj(path, obj, fmt);
}
template<typename T>
ox::Result<T> Project::loadObj(ox::CRStringView path) const noexcept {
ox::Result<T> Project::loadObj(ox::StringViewCR path) const noexcept {
oxRequire(buff, loadBuff(path));
if constexpr(ox::is_same_v<T, ox::ModelObject>) {
return keel::readAsset(m_typeStore, buff);

View File

@ -11,7 +11,7 @@
namespace studio {
FDFilterItem::FDFilterItem(ox::CRStringView pName, ox::CRStringView pSpec) noexcept {
FDFilterItem::FDFilterItem(ox::StringViewCR pName, ox::StringViewCR pSpec) noexcept {
name.resize(pName.len() + 1);
ox::strncpy(name.data(), pName.data(), pName.len());
spec.resize(pSpec.len() + 1);

View File

@ -26,7 +26,7 @@ static void generateTypes(ox::TypeStore &ts) noexcept {
}
}
Project::Project(keel::Context &ctx, ox::String path, ox::CRStringView projectDataDir):
Project::Project(keel::Context &ctx, ox::String path, ox::StringViewCR projectDataDir):
m_ctx(ctx),
m_path(std::move(path)),
m_projectDataDir(projectDataDir),
@ -55,7 +55,7 @@ ox::FileSystem &Project::romFs() noexcept {
return m_fs;
}
ox::Error Project::mkdir(ox::CRStringView path) const noexcept {
ox::Error Project::mkdir(ox::StringViewCR path) const noexcept {
auto const [stat, err] = m_fs.stat(path);
if (err) {
oxReturnError(m_fs.mkdir(path, true));
@ -65,15 +65,15 @@ ox::Error Project::mkdir(ox::CRStringView path) const noexcept {
ox::Error{} : OxError(1, "path exists as normal file");
}
ox::Result<ox::FileStat> Project::stat(ox::CRStringView path) const noexcept {
ox::Result<ox::FileStat> Project::stat(ox::StringViewCR path) const noexcept {
return m_fs.stat(path);
}
bool Project::exists(ox::CRStringView path) const noexcept {
bool Project::exists(ox::StringViewCR path) const noexcept {
return m_fs.stat(path).error == 0;
}
ox::Vector<ox::String> const&Project::fileList(ox::CRStringView ext) noexcept {
ox::Vector<ox::String> const&Project::fileList(ox::StringViewCR ext) noexcept {
return m_fileExtFileMap[ext];
}
@ -104,7 +104,7 @@ void Project::buildFileIndex() noexcept {
}
}
void Project::indexFile(ox::CRStringView path) noexcept {
void Project::indexFile(ox::StringViewCR path) noexcept {
auto const [ext, err] = fileExt(path);
if (err) {
return;
@ -112,7 +112,7 @@ void Project::indexFile(ox::CRStringView path) noexcept {
m_fileExtFileMap[ext].emplace_back(path);
}
ox::Error Project::writeBuff(ox::CRStringView path, ox::BufferView const&buff) noexcept {
ox::Error Project::writeBuff(ox::StringViewCR path, ox::BufferView const&buff) noexcept {
constexpr auto HdrSz = 40;
ox::Buffer outBuff;
outBuff.reserve(buff.size() + HdrSz);
@ -133,11 +133,11 @@ ox::Error Project::writeBuff(ox::CRStringView path, ox::BufferView const&buff) n
return {};
}
ox::Result<ox::Buffer> Project::loadBuff(ox::CRStringView path) const noexcept {
ox::Result<ox::Buffer> Project::loadBuff(ox::StringViewCR path) const noexcept {
return m_fs.read(path);
}
ox::Error Project::lsProcDir(ox::Vector<ox::String> *paths, ox::CRStringView path) const noexcept {
ox::Error Project::lsProcDir(ox::Vector<ox::String> *paths, ox::StringViewCR path) const noexcept {
oxRequire(files, m_fs.ls(path));
for (auto const&name : files) {
auto fullPath = ox::sfmt("{}/{}", path, name);
@ -156,7 +156,7 @@ ox::Error Project::lsProcDir(ox::Vector<ox::String> *paths, ox::CRStringView pat
return {};
}
ox::Result<ox::Vector<ox::String>> Project::listFiles(ox::CRStringView path) const noexcept {
ox::Result<ox::Vector<ox::String>> Project::listFiles(ox::StringViewCR path) const noexcept {
ox::Vector<ox::String> paths;
oxReturnError(lsProcDir(&paths, path));
return paths;

View File

@ -30,7 +30,7 @@ class ClipboardObject: public BaseClipboardObject {
ox::String getClipboardText(Context &ctx) noexcept;
void setClipboardText(Context &ctx, ox::CRStringView text) noexcept;
void setClipboardText(Context &ctx, ox::StringViewCR text) noexcept;
void setClipboardObject(Context &ctx, ox::UPtr<BaseClipboardObject> &&obj) noexcept;

View File

@ -26,7 +26,7 @@ void removeDrawer(Context &ctx, Drawer *cd) noexcept;
ox::Error initGfx(Context &ctx) noexcept;
void setWindowTitle(Context &ctx, ox::CRStringView title) noexcept;
void setWindowTitle(Context &ctx, ox::StringViewCR title) noexcept;
void focusWindow(Context &ctx) noexcept;

View File

@ -16,7 +16,7 @@ namespace turbine {
using TimeMs = uint64_t;
ox::Result<ContextUPtr> init(ox::UPtr<ox::FileSystem> &&fs, ox::CRStringView appName) noexcept;
ox::Result<ContextUPtr> init(ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept;
ox::Error run(Context &ctx) noexcept;

View File

@ -12,7 +12,7 @@ ox::String getClipboardText(Context&) noexcept {
return {};
}
void setClipboardText(Context&, ox::CRStringView) noexcept {
void setClipboardText(Context&, ox::StringViewCR) noexcept {
}
}

View File

@ -24,7 +24,7 @@ ox::Error initGfx(Context&) noexcept {
return {};
}
void setWindowTitle(Context&, ox::CRStringView) noexcept {
void setWindowTitle(Context&, ox::StringViewCR) noexcept {
}
int getScreenWidth(Context&) noexcept {

View File

@ -57,7 +57,7 @@ static ox::Result<std::size_t> findPreloadSection() noexcept {
}
ox::Result<ContextUPtr> init(
ox::UPtr<ox::FileSystem> &&fs, ox::CRStringView appName) noexcept {
ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept {
auto ctx = ox::make_unique<Context>();
oxReturnError(keel::init(ctx->keelCtx, std::move(fs), appName));
#ifdef OX_BARE_METAL

View File

@ -16,7 +16,7 @@ ox::String getClipboardText(Context &ctx) noexcept {
return ox::String(glfwGetClipboardString(ctx.window));
}
void setClipboardText(Context &ctx, ox::CRStringView text) noexcept {
void setClipboardText(Context &ctx, ox::StringViewCR text) noexcept {
auto cstr = ox_malloca(text.bytes() + 1, char);
ox::strncpy(cstr.get(), text.data(), text.bytes());
glfwSetClipboardString(ctx.window, cstr.get());

View File

@ -219,7 +219,7 @@ ox::Error initGfx(Context &ctx) noexcept {
return {};
}
void setWindowTitle(Context &ctx, ox::CRStringView title) noexcept {
void setWindowTitle(Context &ctx, ox::StringViewCR title) noexcept {
auto cstr = ox_malloca(title.bytes() + 1, char);
ox::strncpy(cstr.get(), title.data(), title.bytes());
glfwSetWindowTitle(ctx.window, cstr.get());

View File

@ -41,7 +41,7 @@ static void draw(GLFWwindow *window, int, int) noexcept {
}
ox::Result<ContextUPtr> init(
ox::UPtr<ox::FileSystem> &&fs, ox::CRStringView appName) noexcept {
ox::UPtr<ox::FileSystem> &&fs, ox::StringViewCR appName) noexcept {
auto ctx = ox::make_unique<Context>();
oxReturnError(keel::init(ctx->keelCtx, std::move(fs), appName));
using namespace std::chrono;