From ec711331d12137b933bafb9617b209ceae70e867 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 31 Mar 2021 02:40:52 -0500 Subject: [PATCH] [nostalgia/common] Update models --- src/nostalgia/common/bounds.hpp | 19 ++++++++++++------- src/nostalgia/common/common.hpp | 7 +++---- src/nostalgia/common/point.hpp | 5 ++++- src/nostalgia/common/size.hpp | 5 ++++- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/nostalgia/common/bounds.hpp b/src/nostalgia/common/bounds.hpp index 48de1908..dd641c88 100644 --- a/src/nostalgia/common/bounds.hpp +++ b/src/nostalgia/common/bounds.hpp @@ -5,6 +5,7 @@ * 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 #include "point.hpp" @@ -12,7 +13,11 @@ namespace nostalgia::common { class Bounds { + public: + static constexpr auto TypeName = "net.drinkingtea.nostalgia.common.Bounds"; + static constexpr auto Fields = 4; + static constexpr auto TypeVersion = 1; int x = 0; int y = 0; int width = 0; @@ -33,17 +38,17 @@ class Bounds { [[nodiscard]] Point pt1(); [[nodiscard]] Point pt2(); + }; template ox::Error model(T *io, Bounds *obj) { - auto err = OxError(0); - io->setTypeInfo("nostalgia::common::Bounds", 4); - err |= io->field("x", &obj->x); - err |= io->field("y", &obj->y); - err |= io->field("width", &obj->width); - err |= io->field("height", &obj->height); - return err; + io->template setTypeInfo(); + oxReturnError(io->field("x", &obj->x)); + oxReturnError(io->field("y", &obj->y)); + oxReturnError(io->field("width", &obj->width)); + oxReturnError(io->field("height", &obj->height)); + return OxError(0); } } diff --git a/src/nostalgia/common/common.hpp b/src/nostalgia/common/common.hpp index 35ddb5fa..76143090 100644 --- a/src/nostalgia/common/common.hpp +++ b/src/nostalgia/common/common.hpp @@ -5,10 +5,9 @@ * 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/. */ -#ifndef NOSTALGIA_COMMON_COMMON_HPP -#define NOSTALGIA_COMMON_COMMON_HPP + +#pragma once #include "bounds.hpp" #include "point.hpp" - -#endif +#include "size.hpp" diff --git a/src/nostalgia/common/point.hpp b/src/nostalgia/common/point.hpp index 8609ebf0..df7ee6e8 100644 --- a/src/nostalgia/common/point.hpp +++ b/src/nostalgia/common/point.hpp @@ -14,6 +14,9 @@ namespace nostalgia::common { class Point { public: + static constexpr auto TypeName = "net.drinkingtea.nostalgia.common.Point"; + static constexpr auto Fields = 2; + static constexpr auto TypeVersion = 1; int x = 0; int y = 0; @@ -183,7 +186,7 @@ constexpr bool Point::operator!=(const Point &p) const { template ox::Error model(T *io, Point *obj) { - io->setTypeInfo("nostalgia::common::Bounds", 2); + io->template setTypeInfo(); oxReturnError(io->field("x", &obj->x)); oxReturnError(io->field("y", &obj->y)); return OxError(0); diff --git a/src/nostalgia/common/size.hpp b/src/nostalgia/common/size.hpp index 09abc675..7ff67475 100644 --- a/src/nostalgia/common/size.hpp +++ b/src/nostalgia/common/size.hpp @@ -14,6 +14,9 @@ namespace nostalgia::common { class Size { public: + static constexpr auto TypeName = "net.drinkingtea.nostalgia.common.Size"; + static constexpr auto Fields = 2; + static constexpr auto TypeVersion = 1; int width = 0; int height = 0; @@ -183,7 +186,7 @@ constexpr bool Size::operator!=(const Size &p) const { template ox::Error model(T *io, Size *obj) { - io->setTypeInfo("nostalgia::common::Bounds", 2); + io->template setTypeInfo(); oxReturnError(io->field("width", &obj->width)); oxReturnError(io->field("height", &obj->height)); return OxError(0);