MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
BoundsText.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace MayaFlux::Reflect {
7
8/**
9 * @brief A Kinesis::AABB2D as four finite numbers in the struct's own member order.
10 *
11 * Reads min.x min.y max.x max.y, so the text is the aggregate
12 * AABB2D { .min = { x0, y0 }, .max = { x1, y1 } } written flat. An origin and size
13 * is a different spelling and has its own named constructor, AABB2D::from_origin_size.
14 */
15template <>
16struct TextCodec<Kinesis::AABB2D> {
17 static constexpr size_t extent = 4;
18
19 static bool decode(std::string_view source, Kinesis::AABB2D& value, TextError& error)
20 {
21 const auto decoded = parse_tuple<float, 4>(source, error);
22 if (!decoded)
23 return false;
24 value.min = { (*decoded)[0], (*decoded)[1] };
25 value.max = { (*decoded)[2], (*decoded)[3] };
26 return true;
27 }
28};
29
30}
std::optional< std::array< T, N > > parse_tuple(std::string_view source, TextError &error)
Parse exactly N whitespace separated finite numbers.
Definition TextCodec.hpp:55
Axis-aligned bounding rectangle in a 2D coordinate space.
Definition Bounds.hpp:63
static bool decode(std::string_view source, Kinesis::AABB2D &value, TextError &error)
Conversion of authored text to one value type.
Definition TextCodec.hpp:81