[ox] Rename CRStringView to StringViewCR

This commit is contained in:
Gary Talent 2024-09-28 16:09:43 -05:00
parent 829dc0298e
commit cc10631b55
27 changed files with 168 additions and 168 deletions

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); auto [value, err] = m_ints.at(arg);
return !err ? *value : defaultValue; 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); auto [value, err] = m_strings.at(arg);
return !err ? ox::String(*value) : ox::String(defaultValue); 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); auto [value, err] = m_ints.at(arg);
return !err ? *value : defaultValue; 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)); oxRequire(out, m_bools.at(arg));
return *out; 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)); oxRequire(out, m_strings.at(argName));
return *out; 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)); oxRequire(out, m_ints.at(arg));
return *out; return *out;
} }

View File

@ -23,21 +23,21 @@ class ClArgs {
ClArgs(int argc, const char **args) noexcept; ClArgs(int argc, const char **args) noexcept;
[[nodiscard]] [[nodiscard]]
bool getBool(ox::CRStringView arg, bool defaultValue) const noexcept; bool getBool(ox::StringViewCR arg, bool defaultValue) const noexcept;
[[nodiscard]] [[nodiscard]]
String getString(ox::CRStringView argName, ox::StringView defaultValue) const noexcept; String getString(ox::StringViewCR argName, ox::StringView defaultValue) const noexcept;
[[nodiscard]] [[nodiscard]]
int getInt(ox::CRStringView arg, int defaultValue) const noexcept; int getInt(ox::StringViewCR arg, int defaultValue) const noexcept;
[[nodiscard]] [[nodiscard]]
Result<bool> getBool(ox::CRStringView arg) const noexcept; Result<bool> getBool(ox::StringViewCR arg) const noexcept;
[[nodiscard]] [[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: public:
constexpr DirectoryEntry() noexcept = default; 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); oxTracef("ox.fs.DirectoryEntry.init", "inode: {}, name: {}, bufferSize: {}", inode, name, bufferSize);
m_bufferSize = static_cast<InodeId_t>(bufferSize); m_bufferSize = static_cast<InodeId_t>(bufferSize);
auto d = data(); auto d = data();
@ -284,7 +284,7 @@ Error Directory<FileStore, InodeId_t>::ls(F cb) noexcept {
} }
template<typename FileStore, typename InodeId_t> 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); oxTrace("ox.fs.Directory.findEntry", name);
auto buff = m_fs.read(m_inodeId).template to<Buffer>(); auto buff = m_fs.read(m_inodeId).template to<Buffer>();
if (!buff.valid()) { if (!buff.valid()) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,29 +29,29 @@ class PassThroughFS: public FileSystem {
std::filesystem::path m_path; std::filesystem::path m_path;
public: public:
explicit PassThroughFS(CRStringView dirPath); explicit PassThroughFS(StringViewCR dirPath);
~PassThroughFS() noexcept override; ~PassThroughFS() noexcept override;
[[nodiscard]] [[nodiscard]]
String basePath() const noexcept; 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> 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; Error resize(uint64_t size, void *buffer) noexcept override;
Result<FileStat> statInode(uint64_t inode) const 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]] [[nodiscard]]
uint64_t spaceNeeded(uint64_t size) const noexcept override; uint64_t spaceNeeded(uint64_t size) const noexcept override;
@ -69,13 +69,13 @@ class PassThroughFS: public FileSystem {
bool valid() const noexcept override; bool valid() const noexcept override;
protected: 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 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 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; 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> 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; std::error_code ec;
const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec); const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec);
oxReturnError(OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: ls failed")); 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(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(const char *path);
PathIterator(CRStringView path); PathIterator(StringViewCR path);
Error dirPath(char *pathOut, std::size_t pathOutSize); 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{}; sockaddr_in addr{};
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 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; LoggerConn &operator=(const LoggerConn&) noexcept = delete;
ox::Error send(const trace::TraceMsg&) noexcept final; ox::Error send(const trace::TraceMsg&) noexcept final;
ox::Error sendInit(const trace::InitTraceMsg&) 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; ox::Error send(const char *buff, std::size_t len) const noexcept;
private: private:
void msgSend() noexcept; void msgSend() noexcept;

View File

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

View File

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

View File

@ -24,24 +24,24 @@ class FieldCounter {
std::size_t fields = 0; std::size_t fields = 0;
template<typename U = std::nullptr_t> 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 {}; return {};
} }
template<typename U> template<typename U>
constexpr ox::Error field(CRStringView, U) noexcept { constexpr ox::Error field(StringViewCR, U) noexcept {
++fields; ++fields;
return OxError(0); return OxError(0);
} }
template<typename U> template<typename U>
constexpr ox::Error field(CRStringView, U, std::size_t) noexcept { constexpr ox::Error field(StringViewCR, U, std::size_t) noexcept {
++fields; ++fields;
return OxError(0); return OxError(0);
} }
template<typename U, typename Handler> template<typename U, typename Handler>
constexpr Error field(CRStringView, Handler) { constexpr Error field(StringViewCR, Handler) {
++fields; ++fields;
return OxError(0); return OxError(0);
} }

