[olympic,nostalgia] Rename CRStringView to StringViewCR

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

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;