MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ decode_glm()

template<typename T >
requires GlmSerializable<T>
static void MayaFlux::IO::JSONSerializer::decode_glm ( const nlohmann::json &  j,
T out 
)
inlinestaticprivate

Definition at line 323 of file JSONSerializer.hpp.

324 {
325 if (!j.is_array()) {
326 auto e = nlohmann::json::type_error::create(302, "expected array for glm type", &j);
327 error<std::runtime_error>(
330 std::source_location::current(),
331 "JSON type error: {}", e.what());
332 }
333 constexpr auto n = glm_component_count<T>();
334 if (j.size() != n) {
335 auto e = nlohmann::json::other_error::create(
336 501, "glm component count mismatch", &j);
337 error<std::runtime_error>(
340 std::source_location::current(),
341 "JSON error: expected {} components for type {}, got {}: {}",
342 n, typeid(T).name(), j.size(), e.what());
343 }
344 using Comp = glm_component_type<T>;
345 Comp* ptr = &out[0];
346 for (size_t i = 0; i < n; ++i) {
347 ptr[i] = j[i].get<Comp>();
348 }
349 }
const uint8_t * ptr
@ Runtime
General runtime operations (default fallback)
@ IO
Networking, file handling, streaming.

References ptr, and MayaFlux::IO::T.