[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
#include <ox/model/def.hpp>
#include <ox/std/error.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;
}
oxModelBegin(Bounds)
oxModelField(x)
oxModelField(y)
oxModelField(width)
oxModelField(height)
oxModelEnd()
template<typename T>
constexpr Error model(T *io, ox::CommonPtrWith<Bounds> auto *obj) noexcept {
io->template setTypeInfo<Bounds>();
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 {};
}
}

View File

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

View File

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