[ox/model] Add macros to simplify model definition

This commit is contained in:
Gary Talent 2022-01-26 01:36:29 -06:00
parent f687134943
commit fcc4cf3308
3 changed files with 16 additions and 0 deletions

View File

@ -20,6 +20,7 @@ endif()
install(
FILES
def.hpp
descread.hpp
desctypes.hpp
descwrite.hpp

14
deps/ox/src/ox/model/def.hpp vendored Normal file
View File

@ -0,0 +1,14 @@
/*
* Copyright 2015 - 2022 gary@drinkingtea.net
*
* 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/.
*/
#pragma once
#define oxModelBegin(modelName) template<typename T> constexpr ox::Error model(T *io, modelName *o) noexcept { io->template setTypeInfo<modelName>();
#define oxModelEnd() return OxError(0); }
#define oxModelField(fieldName) oxReturnError(io->field(#fieldName, &o->fieldName));
#define oxModelFriend(modelName) template<typename T> friend ox::Error model(T*, modelName*)

View File

@ -8,6 +8,7 @@
#pragma once
#include "def.hpp"
#include "descread.hpp"
#include "desctypes.hpp"
#include "descwrite.hpp"