diff --git a/deps/ox/src/ox/fs/filesystem/filelocation.cpp b/deps/ox/src/ox/fs/filesystem/filelocation.cpp index 43799abf..f5793edf 100644 --- a/deps/ox/src/ox/fs/filesystem/filelocation.cpp +++ b/deps/ox/src/ox/fs/filesystem/filelocation.cpp @@ -10,43 +10,43 @@ namespace ox { -FileAddress::FileAddress() { +FileAddress::FileAddress() noexcept { m_data.inode = 0; m_type = FileAddressType::Inode; } -FileAddress::FileAddress(const FileAddress &other) { +FileAddress::FileAddress(const FileAddress &other) noexcept { operator=(other); } -FileAddress::FileAddress(std::nullptr_t) { +FileAddress::FileAddress(std::nullptr_t) noexcept { } -FileAddress::FileAddress(uint64_t inode) { +FileAddress::FileAddress(uint64_t inode) noexcept { m_data.inode = inode; m_type = FileAddressType::Inode; } -FileAddress::FileAddress(char *path) { +FileAddress::FileAddress(char *path) noexcept { auto pathSize = ox_strlen(path) + 1; m_data.path = new char[pathSize]; memcpy(m_data.path, path, pathSize); m_type = FileAddressType::Path; } -FileAddress::FileAddress(const char *path) { +FileAddress::FileAddress(const char *path) noexcept { m_data.constPath = path; m_type = FileAddressType::ConstPath; } -FileAddress::~FileAddress() { +FileAddress::~FileAddress() noexcept { if (m_type == FileAddressType::Path) { delete[] m_data.path; m_data.path = nullptr; } } -const FileAddress &FileAddress::operator=(const FileAddress &other) { +const FileAddress &FileAddress::operator=(const FileAddress &other) noexcept { m_type = other.m_type; switch (m_type) { case FileAddressType::Path: diff --git a/deps/ox/src/ox/fs/filesystem/filelocation.hpp b/deps/ox/src/ox/fs/filesystem/filelocation.hpp index 8f507a5e..9920ebaa 100644 --- a/deps/ox/src/ox/fs/filesystem/filelocation.hpp +++ b/deps/ox/src/ox/fs/filesystem/filelocation.hpp @@ -23,7 +23,7 @@ enum class FileAddressType: int8_t { class FileAddress { template - friend Error model(T*, FileAddress*); + friend constexpr Error model(T*, FileAddress*) noexcept; public: static constexpr auto TypeName = "net.drinkingtea.ox.FileAddress"; @@ -42,21 +42,21 @@ class FileAddress { Data m_data; public: - FileAddress(); + FileAddress() noexcept; - FileAddress(const FileAddress &other); + FileAddress(const FileAddress &other) noexcept; - FileAddress(std::nullptr_t); + FileAddress(std::nullptr_t) noexcept; - FileAddress(uint64_t inode); + FileAddress(uint64_t inode) noexcept; - FileAddress(char *path); + FileAddress(char *path) noexcept; - FileAddress(const char *path); + FileAddress(const char *path) noexcept; - ~FileAddress(); + ~FileAddress() noexcept; - const FileAddress &operator=(const FileAddress &other); + const FileAddress &operator=(const FileAddress &other) noexcept; [[nodiscard]] constexpr FileAddressType type() const noexcept { switch (m_type) { @@ -68,7 +68,7 @@ class FileAddress { } } - Result getInode() const noexcept { + constexpr Result getInode() const noexcept { switch (m_type) { case FileAddressType::Inode: return m_data.inode; @@ -77,7 +77,7 @@ class FileAddress { } } - Result getPath() const noexcept { + constexpr Result getPath() const noexcept { switch (m_type) { case FileAddressType::Path: return m_data.path; @@ -88,14 +88,14 @@ class FileAddress { } } - operator bool() const { + constexpr operator bool() const noexcept { return m_type != FileAddressType::None; } }; template -Error model(T *io, FileAddress::Data *obj) { +constexpr Error model(T *io, FileAddress::Data *obj) noexcept { io->template setTypeInfo(); oxReturnError(io->field("path", SerStr(&obj->path))); oxReturnError(io->field("constPath", SerStr(&obj->path))); @@ -104,7 +104,7 @@ Error model(T *io, FileAddress::Data *obj) { } template -Error model(T *io, FileAddress *fa) { +constexpr Error model(T *io, FileAddress *fa) noexcept { io->template setTypeInfo(); oxReturnError(io->field("type", bit_cast(&fa->m_type))); oxReturnError(io->field("data", UnionView(&fa->m_data, static_cast(fa->m_type))));