[ox/std] Cleanup geo types to not depend on ox/model

This commit is contained in:
Gary Talent 2023-06-01 23:19:51 -05:00
parent 437b33cdb5
commit 07284ac595
4 changed files with 32 additions and 19 deletions

View File

@ -8,7 +8,6 @@
#pragma once #pragma once
#include <ox/model/def.hpp>
#include <ox/std/error.hpp> #include <ox/std/error.hpp>
#include <ox/std/new.hpp> #include <ox/std/new.hpp>
@ -125,11 +124,15 @@ constexpr void Bounds::set(const Point &pt1, const Point &pt2) noexcept {
this->height = y2 - y1; this->height = y2 - y1;
} }
oxModelBegin(Bounds) template<typename T>
oxModelField(x) constexpr Error model(T *io, ox::CommonPtrWith<Bounds> auto *obj) noexcept {
oxModelField(y) io->template setTypeInfo<Bounds>();
oxModelField(width) oxReturnError(io->field("x", &obj->x));
oxModelField(height) oxReturnError(io->field("y", &obj->y));
oxModelEnd() oxReturnError(io->field("width", &obj->width));
oxReturnError(io->field("height", &obj->height));
return {};
}
} }

View File

@ -184,9 +184,12 @@ constexpr bool Point::operator!=(const Point &p) const noexcept {
return x != p.x || y != p.y; return x != p.x || y != p.y;
} }
oxModelBegin(Point) template<typename T>
oxModelField(x) constexpr Error model(T *io, ox::CommonPtrWith<Point> auto *obj) noexcept {
oxModelField(y) io->template setTypeInfo<Point>();
oxModelEnd() oxReturnError(io->field("x", &obj->x));
oxReturnError(io->field("y", &obj->y));
return {};
}
} }

View File

@ -9,6 +9,7 @@
#pragma once #pragma once
#include <ox/std/error.hpp> #include <ox/std/error.hpp>
#include <ox/std/concepts.hpp>
namespace ox { namespace ox {
@ -184,9 +185,12 @@ constexpr bool Size::operator!=(const Size &p) const noexcept {
} }
oxModelBegin(Size) template<typename T>
oxModelField(width) constexpr Error model(T *io, ox::CommonPtrWith<Size> auto *obj) noexcept {
oxModelField(height) io->template setTypeInfo<Size>();
oxModelEnd() oxReturnError(io->field("width", &obj->width));
oxReturnError(io->field("height", &obj->height));
return {};
}
} }

View File

@ -260,9 +260,12 @@ struct Vec {
using Vec2 = Vec<float>; using Vec2 = Vec<float>;
oxModelBegin(Vec2) template<typename T>
oxModelField(x) constexpr Error model(T *io, ox::CommonPtrWith<Vec2> auto *obj) noexcept {
oxModelField(y) io->template setTypeInfo<Vec2>();
oxModelEnd() oxReturnError(io->field("x", &obj->x));
oxReturnError(io->field("y", &obj->y));
return {};
}
} }