[ox] Overhaul serialization/model system and add ModelValue/ModelObject/ModelUnion variant system
This commit is contained in:
19
deps/ox/src/ox/fs/filesystem/filelocation.hpp
vendored
19
deps/ox/src/ox/fs/filesystem/filelocation.hpp
vendored
@@ -3,12 +3,13 @@
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/std/std.hpp>
|
||||
#include <ox/model/def.hpp>
|
||||
#include <ox/model/typenamecatcher.hpp>
|
||||
#include <ox/model/types.hpp>
|
||||
|
||||
@@ -24,7 +25,7 @@ enum class FileAddressType: int8_t {
|
||||
class FileAddress {
|
||||
|
||||
template<typename T>
|
||||
friend constexpr Error model(T*, FileAddress*) noexcept;
|
||||
friend constexpr Error model(T*, CommonPtrWith<FileAddress> auto*) noexcept;
|
||||
|
||||
public:
|
||||
static constexpr auto TypeName = "net.drinkingtea.ox.FileAddress";
|
||||
@@ -129,22 +130,16 @@ constexpr const char *getModelTypeName<FileAddress>() noexcept {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, FileAddress::Data *obj) noexcept {
|
||||
constexpr Error model(T *io, CommonPtrWith<FileAddress::Data> auto *obj) noexcept {
|
||||
io->template setTypeInfo<FileAddress::Data>();
|
||||
if constexpr(ox_strcmp(T::opType(), OpType::Reflect) == 0) {
|
||||
String dummy;
|
||||
oxReturnError(io->field("path", &dummy));
|
||||
oxReturnError(io->field("constPath", &dummy));
|
||||
} else {
|
||||
oxReturnError(io->field("path", SerStr(&obj->path)));
|
||||
oxReturnError(io->field("constPath", SerStr(&obj->path)));
|
||||
}
|
||||
oxReturnError(io->fieldCString("path", &obj->path));
|
||||
oxReturnError(io->fieldCString("constPath", &obj->path));
|
||||
oxReturnError(io->field("inode", &obj->inode));
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr Error model(T *io, FileAddress *fa) noexcept {
|
||||
constexpr Error model(T *io, CommonPtrWith<FileAddress> auto *fa) noexcept {
|
||||
io->template setTypeInfo<FileAddress>();
|
||||
if constexpr(ox_strcmp(T::opType(), OpType::Reflect) == 0) {
|
||||
int8_t type = 0;
|
||||
|
Reference in New Issue
Block a user