Compare commits

...

4 Commits

Author SHA1 Message Date
1a9f0d49e7 [ox] Rename CRString to StringCR
All checks were successful
Build / build (push) Successful in 2m30s
2024-09-28 17:46:45 -05:00
a1b5b56553 [olympic,nostalgia] Rename CRStringView to StringViewCR 2024-09-28 16:10:44 -05:00
256be6dae0 [glutils] Rename CRStringView to StringViewCR 2024-09-28 16:10:16 -05:00
cc10631b55 [ox] Rename CRStringView to StringViewCR 2024-09-28 16:09:43 -05:00
67 changed files with 280 additions and 280 deletions

View File

@ -73,7 +73,7 @@ void bind(const FrameBuffer &fb) noexcept {
static ox::Result<GLShader> buildShader(
GLuint shaderType,
const GLchar *src,
ox::CRStringView shaderName) noexcept {
ox::StringViewCR shaderName) noexcept {
GLShader shader(glCreateShader(shaderType));
glShaderSource(shader, 1, &src, nullptr);
glCompileShader(shader);

View File

@ -37,32 +37,32 @@ ClArgs::ClArgs(int argc, const char **args) noexcept {
}
}
bool ClArgs::getBool(ox::CRStringView arg, bool defaultValue) const noexcept {
bool ClArgs::getBool(ox::StringViewCR arg, bool defaultValue) const noexcept {
auto [value, err] = m_ints.at(arg);
return !err ? *value : defaultValue;
}
String ClArgs::getString(ox::CRStringView arg, ox::StringView defaultValue) const noexcept {
String ClArgs::getString(ox::StringViewCR arg, ox::StringView defaultValue) const noexcept {
auto [value, err] = m_strings.at(arg);
return !err ? ox::String(*value) : ox::String(defaultValue);
}
int ClArgs::getInt(ox::CRStringView arg, int defaultValue) const noexcept {
int ClArgs::getInt(ox::StringViewCR arg, int defaultValue) const noexcept {
auto [value, err] = m_ints.at(arg);
return !err ? *value : defaultValue;
}
Result<bool> ClArgs::getBool(ox::CRStringView arg) const noexcept {
Result<bool> ClArgs::getBool(ox::StringViewCR arg) const noexcept {
oxRequire(out, m_bools.at(arg));
return *out;
}
Result<String> ClArgs::getString(ox::CRStringView argName) const noexcept {
Result<String> ClArgs::getString(ox::StringViewCR argName) const noexcept {
oxRequire(out, m_strings.at(argName));
return *out;
}
Result<int> ClArgs::getInt(ox::CRStringView arg) const noexcept {
Result<int> ClArgs::getInt(ox::StringViewCR arg) const noexcept {
oxRequire(out, m_ints.at(arg));
return *out;
}

View File

@ -23,21 +23,21 @@ class ClArgs {
ClArgs(int argc, const char **args) noexcept;
[[nodiscard]]
bool getBool(ox::CRStringView arg, bool defaultValue) const noexcept;
bool getBool(ox::StringViewCR arg, bool defaultValue) const noexcept;
[[nodiscard]]
String getString(ox::CRStringView argName, ox::StringView defaultValue) const noexcept;
String getString(ox::StringViewCR argName, ox::StringView defaultValue) const noexcept;
[[nodiscard]]
int getInt(ox::CRStringView arg, int defaultValue) const noexcept;
int getInt(ox::StringViewCR arg, int defaultValue) const noexcept;
[[nodiscard]]
Result<bool> getBool(ox::CRStringView arg) const noexcept;
Result<bool> getBool(ox::StringViewCR arg) const noexcept;
[[nodiscard]]
Result<String> getString(ox::CRStringView argName) const noexcept;
Result<String> getString(ox::StringViewCR argName) const noexcept;
Result<int> getInt(ox::CRStringView arg) const noexcept;
Result<int> getInt(ox::StringViewCR arg) const noexcept;
};

View File

@ -43,7 +43,7 @@ struct OX_PACKED DirectoryEntry {
public:
constexpr DirectoryEntry() noexcept = default;
Error init(InodeId_t inode, ox::CRStringView name, size_t bufferSize) noexcept {
Error init(InodeId_t inode, ox::StringViewCR name, size_t bufferSize) noexcept {
oxTracef("ox.fs.DirectoryEntry.init", "inode: {}, name: {}, bufferSize: {}", inode, name, bufferSize);
m_bufferSize = static_cast<InodeId_t>(bufferSize);
auto d = data();
@ -284,7 +284,7 @@ Error Directory<FileStore, InodeId_t>::ls(F cb) noexcept {
}
template<typename FileStore, typename InodeId_t>
Result<typename FileStore::InodeId_t> Directory<FileStore, InodeId_t>::findEntry(CRStringView name) const noexcept {
Result<typename FileStore::InodeId_t> Directory<FileStore, InodeId_t>::findEntry(StringViewCR name) const noexcept {
oxTrace("ox.fs.Directory.findEntry", name);
auto buff = m_fs.read(m_inodeId).template to<Buffer>();
if (!buff.valid()) {

View File

@ -28,7 +28,7 @@ FileAddress::FileAddress(uint64_t inode) noexcept {
m_type = FileAddressType::Inode;
}
FileAddress::FileAddress(ox::CRStringView path) noexcept {
FileAddress::FileAddress(ox::StringViewCR path) noexcept {
auto pathSize = path.bytes();
m_data.path = new char[pathSize + 1];
memcpy(m_data.path, path.data(), pathSize);
@ -114,7 +114,7 @@ bool FileAddress::operator==(FileAddress const&other) const noexcept {
return true;
}
bool FileAddress::operator==(CRStringView path) const noexcept {
bool FileAddress::operator==(StringViewCR path) const noexcept {
auto [p, err] = getPath();
if (err) {
return false;

View File

@ -57,7 +57,7 @@ class FileAddress {
FileAddress(uint64_t inode) noexcept;
explicit FileAddress(CRStringView path) noexcept;
explicit FileAddress(StringViewCR path) noexcept;
constexpr FileAddress(ox::StringLiteral path) noexcept;
@ -69,7 +69,7 @@ class FileAddress {
bool operator==(const FileAddress &other) const noexcept;
bool operator==(CRStringView path) const noexcept;
bool operator==(StringViewCR path) const noexcept;
[[nodiscard]]
constexpr FileAddressType type() const noexcept {

View File

@ -44,7 +44,7 @@ Result<Buffer> FileSystem::read(const FileAddress &addr) noexcept {
return buff;
}
Result<Buffer> FileSystem::read(CRStringView path) noexcept {
Result<Buffer> FileSystem::read(StringViewCR path) noexcept {
oxRequire(s, statPath(path));
Buffer buff(static_cast<std::size_t>(s.size));
oxReturnError(readFilePath(path, buff.data(), buff.size()));

View File

@ -30,22 +30,22 @@ class FileSystem {
public:
virtual ~FileSystem() noexcept = default;
virtual Error mkdir(CRStringView path, bool recursive) noexcept = 0;
virtual Error mkdir(StringViewCR path, bool recursive) noexcept = 0;
/**
* Moves an entry from one directory to another.
* @param src the path to the file
* @param dest the path of the destination directory
*/
virtual Error move(CRStringView src, CRStringView dest) noexcept = 0;
virtual Error move(StringViewCR src, StringViewCR dest) noexcept = 0;
Error read(const FileAddress &addr, void *buffer, std::size_t size) noexcept;
Result<Buffer> read(const FileAddress &addr) noexcept;
Result<Buffer> read(CRStringView path) noexcept;
Result<Buffer> read(StringViewCR path) noexcept;
inline Error read(CRStringView path, void *buffer, std::size_t buffSize) noexcept {
inline Error read(StringViewCR path, void *buffer, std::size_t buffSize) noexcept {
return readFilePath(path, buffer, buffSize);
}
@ -55,19 +55,19 @@ class FileSystem {
Error read(const FileAddress &addr, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept;
virtual Result<Vector<String>> ls(CRStringView dir) const noexcept = 0;
virtual Result<Vector<String>> ls(StringViewCR dir) const noexcept = 0;
virtual Error remove(CRStringView path, bool recursive) noexcept = 0;
virtual Error remove(StringViewCR path, bool recursive) noexcept = 0;
Error remove(const FileAddress &addr, bool recursive = false) noexcept;
virtual Error resize(uint64_t size, void *buffer) noexcept = 0;
Error write(CRStringView path, const void *buffer, uint64_t size) noexcept {
Error write(StringViewCR path, const void *buffer, uint64_t size) noexcept {
return writeFilePath(path, buffer, size, FileType::NormalFile);
}
Error write(CRStringView path, ox::Span<char> const&buff) noexcept {
Error write(StringViewCR path, ox::Span<char> const&buff) noexcept {
return write(path, buff.data(), buff.size(), FileType::NormalFile);
}
@ -81,7 +81,7 @@ class FileSystem {
Error write(const FileAddress &addr, const void *buffer, uint64_t size, FileType fileType = FileType::NormalFile) noexcept;
inline Error write(CRStringView path, const void *buffer, uint64_t size, FileType fileType) noexcept {
inline Error write(StringViewCR path, const void *buffer, uint64_t size, FileType fileType) noexcept {
return writeFilePath(path, buffer, size, fileType);
}
@ -93,7 +93,7 @@ class FileSystem {
return statInode(inode);
}
inline Result<FileStat> stat(CRStringView path) const noexcept {
inline Result<FileStat> stat(StringViewCR path) const noexcept {
return statPath(path);
}
@ -134,15 +134,15 @@ class FileSystem {
protected:
virtual Result<FileStat> statInode(uint64_t inode) const noexcept = 0;
virtual Result<FileStat> statPath(CRStringView path) const noexcept = 0;
virtual Result<FileStat> statPath(StringViewCR path) const noexcept = 0;
virtual Error readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept = 0;
virtual Error readFilePath(StringViewCR path, void *buffer, std::size_t buffSize) noexcept = 0;
virtual Error readFileInode(uint64_t inode, void *buffer, std::size_t size) noexcept = 0;
virtual Error readFileInodeRange(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept = 0;
virtual Error writeFilePath(CRStringView path, const void *buffer, uint64_t size, FileType fileType) noexcept = 0;
virtual Error writeFilePath(StringViewCR path, const void *buffer, uint64_t size, FileType fileType) noexcept = 0;
virtual Error writeFileInode(uint64_t inode, const void *buffer, uint64_t size, FileType fileType) noexcept = 0;
@ -152,7 +152,7 @@ class MemFS: public FileSystem {
public:
Result<const char*> directAccess(const FileAddress &addr) const noexcept;
inline Result<const char*> directAccess(CRStringView path) const noexcept {
inline Result<const char*> directAccess(StringViewCR path) const noexcept {
return directAccessPath(path);
}
@ -161,7 +161,7 @@ class MemFS: public FileSystem {
}
protected:
virtual Result<const char*> directAccessPath(CRStringView path) const noexcept = 0;
virtual Result<const char*> directAccessPath(StringViewCR path) const noexcept = 0;
virtual Result<const char*> directAccessInode(uint64_t inode) const noexcept = 0;
};
@ -197,13 +197,13 @@ class FileSystemTemplate: public MemFS {
static Error format(void *buff, uint64_t buffSize) noexcept;
Error mkdir(CRStringView path, bool recursive) noexcept override;
Error mkdir(StringViewCR path, bool recursive) noexcept override;
Error move(CRStringView src, CRStringView dest) noexcept override;
Error move(StringViewCR src, StringViewCR dest) noexcept override;
Error readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept override;
Error readFilePath(StringViewCR path, void *buffer, std::size_t buffSize) noexcept override;
Result<const char*> directAccessPath(CRStringView) const noexcept override;
Result<const char*> directAccessPath(StringViewCR) const noexcept override;
Error readFileInode(uint64_t inode, void *buffer, std::size_t size) noexcept override;
@ -211,12 +211,12 @@ class FileSystemTemplate: public MemFS {
Result<const char*> directAccessInode(uint64_t) const noexcept override;
Result<Vector<String>> ls(CRStringView dir) const noexcept override;
Result<Vector<String>> ls(StringViewCR dir) const noexcept override;
template<typename F>
Error ls(CRStringView path, F cb) const;
Error ls(StringViewCR path, F cb) const;
Error remove(CRStringView path, bool recursive) noexcept override;
Error remove(StringViewCR path, bool recursive) noexcept override;
/**
* Resizes FileSystem to minimum possible size.
@ -225,13 +225,13 @@ class FileSystemTemplate: public MemFS {
Error resize(uint64_t size, void *buffer) noexcept override;
Error writeFilePath(CRStringView path, const void *buffer, uint64_t size, FileType fileType) noexcept override;
Error writeFilePath(StringViewCR path, const void *buffer, uint64_t size, FileType fileType) noexcept override;
Error writeFileInode(uint64_t inode, const void *buffer, uint64_t size, FileType fileType) noexcept override;
Result<FileStat> statInode(uint64_t inode) const noexcept override;
Result<FileStat> statPath(CRStringView path) const noexcept override;
Result<FileStat> statPath(StringViewCR path) const noexcept override;
[[nodiscard]]
uint64_t spaceNeeded(uint64_t size) const noexcept override;
@ -253,7 +253,7 @@ class FileSystemTemplate: public MemFS {
/**
* Finds the inode ID at the given path.
*/
Result<uint64_t> find(CRStringView path) const noexcept;
Result<uint64_t> find(StringViewCR path) const noexcept;
Result<Directory> rootDir() const noexcept;
@ -305,14 +305,14 @@ Error FileSystemTemplate<FileStore, Directory>::format(void *buff, uint64_t buff
}
template<typename FileStore, typename Directory>
Error FileSystemTemplate<FileStore, Directory>::mkdir(CRStringView path, bool recursive) noexcept {
Error FileSystemTemplate<FileStore, Directory>::mkdir(StringViewCR path, bool recursive) noexcept {
oxTracef("ox.fs.FileSystemTemplate.mkdir", "path: {}, recursive: {}", path, recursive);
oxRequireM(rootDir, this->rootDir());
return rootDir.mkdir(path, recursive);
}
template<typename FileStore, typename Directory>
Error FileSystemTemplate<FileStore, Directory>::move(CRStringView src, CRStringView dest) noexcept {
Error FileSystemTemplate<FileStore, Directory>::move(StringViewCR src, StringViewCR dest) noexcept {
oxRequire(fd, fileSystemData());
Directory rootDir(m_fs, fd.rootDirInode);
oxRequireM(inode, rootDir.find(src));
@ -322,7 +322,7 @@ Error FileSystemTemplate<FileStore, Directory>::move(CRStringView src, CRStringV
}
template<typename FileStore, typename Directory>
Error FileSystemTemplate<FileStore, Directory>::readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept {
Error FileSystemTemplate<FileStore, Directory>::readFilePath(StringViewCR path, void *buffer, std::size_t buffSize) noexcept {
oxTrace("ox.fs.FileSystemTemplate.readFilePath", path);
oxRequire(fd, fileSystemData());
Directory rootDir(m_fs, fd.rootDirInode);
@ -334,7 +334,7 @@ Error FileSystemTemplate<FileStore, Directory>::readFilePath(CRStringView path,
}
template<typename FileStore, typename Directory>
Result<const char*> FileSystemTemplate<FileStore, Directory>::directAccessPath(CRStringView path) const noexcept {
Result<const char*> FileSystemTemplate<FileStore, Directory>::directAccessPath(StringViewCR path) const noexcept {
oxRequire(fd, fileSystemData());
Directory rootDir(m_fs, fd.rootDirInode);
oxRequire(inode, rootDir.find(path));
@ -366,9 +366,9 @@ Result<const char*> FileSystemTemplate<FileStore, Directory>::directAccessInode(
}
template<typename FileStore, typename Directory>
Result<Vector<String>> FileSystemTemplate<FileStore, Directory>::ls(CRStringView path) const noexcept {
Result<Vector<String>> FileSystemTemplate<FileStore, Directory>::ls(StringViewCR path) const noexcept {
Vector<String> out;
oxReturnError(ls(path, [&out](CRStringView name, typename FileStore::InodeId_t) {
oxReturnError(ls(path, [&out](StringViewCR name, typename FileStore::InodeId_t) {
out.emplace_back(name);
return OxError(0);
}));
@ -377,7 +377,7 @@ Result<Vector<String>> FileSystemTemplate<FileStore, Directory>::ls(CRStringView
template<typename FileStore, typename Directory>
template<typename F>
Error FileSystemTemplate<FileStore, Directory>::ls(CRStringView path, F cb) const {
Error FileSystemTemplate<FileStore, Directory>::ls(StringViewCR path, F cb) const {
oxTracef("ox.fs.FileSystemTemplate.ls", "path: {}", path);
oxRequire(s, stat(path));
Directory dir(m_fs, s.inode);
@ -385,7 +385,7 @@ Error FileSystemTemplate<FileStore, Directory>::ls(CRStringView path, F cb) cons
}
template<typename FileStore, typename Directory>
Error FileSystemTemplate<FileStore, Directory>::remove(CRStringView path, bool recursive) noexcept {
Error FileSystemTemplate<FileStore, Directory>::remove(StringViewCR path, bool recursive) noexcept {
oxRequire(fd, fileSystemData());
Directory rootDir(m_fs, fd.rootDirInode);
oxRequire(inode, rootDir.find(path));
@ -416,7 +416,7 @@ Error FileSystemTemplate<FileStore, Directory>::resize(uint64_t size, void *buff
template<typename FileStore, typename Directory>
Error FileSystemTemplate<FileStore, Directory>::writeFilePath(
CRStringView path,
StringViewCR path,
const void *buffer,
uint64_t size,
FileType fileType) noexcept {
@ -449,7 +449,7 @@ Result<FileStat> FileSystemTemplate<FileStore, Directory>::statInode(uint64_t in
}
template<typename FileStore, typename Directory>
Result<FileStat> FileSystemTemplate<FileStore, Directory>::statPath(CRStringView path) const noexcept {
Result<FileStat> FileSystemTemplate<FileStore, Directory>::statPath(StringViewCR path) const noexcept {
oxRequire(inode, find(path));
return stat(inode);
}
@ -492,7 +492,7 @@ Result<typename FileSystemTemplate<FileStore, Directory>::FileSystemData> FileSy
}
template<typename FileStore, typename Directory>
Result<uint64_t> FileSystemTemplate<FileStore, Directory>::find(CRStringView path) const noexcept {
Result<uint64_t> FileSystemTemplate<FileStore, Directory>::find(StringViewCR path) const noexcept {
oxRequire(fd, fileSystemData());
// return root as a special case
if (path == "/") {

View File

@ -17,7 +17,7 @@
namespace ox {
PassThroughFS::PassThroughFS(CRStringView dirPath) {
PassThroughFS::PassThroughFS(StringViewCR dirPath) {
m_path = std::string_view(dirPath.data(), dirPath.bytes());
}
@ -27,7 +27,7 @@ String PassThroughFS::basePath() const noexcept {
return ox::String(m_path.string().c_str());
}
Error PassThroughFS::mkdir(CRStringView path, bool recursive) noexcept {
Error PassThroughFS::mkdir(StringViewCR path, bool recursive) noexcept {
bool success = false;
const auto p = m_path / stripSlash(path);
const auto u8p = p.u8string();
@ -54,7 +54,7 @@ Error PassThroughFS::mkdir(CRStringView path, bool recursive) noexcept {
return OxError(success ? 0 : 1);
}
Error PassThroughFS::move(CRStringView src, CRStringView dest) noexcept {
Error PassThroughFS::move(StringViewCR src, StringViewCR dest) noexcept {
std::error_code ec;
std::filesystem::rename(m_path / stripSlash(src), m_path / stripSlash(dest), ec);
if (ec.value()) {
@ -63,7 +63,7 @@ Error PassThroughFS::move(CRStringView src, CRStringView dest) noexcept {
return OxError(0);
}
Result<Vector<String>> PassThroughFS::ls(CRStringView dir) const noexcept {
Result<Vector<String>> PassThroughFS::ls(StringViewCR dir) const noexcept {
Vector<String> out;
std::error_code ec;
const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec);
@ -75,7 +75,7 @@ Result<Vector<String>> PassThroughFS::ls(CRStringView dir) const noexcept {
return out;
}
Error PassThroughFS::remove(CRStringView path, bool recursive) noexcept {
Error PassThroughFS::remove(StringViewCR path, bool recursive) noexcept {
if (recursive) {
return OxError(std::filesystem::remove_all(m_path / stripSlash(path)) != 0);
} else {
@ -93,7 +93,7 @@ Result<FileStat> PassThroughFS::statInode(uint64_t) const noexcept {
return OxError(1, "statInode(uint64_t) is not supported by PassThroughFS");
}
Result<FileStat> PassThroughFS::statPath(CRStringView path) const noexcept {
Result<FileStat> PassThroughFS::statPath(StringViewCR path) const noexcept {
std::error_code ec;
const auto p = m_path / stripSlash(path);
const FileType type = std::filesystem::is_directory(p, ec) ?
@ -140,7 +140,7 @@ bool PassThroughFS::valid() const noexcept {
return false;
}
Error PassThroughFS::readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept {
Error PassThroughFS::readFilePath(StringViewCR path, void *buffer, std::size_t buffSize) noexcept {
try {
std::ifstream file((m_path / stripSlash(path)), std::ios::binary | std::ios::ate);
const std::size_t size = static_cast<std::size_t>(file.tellg());
@ -167,7 +167,7 @@ Error PassThroughFS::readFileInodeRange(uint64_t, std::size_t, std::size_t, void
return OxError(1, "read(uint64_t, std::size_t, std::size_t, void*, std::size_t*) is not supported by PassThroughFS");
}
Error PassThroughFS::writeFilePath(CRStringView path, const void *buffer, uint64_t size, FileType) noexcept {
Error PassThroughFS::writeFilePath(StringViewCR path, const void *buffer, uint64_t size, FileType) noexcept {
const auto p = (m_path / stripSlash(path));
try {
std::ofstream f(p, std::ios::binary);

View File

@ -29,29 +29,29 @@ class PassThroughFS: public FileSystem {
std::filesystem::path m_path;
public:
explicit PassThroughFS(CRStringView dirPath);
explicit PassThroughFS(StringViewCR dirPath);
~PassThroughFS() noexcept override;
[[nodiscard]]
String basePath() const noexcept;
Error mkdir(CRStringView path, bool recursive) noexcept override;
Error mkdir(StringViewCR path, bool recursive) noexcept override;
Error move(CRStringView src, CRStringView dest) noexcept override;
Error move(StringViewCR src, StringViewCR dest) noexcept override;
Result<Vector<String>> ls(CRStringView dir) const noexcept override;
Result<Vector<String>> ls(StringViewCR dir) const noexcept override;
template<typename F>
Error ls(CRStringView dir, F cb) const noexcept;
Error ls(StringViewCR dir, F cb) const noexcept;
Error remove(CRStringView path, bool recursive) noexcept override;
Error remove(StringViewCR path, bool recursive) noexcept override;
Error resize(uint64_t size, void *buffer) noexcept override;
Result<FileStat> statInode(uint64_t inode) const noexcept override;
Result<FileStat> statPath(CRStringView path) const noexcept override;
Result<FileStat> statPath(StringViewCR path) const noexcept override;
[[nodiscard]]
uint64_t spaceNeeded(uint64_t size) const noexcept override;
@ -69,13 +69,13 @@ class PassThroughFS: public FileSystem {
bool valid() const noexcept override;
protected:
Error readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept override;
Error readFilePath(StringViewCR path, void *buffer, std::size_t buffSize) noexcept override;
Error readFileInode(uint64_t inode, void *buffer, std::size_t size) noexcept override;
Error readFileInodeRange(uint64_t inode, std::size_t readStart, std::size_t readSize, void *buffer, std::size_t *size) noexcept override;
Error writeFilePath(CRStringView path, const void *buffer, uint64_t size, FileType fileType) noexcept override;
Error writeFilePath(StringViewCR path, const void *buffer, uint64_t size, FileType fileType) noexcept override;
Error writeFileInode(uint64_t inode, const void *buffer, uint64_t size, FileType fileType) noexcept override;
@ -89,7 +89,7 @@ class PassThroughFS: public FileSystem {
};
template<typename F>
Error PassThroughFS::ls(CRStringView dir, F cb) const noexcept {
Error PassThroughFS::ls(StringViewCR dir, F cb) const noexcept {
std::error_code ec;
const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec);
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: ls failed"));

View File

@ -22,7 +22,7 @@ PathIterator::PathIterator(const char *path, std::size_t maxSize, std::size_t it
PathIterator::PathIterator(const char *path): PathIterator(path, ox::strlen(path)) {
}
PathIterator::PathIterator(CRStringView path): PathIterator(path.data(), path.bytes()) {
PathIterator::PathIterator(StringViewCR path): PathIterator(path.data(), path.bytes()) {
}
/**

View File

@ -25,7 +25,7 @@ class PathIterator {
PathIterator(const char *path);
PathIterator(CRStringView path);
PathIterator(StringViewCR path);
Error dirPath(char *pathOut, std::size_t pathOutSize);

View File

@ -51,7 +51,7 @@ LoggerConn::~LoggerConn() noexcept {
}
}
ox::Error LoggerConn::initConn(ox::CRStringView appName) noexcept {
ox::Error LoggerConn::initConn(ox::StringViewCR appName) noexcept {
sockaddr_in addr{};
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);

View File

@ -38,7 +38,7 @@ class LoggerConn: public trace::Logger {
LoggerConn &operator=(const LoggerConn&) noexcept = delete;
ox::Error send(const trace::TraceMsg&) noexcept final;
ox::Error sendInit(const trace::InitTraceMsg&) noexcept final;
ox::Error initConn(ox::CRStringView appName) noexcept;
ox::Error initConn(ox::StringViewCR appName) noexcept;
ox::Error send(const char *buff, std::size_t len) const noexcept;
private:
void msgSend() noexcept;

View File

@ -35,7 +35,7 @@ constexpr auto buildTypeId() noexcept {
}
static constexpr auto buildTypeId(
CRStringView name, int version,
StringViewCR name, int version,
const TypeParamPack &typeParams = {}) noexcept {
String tp;
if (!typeParams.empty()) {

View File

@ -91,23 +91,23 @@ class TypeDescWriter {
constexpr ~TypeDescWriter() noexcept = default;
template<typename T = std::nullptr_t>
constexpr ox::Error setTypeInfo(CRStringView name = T::TypeName,
int version = T::TypeVersion,
const TypeParamPack &typeParams = {},
std::size_t fields = ModelFieldCount_v<T>) noexcept;
constexpr ox::Error setTypeInfo(StringViewCR name = T::TypeName,
int version = T::TypeVersion,
const TypeParamPack &typeParams = {},
std::size_t fields = ModelFieldCount_v<T>) noexcept;
template<typename T>
constexpr Error field(CRStringView name, const T *val, std::size_t valLen,
constexpr Error field(StringViewCR name, const T *val, std::size_t valLen,
const SubscriptStack &subscriptStack = {}) noexcept;
template<typename T, bool force>
constexpr Error field(CRStringView name, UnionView<T, force> val) noexcept;
constexpr Error field(StringViewCR name, UnionView<T, force> val) noexcept;
template<typename T>
constexpr Error field(CRStringView name, const T *val) noexcept;
constexpr Error field(StringViewCR name, const T *val) noexcept;
template<typename ...Args>
constexpr Error fieldCString(CRStringView name, Args&&...) noexcept;
constexpr Error fieldCString(StringViewCR name, Args&&...) noexcept;
[[nodiscard]]
constexpr DescriptorType *definition() noexcept {
@ -167,7 +167,7 @@ class TypeDescWriter {
constexpr const DescriptorType *type(UnionView<U> val) const noexcept;
[[nodiscard]]
constexpr const DescriptorType *getType(CRStringView tn, int typeVersion, PrimitiveType t, int b,
constexpr const DescriptorType *getType(StringViewCR tn, int typeVersion, PrimitiveType t, int b,
const TypeParamPack &typeParams = {}) const noexcept;
};
@ -176,8 +176,8 @@ constexpr TypeDescWriter::TypeDescWriter(TypeStore *typeStore) noexcept: m_typeS
template<typename T>
constexpr ox::Error TypeDescWriter::setTypeInfo(
CRStringView typeName, int typeVersion,
const TypeParamPack &typeParams, std::size_t) noexcept {
StringViewCR typeName, int typeVersion,
const TypeParamPack &typeParams, std::size_t) noexcept {
PrimitiveType pt;
if constexpr(is_union_v<T>) {
pt = PrimitiveType::Union;
@ -193,7 +193,7 @@ constexpr ox::Error TypeDescWriter::setTypeInfo(
// array handler
template<typename T>
constexpr Error TypeDescWriter::field(CRStringView name, const T*, std::size_t, const SubscriptStack &subscriptStack) noexcept {
constexpr Error TypeDescWriter::field(StringViewCR name, const T*, std::size_t, const SubscriptStack &subscriptStack) noexcept {
if (m_type) {
constexpr typename remove_pointer<T>::type *p = nullptr;
const auto t = type(p);
@ -205,7 +205,7 @@ constexpr Error TypeDescWriter::field(CRStringView name, const T*, std::size_t,
}
template<typename T, bool force>
constexpr Error TypeDescWriter::field(CRStringView name, UnionView<T, force> val) noexcept {
constexpr Error TypeDescWriter::field(StringViewCR name, UnionView<T, force> val) noexcept {
if (m_type) {
const auto t = type(val);
oxAssert(t != nullptr, "field(const char *name, T val): Type not found or generated");
@ -216,7 +216,7 @@ constexpr Error TypeDescWriter::field(CRStringView name, UnionView<T, force> val
}
template<typename T>
constexpr Error TypeDescWriter::field(CRStringView name, const T *val) noexcept {
constexpr Error TypeDescWriter::field(StringViewCR name, const T *val) noexcept {
if (m_type) {
if constexpr(isVector_v<T> || isArray_v<T>) {
typename T::value_type *data = nullptr;
@ -237,7 +237,7 @@ constexpr Error TypeDescWriter::field(CRStringView name, const T *val) noexcept
}
template<typename ...Args>
constexpr Error TypeDescWriter::fieldCString(CRStringView name, Args&&...) noexcept {
constexpr Error TypeDescWriter::fieldCString(StringViewCR name, Args&&...) noexcept {
constexpr auto s = "";
const auto t = type(s);
m_type->fieldList.emplace_back(t, String(name), 0, SubscriptStack{}, ox::String(t->typeName));
@ -339,7 +339,7 @@ constexpr const DescriptorType *TypeDescWriter::type(const IString<sz>*) const n
return getType(types::BString, 0, PT, 0);
}
constexpr const DescriptorType *TypeDescWriter::getType(CRStringView tn, int typeVersion, PrimitiveType pt, int b,
constexpr const DescriptorType *TypeDescWriter::getType(StringViewCR tn, int typeVersion, PrimitiveType pt, int b,
const TypeParamPack &typeParams) const noexcept {
auto t = m_typeStore->get(tn, typeVersion, typeParams);
if (!t.error) {

View File

@ -24,24 +24,24 @@ class FieldCounter {
std::size_t fields = 0;
template<typename U = std::nullptr_t>
constexpr ox::Error setTypeInfo(CRStringView = "", int = 0, const Vector<String>& = {}, std::size_t = 0) {
constexpr ox::Error setTypeInfo(StringViewCR = "", int = 0, const Vector<String>& = {}, std::size_t = 0) {
return {};
}
template<typename U>
constexpr ox::Error field(CRStringView, U) noexcept {
constexpr ox::Error field(StringViewCR, U) noexcept {
++fields;
return OxError(0);
}
template<typename U>
constexpr ox::Error field(CRStringView, U, std::size_t) noexcept {
constexpr ox::Error field(StringViewCR, U, std::size_t) noexcept {
++fields;
return OxError(0);
}
template<typename U, typename Handler>
constexpr Error field(CRStringView, Handler) {
constexpr Error field(StringViewCR, Handler) {
++fields;
return OxError(0);
}

View File

@ -652,7 +652,7 @@ class ModelObject {
}
[[nodiscard]]
constexpr CRString typeName() const noexcept {
constexpr StringCR typeName() const noexcept {
return m_type->typeName;
}

View File

@ -44,7 +44,7 @@ class TypeStore {
return out->get();
}
constexpr DescriptorType *getInit(CRStringView typeName, int typeVersion, PrimitiveType pt,
constexpr DescriptorType *getInit(StringViewCR typeName, int typeVersion, PrimitiveType pt,
const TypeParamPack &typeParams) noexcept {
const auto typeId = buildTypeId(typeName, typeVersion, typeParams);
auto &out = m_cache[typeId];
@ -105,7 +105,7 @@ class TypeStore {
return OxError(1);
}
Result<UniquePtr<DescriptorType>> loadDescriptor(ox::CRStringView name, int version,
Result<UniquePtr<DescriptorType>> loadDescriptor(ox::StringViewCR name, int version,
const ox::TypeParamPack &typeParams) noexcept {
const auto typeId = buildTypeId(name, version, typeParams);
return loadDescriptor(typeId);

View File

@ -46,12 +46,12 @@ struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>, OpT
}
template<typename T, bool force>
constexpr ox::Error field(CRStringView name, const UnionView<T, force> val) noexcept {
constexpr ox::Error field(StringViewCR name, const UnionView<T, force> val) noexcept {
return field(name, val.get());
}
template<typename T>
constexpr ox::Error field(CRStringView, const T *val) noexcept {
constexpr ox::Error field(StringViewCR, const T *val) noexcept {
if constexpr(ox::is_pointer_v<T> || ox::is_integer_v<T>) {
biggestAlignment = ox::max(biggestAlignment, PlatSpec::alignOf(*val));
} else {
@ -61,7 +61,7 @@ struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>, OpT
}
template<typename T>
constexpr ox::Error field(CRStringView, const T *val, std::size_t cnt) noexcept {
constexpr ox::Error field(StringViewCR, const T *val, std::size_t cnt) noexcept {
for (std::size_t i = 0; i < cnt; ++i) {
oxReturnError(field(nullptr, &val[i]));
}

View File

@ -94,19 +94,19 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>, OpType::Reflect> {
}
template<typename U, bool force>
constexpr ox::Error field(CRStringView, ox::UnionView<U, force> val) noexcept;
constexpr ox::Error field(StringViewCR, ox::UnionView<U, force> val) noexcept;
template<typename T>
constexpr ox::Error field(CRStringView, const T *val) noexcept;
constexpr ox::Error field(StringViewCR, const T *val) noexcept;
template<std::size_t SmallStringSize>
constexpr ox::Error field(CRStringView, const ox::BasicString<SmallStringSize> *val) noexcept;
constexpr ox::Error field(StringViewCR, const ox::BasicString<SmallStringSize> *val) noexcept;
template<typename T, std::size_t sz>
constexpr ox::Error field(CRStringView, const ox::Array<T, sz> *valArray) noexcept;
constexpr ox::Error field(StringViewCR, const ox::Array<T, sz> *valArray) noexcept;
template<typename T>
constexpr ox::Error field(CRStringView, const T **val, std::size_t cnt) noexcept;
constexpr ox::Error field(StringViewCR, const T **val, std::size_t cnt) noexcept;
constexpr ox::Result<std::size_t> startAlloc(size_t sz, size_t align) noexcept;
@ -125,14 +125,14 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>, OpType::Reflect> {
constexpr ox::Error pad(const T*) noexcept;
private:
constexpr ox::Error fieldVector(CRStringView name, const ox::ModelValueVector *val) noexcept;
constexpr ox::Error fieldVector(StringViewCR name, const ox::ModelValueVector *val) noexcept;
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr ox::Error fieldVector(CRStringView, const ox::Vector<T, SmallVectorSize, Allocator> *val) noexcept;
constexpr ox::Error fieldVector(StringViewCR, const ox::Vector<T, SmallVectorSize, Allocator> *val) noexcept;
constexpr ox::Error fieldVector(CRStringView, const auto *val, ox::VectorMemMap<PlatSpec> vecVal) noexcept;
constexpr ox::Error fieldVector(StringViewCR, const auto *val, ox::VectorMemMap<PlatSpec> vecVal) noexcept;
constexpr ox::Error fieldArray(CRStringView name, ox::ModelValueArray const*val) noexcept;
constexpr ox::Error fieldArray(StringViewCR name, ox::ModelValueArray const*val) noexcept;
constexpr bool unionCheckAndIt() noexcept;
@ -158,7 +158,7 @@ Preloader<PlatSpec>::make(ox::ios_base::seekdir anchor, std::size_t sz) noexcept
template<typename PlatSpec>
template<typename U, bool force>
constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const ox::UnionView<U, force> val) noexcept {
constexpr ox::Error Preloader<PlatSpec>::field(StringViewCR, const ox::UnionView<U, force> val) noexcept {
if (!unionCheckAndIt()) {
return {};
}
@ -171,7 +171,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const ox::UnionView
template<typename PlatSpec>
template<typename T>
constexpr ox::Error Preloader<PlatSpec>::field(CRStringView name, const T *val) noexcept {
constexpr ox::Error Preloader<PlatSpec>::field(StringViewCR name, const T *val) noexcept {
if (!unionCheckAndIt()) {
return {};
}
@ -200,7 +200,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView name, const T *val)
template<typename PlatSpec>
template<std::size_t SmallStringSize>
constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const ox::BasicString<SmallStringSize> *val) noexcept {
constexpr ox::Error Preloader<PlatSpec>::field(StringViewCR, const ox::BasicString<SmallStringSize> *val) noexcept {
if (!unionCheckAndIt()) {
return {};
}
@ -230,7 +230,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const ox::BasicStri
template<typename PlatSpec>
template<typename T, std::size_t sz>
constexpr ox::Error Preloader<PlatSpec>::field(CRStringView name, const ox::Array<T, sz> *val) noexcept {
constexpr ox::Error Preloader<PlatSpec>::field(StringViewCR name, const ox::Array<T, sz> *val) noexcept {
if (!unionCheckAndIt()) {
return {};
}
@ -248,7 +248,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView name, const ox::Arra
template<typename PlatSpec>
template<typename T>
constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const T **val, std::size_t cnt) noexcept {
constexpr ox::Error Preloader<PlatSpec>::field(StringViewCR, const T **val, std::size_t cnt) noexcept {
if (!unionCheckAndIt()) {
return {};
}
@ -327,7 +327,7 @@ constexpr ox::Error Preloader<PlatSpec>::pad(const T *v) noexcept {
template<typename PlatSpec>
constexpr ox::Error Preloader<PlatSpec>::fieldVector(
CRStringView name, const ox::ModelValueVector *val) noexcept {
StringViewCR name, const ox::ModelValueVector *val) noexcept {
// serialize the Vector
ox::VectorMemMap<PlatSpec> vecVal{
.size = PlatSpec::correctEndianness(static_cast<typename PlatSpec::size_t>(val->size())),
@ -339,7 +339,7 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(
template<typename PlatSpec>
template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr ox::Error Preloader<PlatSpec>::fieldVector(
CRStringView name, const ox::Vector<T, SmallVectorSize, Allocator> *val) noexcept {
StringViewCR name, const ox::Vector<T, SmallVectorSize, Allocator> *val) noexcept {
// serialize the Vector
ox::VectorMemMap<PlatSpec> vecVal{
.smallVecSize = SmallVectorSize * sizeOf<PlatSpec>(static_cast<T*>(nullptr)),
@ -353,7 +353,7 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(
template<typename PlatSpec>
constexpr ox::Error Preloader<PlatSpec>::fieldVector(
CRStringView, const auto *val, ox::VectorMemMap<PlatSpec> vecVal) noexcept {
StringViewCR, const auto *val, ox::VectorMemMap<PlatSpec> vecVal) noexcept {
oxReturnError(pad(&vecVal));
const auto vecValPt = m_writer.tellp();
// serialize the Vector elements
@ -383,7 +383,7 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(
}
template<typename PlatSpec>
constexpr ox::Error Preloader<PlatSpec>::fieldArray(CRStringView, ox::ModelValueArray const*val) noexcept {
constexpr ox::Error Preloader<PlatSpec>::fieldArray(StringViewCR, ox::ModelValueArray const*val) noexcept {
oxReturnError(pad(&(*val)[0]));
for (auto const&v : *val) {
oxReturnError(this->interface()->field({}, &v));

View File

@ -41,7 +41,7 @@ class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>, OpTy
}
template<typename T, bool force>
constexpr ox::Error field(CRStringView, const UnionView<T, force> val) noexcept {
constexpr ox::Error field(StringViewCR, const UnionView<T, force> val) noexcept {
UnionSizeCatcher<PlatSpec> sc;
oxReturnError(model(sc.interface(), val.get()));
m_size += sc.size();
@ -49,10 +49,10 @@ class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>, OpTy
}
template<typename T>
constexpr ox::Error field(CRStringView, const T *val) noexcept;
constexpr ox::Error field(StringViewCR, const T *val) noexcept;
template<typename T>
constexpr ox::Error field(CRStringView, const T **val, std::size_t cnt) noexcept;
constexpr ox::Error field(StringViewCR, const T **val, std::size_t cnt) noexcept;
[[nodiscard]]
constexpr auto size() const noexcept {
@ -61,24 +61,24 @@ class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>, OpTy
private:
template<typename T, std::size_t SmallVecSize>
constexpr ox::Error fieldStr(CRStringView, const ox::BasicString<SmallVecSize> *val) noexcept;
constexpr ox::Error fieldStr(StringViewCR, const ox::BasicString<SmallVecSize> *val) noexcept;
template<typename T, std::size_t SmallVecSize>
constexpr ox::Error fieldVector(CRStringView, const ox::Vector<T, SmallVecSize> *val) noexcept;
constexpr ox::Error fieldVector(StringViewCR, const ox::Vector<T, SmallVecSize> *val) noexcept;
constexpr void setSize(std::size_t sz) noexcept;
};
template<typename PlatSpec>
template<typename T>
constexpr ox::Error UnionSizeCatcher<PlatSpec>::field(CRStringView, const T *val) noexcept {
constexpr ox::Error UnionSizeCatcher<PlatSpec>::field(StringViewCR, const T *val) noexcept {
setSize(sizeOf<PlatSpec>(val));
return {};
}
template<typename PlatSpec>
template<typename T>
constexpr ox::Error UnionSizeCatcher<PlatSpec>::field(CRStringView, const T **val, std::size_t cnt) noexcept {
constexpr ox::Error UnionSizeCatcher<PlatSpec>::field(StringViewCR, const T **val, std::size_t cnt) noexcept {
for (std::size_t i = 0; i < cnt; ++i) {
oxReturnError(field("", &val[i]));
}
@ -87,7 +87,7 @@ constexpr ox::Error UnionSizeCatcher<PlatSpec>::field(CRStringView, const T **va
template<typename PlatSpec>
template<typename T, std::size_t SmallStrSize>
constexpr ox::Error UnionSizeCatcher<PlatSpec>::fieldStr(CRStringView, const ox::BasicString<SmallStrSize>*) noexcept {
constexpr ox::Error UnionSizeCatcher<PlatSpec>::fieldStr(StringViewCR, const ox::BasicString<SmallStrSize>*) noexcept {
ox::VectorMemMap<PlatSpec> v;
setSize(sizeOf<PlatSpec>(v));
return {};
@ -95,7 +95,7 @@ constexpr ox::Error UnionSizeCatcher<PlatSpec>::fieldStr(CRStringView, const ox:
template<typename PlatSpec>
template<typename T, std::size_t SmallVecSize>
constexpr ox::Error UnionSizeCatcher<PlatSpec>::fieldVector(CRStringView, const ox::Vector<T, SmallVecSize>*) noexcept {
constexpr ox::Error UnionSizeCatcher<PlatSpec>::fieldVector(StringViewCR, const ox::Vector<T, SmallVecSize>*) noexcept {
ox::VectorMemMap<PlatSpec> v;
setSize(sizeOf<PlatSpec>(v));
return {};

View File

@ -22,9 +22,9 @@
namespace ox {
void panic(CRStringView file, int line, CRStringView panicMsg, const Error &err = OxError(0)) noexcept;
void panic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = OxError(0)) noexcept;
constexpr void constexprPanic(CRStringView file, int line, CRStringView panicMsg, const Error &err = OxError(0)) noexcept {
constexpr void constexprPanic(StringViewCR file, int line, StringViewCR panicMsg, const Error &err = OxError(0)) noexcept {
if (!std::is_constant_evaluated()) {
panic(file, line, panicMsg, err);
} else {
@ -32,7 +32,7 @@ constexpr void constexprPanic(CRStringView file, int line, CRStringView panicMsg
}
}
constexpr void assertFunc(CRStringView file, int line, bool pass, [[maybe_unused]]CRStringView assertTxt, [[maybe_unused]]CRStringView msg) noexcept {
constexpr void assertFunc(StringViewCR file, int line, bool pass, [[maybe_unused]]StringViewCR assertTxt, [[maybe_unused]]StringViewCR msg) noexcept {
if (!pass) {
if (!std::is_constant_evaluated()) {
#ifdef OX_USE_STDLIB
@ -51,7 +51,7 @@ constexpr void assertFunc(CRStringView file, int line, bool pass, [[maybe_unused
}
}
constexpr void assertFunc(CRStringView file, int line, const Error &err, CRStringView, CRStringView assertMsg) noexcept {
constexpr void assertFunc(StringViewCR file, int line, const Error &err, StringViewCR, StringViewCR assertMsg) noexcept {
if (err) {
if (!std::is_constant_evaluated()) {
#if defined(OX_USE_STDLIB)
@ -76,7 +76,7 @@ constexpr void assertFunc(CRStringView file, int line, const Error &err, CRStrin
}
}
constexpr void expect(CRStringView file, int line, const auto &actual, const auto &expected) noexcept {
constexpr void expect(StringViewCR file, int line, const auto &actual, const auto &expected) noexcept {
if (actual != expected) {
if (!std::is_constant_evaluated()) {
#if defined(OX_USE_STDLIB)

View File

@ -35,7 +35,7 @@ class IString {
constexpr IString(const char *str) noexcept;
constexpr IString &operator=(CRStringView str) noexcept;
constexpr IString &operator=(StringViewCR str) noexcept;
constexpr IString &operator=(const char *str) noexcept;
@ -119,7 +119,7 @@ constexpr IString<size> &IString<size>::operator=(Integer_c auto i) noexcept {
}
template<std::size_t size>
constexpr IString<size> &IString<size>::operator=(ox::CRStringView str) noexcept {
constexpr IString<size> &IString<size>::operator=(ox::StringViewCR str) noexcept {
std::size_t strLen = str.len();
if (cap() < strLen) {
strLen = cap();

View File

@ -46,7 +46,7 @@ class BasicString {
constexpr explicit BasicString(StringLiteral const&str) noexcept;
constexpr explicit BasicString(CRStringView str) noexcept;
constexpr explicit BasicString(StringViewCR str) noexcept;
constexpr explicit BasicString(BasicString const&) noexcept;
@ -126,7 +126,7 @@ class BasicString {
constexpr BasicString &operator=(BasicString &&src) noexcept;
constexpr BasicString &operator=(CRStringView src) noexcept;
constexpr BasicString &operator=(StringViewCR src) noexcept;
constexpr BasicString &operator+=(const char *str) noexcept;
@ -148,7 +148,7 @@ class BasicString {
constexpr BasicString operator+(Integer_c auto i) const noexcept;
constexpr BasicString operator+(CRStringView src) const noexcept;
constexpr BasicString operator+(StringViewCR src) const noexcept;
constexpr BasicString operator+(BasicString const&src) const noexcept;
@ -243,7 +243,7 @@ class BasicString {
constexpr std::size_t bytes() const noexcept;
private:
constexpr void set(CRStringView str) noexcept;
constexpr void set(StringViewCR str) noexcept;
constexpr void set(const char8_t *str) noexcept;
};
@ -278,7 +278,7 @@ constexpr BasicString<SmallStringSize_v>::BasicString(StringLiteral const&str) n
}
template<std::size_t SmallStringSize_v>
constexpr BasicString<SmallStringSize_v>::BasicString(CRStringView str) noexcept {
constexpr BasicString<SmallStringSize_v>::BasicString(StringViewCR str) noexcept {
set(str);
}
@ -343,7 +343,7 @@ constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operat
}
template<std::size_t SmallStringSize_v>
constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operator=(CRStringView src) noexcept {
constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operator=(StringViewCR src) noexcept {
set(src);
return *this;
}
@ -416,7 +416,7 @@ constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operato
}
template<std::size_t SmallStringSize_v>
constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operator+(CRStringView src) const noexcept {
constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operator+(StringViewCR src) const noexcept {
const std::size_t strLen = src.len();
const auto currentLen = len();
BasicString<SmallStringSize_v> cpy(currentLen + strLen);
@ -521,7 +521,7 @@ constexpr std::size_t BasicString<SmallStringSize_v>::len() const noexcept {
}
template<std::size_t SmallStringSize_v>
constexpr void BasicString<SmallStringSize_v>::set(CRStringView str) noexcept {
constexpr void BasicString<SmallStringSize_v>::set(StringViewCR str) noexcept {
std::size_t const strBytes = str.bytes();
m_buff.resize(strBytes + 1);
copy_n(str.data(), strBytes, m_buff.data());
@ -539,11 +539,11 @@ constexpr void BasicString<SmallStringSize_v>::set(const char8_t *str) noexcept
extern template class BasicString<8>;
using String = BasicString<8>;
using CRString = String const&;
using StringCR = String const&;
[[nodiscard]]
constexpr ox::String toString(ox::CRStringView sv) noexcept {
constexpr ox::String toString(ox::StringViewCR sv) noexcept {
return ox::String(sv);
}

View File

@ -58,16 +58,16 @@ class StringView: public detail::BaseStringView {
};
using CRStringView = const StringView&;
using StringViewCR = const StringView&;
constexpr auto operator==(CRStringView s1, CRStringView s2) noexcept {
constexpr auto operator==(StringViewCR s1, StringViewCR s2) noexcept {
if (s2.len() != s1.len()) {
return false;
}
return ox::strncmp(s1.data(), s2.data(), s1.len()) == 0;
}
constexpr auto operator<=>(CRStringView s1, CRStringView s2) noexcept {
constexpr auto operator<=>(StringViewCR s1, StringViewCR s2) noexcept {
const auto maxLen = ox::min(s1.len(), s2.len());
const auto a = &s1.front();
const auto b = &s2.front();
@ -87,18 +87,18 @@ constexpr auto operator<=>(CRStringView s1, CRStringView s2) noexcept {
}
}
constexpr auto write(Writer_c auto &writer, ox::CRStringView sv) noexcept {
constexpr auto write(Writer_c auto &writer, ox::StringViewCR sv) noexcept {
return writer.write(sv.data(), sv.bytes());
}
#ifdef OX_USE_STDLIB
constexpr auto toStdStringView(CRStringView sv) noexcept {
constexpr auto toStdStringView(StringViewCR sv) noexcept {
return std::string_view(sv.data(), sv.bytes());
}
#endif
constexpr ox::Result<int> atoi(ox::CRStringView str) noexcept {
constexpr ox::Result<int> atoi(ox::StringViewCR str) noexcept {
int total = 0;
int multiplier = 1;
for (auto i = static_cast<int64_t>(str.len()) - 1; i != -1; --i) {

View File

@ -34,19 +34,19 @@ constexpr ox::StringView substr(ox::StringView const&str, std::size_t start, std
}
[[nodiscard]]
constexpr bool beginsWith(CRStringView base, CRStringView beginning) noexcept {
constexpr bool beginsWith(StringViewCR base, StringViewCR beginning) noexcept {
const auto beginningLen = ox::min(beginning.len(), base.len());
return base.len() >= beginning.len() && ox::strncmp(base.data(), beginning, beginningLen) == 0;
}
[[nodiscard]]
constexpr bool endsWith(CRStringView base, CRStringView ending) noexcept {
constexpr bool endsWith(StringViewCR base, StringViewCR ending) noexcept {
const auto endingLen = ending.len();
return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0;
}
[[nodiscard]]
constexpr std::size_t find(CRStringView str, char search) noexcept {
constexpr std::size_t find(StringViewCR str, char search) noexcept {
std::size_t i = 0;
for (; i < str.len(); ++i) {
if (str[i] == search) {
@ -57,7 +57,7 @@ constexpr std::size_t find(CRStringView str, char search) noexcept {
}
[[nodiscard]]
constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
constexpr std::size_t find(StringViewCR str, StringViewCR search) noexcept {
std::size_t i = 0;
for (; i < str.len(); ++i) {
if (beginsWith(substr(str, i), search)) {
@ -69,9 +69,9 @@ constexpr std::size_t find(CRStringView str, CRStringView search) noexcept {
template<std::size_t smallSz = 0>
[[nodiscard]]
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del) noexcept {
constexpr ox::Vector<ox::StringView, smallSz> split(StringViewCR str, char del) noexcept {
ox::Vector<ox::StringView, smallSz> out;
constexpr auto nextSeg = [](CRStringView current, char del) {
constexpr auto nextSeg = [](StringViewCR current, char del) {
return substr(current, find(current, del) + 1);
};
for (auto current = str; current.len(); current = nextSeg(current, del)) {
@ -86,9 +86,9 @@ constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, char del)
template<std::size_t smallSz = 0>
[[nodiscard]]
constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringView del) noexcept {
constexpr ox::Vector<ox::StringView, smallSz> split(StringViewCR str, StringViewCR del) noexcept {
ox::Vector<ox::StringView, smallSz> out;
constexpr auto nextSeg = [](CRStringView current, CRStringView del) {
constexpr auto nextSeg = [](StringViewCR current, StringViewCR del) {
return substr(current, find(current, del) + del.len());
};
for (auto current = str; current.len(); current = nextSeg(current, del)) {
@ -102,7 +102,7 @@ constexpr ox::Vector<ox::StringView, smallSz> split(CRStringView str, CRStringVi
}
[[nodiscard]]
constexpr ox::Result<std::size_t> lastIndexOf(ox::CRStringView str, int character) noexcept {
constexpr ox::Result<std::size_t> lastIndexOf(ox::StringViewCR str, int character) noexcept {
ox::Result<std::size_t> retval = OxError(1, "Character not found");
for (auto i = static_cast<int>(str.bytes() - 1); i >= 0; --i) {
if (str[static_cast<std::size_t>(i)] == character) {

View File

@ -24,10 +24,10 @@ static const auto OxPrintTrace = std::getenv("OXTRACE") != nullptr;
#define REG_MGBA_DEBUG_FLAGS *reinterpret_cast<volatile uint16_t*>(0x4FFF700)
#define REG_MGBA_DEBUG_STRING (reinterpret_cast<char*>(0x4FFF600))
inline void nullLog(ox::CRStringView) {}
inline void (*infoLog)(ox::CRStringView) = nullLog;
inline void (*debugLog)(ox::CRStringView) = nullLog;
inline void (*errorLog)(ox::CRStringView) = nullLog;
inline void nullLog(ox::StringViewCR) {}
inline void (*infoLog)(ox::StringViewCR) = nullLog;
inline void (*debugLog)(ox::StringViewCR) = nullLog;
inline void (*errorLog)(ox::StringViewCR) = nullLog;
namespace mgba {
@ -40,7 +40,7 @@ enum LogChan {
};
template<LogChan chan>
static void log(ox::CRStringView str) {
static void log(ox::StringViewCR str) {
const auto sz = ox::min<std::size_t>(0x100, str.bytes());
ox::strncpy(REG_MGBA_DEBUG_STRING, str.data(), sz);
REG_MGBA_DEBUG_FLAGS = chan | 0x100;

View File

@ -31,7 +31,7 @@ constexpr auto isHexChar(char c) noexcept {
|| (c >= 'A' && c <= 'F');
}
constexpr ox::Result<uint8_t> fromHex(ox::CRStringView v) noexcept {
constexpr ox::Result<uint8_t> fromHex(ox::StringViewCR v) noexcept {
constexpr auto valMap = [] {
ox::Array<uint8_t, 128> out;
out['A'] = out['a'] = 10;
@ -125,7 +125,7 @@ class UUID {
}
}
static constexpr ox::Result<ox::UUID> fromString(ox::CRStringView s) noexcept {
static constexpr ox::Result<ox::UUID> fromString(ox::StringViewCR s) noexcept {
if (s.len() < 36) {
return OxError(1, "Insufficient data to contain a complete UUID");
}

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;