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

◆ from_json()

template<typename T >
static void MayaFlux::IO::Serializer< T >::from_json ( const nlohmann::json &  j,
T out 
)
inlinestatic

Definition at line 40 of file GlmSerializer.hpp.

41 {
42 constexpr auto n = glm_component_count<T>();
43 if (!j.is_array()) {
44 throw nlohmann::json::type_error::create(302, "expected array for glm type", &j);
45 }
46
47 if (j.size() != n) {
48 throw nlohmann::json::other_error::create(501,
49 "glm component count mismatch: expected "
50 + std::to_string(n) + ", got " + std::to_string(j.size()),
51 &j);
52 }
53
54 using Comp = glm_component_type<T>;
55 Comp* ptr = &out[0];
56 for (size_t i = 0; i < n; ++i)
57 ptr[i] = j[i].get<Comp>();
58 }
const uint8_t * ptr

References ptr.