[olympic,nostalgia] Rename CRStringView to StringViewCR
This commit is contained in:
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
};
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user