View File

@ -44,7 +44,7 @@ class TypeStore {
return out->get(); 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 TypeParamPack &typeParams) noexcept {
const auto typeId = buildTypeId(typeName, typeVersion, typeParams); const auto typeId = buildTypeId(typeName, typeVersion, typeParams);
auto &out = m_cache[typeId]; auto &out = m_cache[typeId];
@ -105,7 +105,7 @@ class TypeStore {
return OxError(1); 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 ox::TypeParamPack &typeParams) noexcept {
const auto typeId = buildTypeId(name, version, typeParams); const auto typeId = buildTypeId(name, version, typeParams);
return loadDescriptor(typeId); return loadDescriptor(typeId);

View File

@ -46,12 +46,12 @@ struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>, OpT
} }
template<typename T, bool force> 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()); return field(name, val.get());
} }
template<typename T> 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>) { if constexpr(ox::is_pointer_v<T> || ox::is_integer_v<T>) {
biggestAlignment = ox::max(biggestAlignment, PlatSpec::alignOf(*val)); biggestAlignment = ox::max(biggestAlignment, PlatSpec::alignOf(*val));
} else { } else {
@ -61,7 +61,7 @@ struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>, OpT
} }
template<typename T> 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) { for (std::size_t i = 0; i < cnt; ++i) {
oxReturnError(field(nullptr, &val[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> 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> 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> 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> 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> 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; 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; constexpr ox::Error pad(const T*) noexcept;
private: 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> 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; 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 PlatSpec>
template<typename U, bool force> 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()) { if (!unionCheckAndIt()) {
return {}; return {};
} }
@ -171,7 +171,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const ox::UnionView
template<typename PlatSpec> template<typename PlatSpec>
template<typename T> 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()) { if (!unionCheckAndIt()) {
return {}; return {};
} }
@ -200,7 +200,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView name, const T *val)
template<typename PlatSpec> template<typename PlatSpec>
template<std::size_t SmallStringSize> 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()) { if (!unionCheckAndIt()) {
return {}; return {};
} }
@ -230,7 +230,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const ox::BasicStri
template<typename PlatSpec> template<typename PlatSpec>
template<typename T, std::size_t sz> 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()) { if (!unionCheckAndIt()) {
return {}; return {};
} }
@ -248,7 +248,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView name, const ox::Arra
template<typename PlatSpec> template<typename PlatSpec>
template<typename T> 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()) { if (!unionCheckAndIt()) {
return {}; return {};
} }
@ -327,7 +327,7 @@ constexpr ox::Error Preloader<PlatSpec>::pad(const T *v) noexcept {
template<typename PlatSpec> template<typename PlatSpec>
constexpr ox::Error Preloader<PlatSpec>::fieldVector( constexpr ox::Error Preloader<PlatSpec>::fieldVector(
CRStringView name, const ox::ModelValueVector *val) noexcept { StringViewCR name, const ox::ModelValueVector *val) noexcept {
// serialize the Vector // serialize the Vector
ox::VectorMemMap<PlatSpec> vecVal{ ox::VectorMemMap<PlatSpec> vecVal{
.size = PlatSpec::correctEndianness(static_cast<typename PlatSpec::size_t>(val->size())), .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 PlatSpec>
template<typename T, std::size_t SmallVectorSize, typename Allocator> template<typename T, std::size_t SmallVectorSize, typename Allocator>
constexpr ox::Error Preloader<PlatSpec>::fieldVector( 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 // serialize the Vector
ox::VectorMemMap<PlatSpec> vecVal{ ox::VectorMemMap<PlatSpec> vecVal{
.smallVecSize = SmallVectorSize * sizeOf<PlatSpec>(static_cast<T*>(nullptr)), .smallVecSize = SmallVectorSize * sizeOf<PlatSpec>(static_cast<T*>(nullptr)),
@ -353,7 +353,7 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(
template<typename PlatSpec> template<typename PlatSpec>
constexpr ox::Error Preloader<PlatSpec>::fieldVector( 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)); oxReturnError(pad(&vecVal));
const auto vecValPt = m_writer.tellp(); const auto vecValPt = m_writer.tellp();
// serialize the Vector elements // serialize the Vector elements
@ -383,7 +383,7 @@ constexpr ox::Error Preloader<PlatSpec>::fieldVector(
} }
template<typename PlatSpec> 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])); oxReturnError(pad(&(*val)[0]));
for (auto const&v : *val) { for (auto const&v : *val) {
oxReturnError(this->interface()->field({}, &v)); oxReturnError(this->interface()->field({}, &v));

View File

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

View File

@ -22,9 +22,9 @@
namespace ox { 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()) { if (!std::is_constant_evaluated()) {
panic(file, line, panicMsg, err); panic(file, line, panicMsg, err);
} else { } 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 (!pass) {
if (!std::is_constant_evaluated()) { if (!std::is_constant_evaluated()) {
#ifdef OX_USE_STDLIB #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 (err) {
if (!std::is_constant_evaluated()) { if (!std::is_constant_evaluated()) {
#if defined(OX_USE_STDLIB) #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 (actual != expected) {
if (!std::is_constant_evaluated()) { if (!std::is_constant_evaluated()) {
#if defined(OX_USE_STDLIB) #if defined(OX_USE_STDLIB)

View File

@ -35,7 +35,7 @@ class IString {
constexpr IString(const char *str) noexcept; 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; 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> 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(); std::size_t strLen = str.len();
if (cap() < strLen) { if (cap() < strLen) {
strLen = cap(); strLen = cap();

View File

@ -46,7 +46,7 @@ class BasicString {
constexpr explicit BasicString(StringLiteral const&str) noexcept; 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; constexpr explicit BasicString(BasicString const&) noexcept;
@ -126,7 +126,7 @@ class BasicString {
constexpr BasicString &operator=(BasicString &&src) noexcept; 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; 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+(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; constexpr BasicString operator+(BasicString const&src) const noexcept;
@ -243,7 +243,7 @@ class BasicString {
constexpr std::size_t bytes() const noexcept; constexpr std::size_t bytes() const noexcept;
private: private:
constexpr void set(CRStringView str) noexcept; constexpr void set(StringViewCR str) noexcept;
constexpr void set(const char8_t *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> template<std::size_t SmallStringSize_v>
constexpr BasicString<SmallStringSize_v>::BasicString(CRStringView str) noexcept { constexpr BasicString<SmallStringSize_v>::BasicString(StringViewCR str) noexcept {
set(str); set(str);
} }
@ -343,7 +343,7 @@ constexpr BasicString<SmallStringSize_v> &BasicString<SmallStringSize_v>::operat
} }
template<std::size_t SmallStringSize_v> 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); set(src);
return *this; return *this;
} }
@ -416,7 +416,7 @@ constexpr BasicString<SmallStringSize_v> BasicString<SmallStringSize_v>::operato
} }
template<std::size_t SmallStringSize_v> 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 std::size_t strLen = src.len();
const auto currentLen = len(); const auto currentLen = len();
BasicString<SmallStringSize_v> cpy(currentLen + strLen); 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> 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(); std::size_t const strBytes = str.bytes();
m_buff.resize(strBytes + 1); m_buff.resize(strBytes + 1);
copy_n(str.data(), strBytes, m_buff.data()); copy_n(str.data(), strBytes, m_buff.data());
@ -543,7 +543,7 @@ using CRString = String const&;
[[nodiscard]] [[nodiscard]]
constexpr ox::String toString(ox::CRStringView sv) noexcept { constexpr ox::String toString(ox::StringViewCR sv) noexcept {
return ox::String(sv); 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()) { if (s2.len() != s1.len()) {
return false; return false;
} }
return ox::strncmp(s1.data(), s2.data(), s1.len()) == 0; 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 maxLen = ox::min(s1.len(), s2.len());
const auto a = &s1.front(); const auto a = &s1.front();
const auto b = &s2.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()); return writer.write(sv.data(), sv.bytes());
} }
#ifdef OX_USE_STDLIB #ifdef OX_USE_STDLIB
constexpr auto toStdStringView(CRStringView sv) noexcept { constexpr auto toStdStringView(StringViewCR sv) noexcept {
return std::string_view(sv.data(), sv.bytes()); return std::string_view(sv.data(), sv.bytes());
} }
#endif #endif
constexpr ox::Result<int> atoi(ox::CRStringView str) noexcept { constexpr ox::Result<int> atoi(ox::StringViewCR str) noexcept {
int total = 0; int total = 0;
int multiplier = 1; int multiplier = 1;
for (auto i = static_cast<int64_t>(str.len()) - 1; i != -1; --i) { 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]] [[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()); const auto beginningLen = ox::min(beginning.len(), base.len());
return base.len() >= beginning.len() && ox::strncmp(base.data(), beginning, beginningLen) == 0; return base.len() >= beginning.len() && ox::strncmp(base.data(), beginning, beginningLen) == 0;
} }
[[nodiscard]] [[nodiscard]]
constexpr bool endsWith(CRStringView base, CRStringView ending) noexcept { constexpr bool endsWith(StringViewCR base, StringViewCR ending) noexcept {
const auto endingLen = ending.len(); const auto endingLen = ending.len();
return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0; return base.len() >= endingLen && ox::strcmp(base.data() + (base.len() - endingLen), ending) == 0;
} }
[[nodiscard]] [[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; std::size_t i = 0;
for (; i < str.len(); ++i) { for (; i < str.len(); ++i) {
if (str[i] == search) { if (str[i] == search) {
@ -57,7 +57,7 @@ constexpr std::size_t find(CRStringView str, char search) noexcept {
} }
[[nodiscard]] [[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; std::size_t i = 0;
for (; i < str.len(); ++i) { for (; i < str.len(); ++i) {
if (beginsWith(substr(str, i), search)) { 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> template<std::size_t smallSz = 0>
[[nodiscard]] [[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; 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); return substr(current, find(current, del) + 1);
}; };
for (auto current = str; current.len(); current = nextSeg(current, del)) { 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> template<std::size_t smallSz = 0>
[[nodiscard]] [[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; 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()); return substr(current, find(current, del) + del.len());
}; };
for (auto current = str; current.len(); current = nextSeg(current, del)) { 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]] [[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"); ox::Result<std::size_t> retval = OxError(1, "Character not found");
for (auto i = static_cast<int>(str.bytes() - 1); i >= 0; --i) { for (auto i = static_cast<int>(str.bytes() - 1); i >= 0; --i) {
if (str[static_cast<std::size_t>(i)] == character) { 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_FLAGS *reinterpret_cast<volatile uint16_t*>(0x4FFF700)
#define REG_MGBA_DEBUG_STRING (reinterpret_cast<char*>(0x4FFF600)) #define REG_MGBA_DEBUG_STRING (reinterpret_cast<char*>(0x4FFF600))
inline void nullLog(ox::CRStringView) {} inline void nullLog(ox::StringViewCR) {}
inline void (*infoLog)(ox::CRStringView) = nullLog; inline void (*infoLog)(ox::StringViewCR) = nullLog;
inline void (*debugLog)(ox::CRStringView) = nullLog; inline void (*debugLog)(ox::StringViewCR) = nullLog;
inline void (*errorLog)(ox::CRStringView) = nullLog; inline void (*errorLog)(ox::StringViewCR) = nullLog;
namespace mgba { namespace mgba {
@ -40,7 +40,7 @@ enum LogChan {
}; };
template<LogChan chan> 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()); const auto sz = ox::min<std::size_t>(0x100, str.bytes());
ox::strncpy(REG_MGBA_DEBUG_STRING, str.data(), sz); ox::strncpy(REG_MGBA_DEBUG_STRING, str.data(), sz);
REG_MGBA_DEBUG_FLAGS = chan | 0x100; REG_MGBA_DEBUG_FLAGS = chan | 0x100;

View File

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