2 #include <State/OSSIASerializationImpl.hpp>
3 #include <State/ValueSerializationImpl.hpp>
5 #include <ossia/detail/typelist.hpp>
12 using domain_t = ossia::vector_domain;
15 s.stream() << domain.min << domain.max << domain.values;
20 s.stream() >> domain.min >> domain.max >> domain.values;
24 template <std::
size_t N>
27 using domain_t = ossia::vecf_domain<N>;
30 s.stream.StartObject();
31 s.obj[s.strings.Min] = domain.min;
32 s.obj[s.strings.Max] = domain.max;
33 s.obj[s.strings.Values] = domain.values;
41 if(
auto it = s.obj.tryGet(s.strings.Min))
45 if(
auto it = s.obj.tryGet(s.strings.Max))
49 if(
auto it = s.obj.tryGet(s.strings.Values))
51 domain.values <<= *it;
56 template <std::
size_t N>
59 using domain_t = ossia::vecf_domain<N>;
62 s.stream() << domain.min << domain.max << domain.values;
67 s.stream() >> domain.min >> domain.max >> domain.values;
74 using domain_t = ossia::domain_base<T>;
77 s.stream.StartObject();
80 s.obj[s.strings.Min] = *domain.min;
82 s.obj[s.strings.Max] = *domain.max;
83 if(!domain.values.empty())
84 s.obj[s.strings.Values] = domain.values;
93 if(
auto it = s.obj.tryGet(s.strings.Min))
97 if(
auto it = s.obj.tryGet(s.strings.Max))
101 if(
auto it = s.obj.tryGet(s.strings.Values))
103 domain.values <<= *it;
111 using domain_t = ossia::domain_base<std::string>;
114 s.stream.StartObject();
115 if(!domain.values.empty())
116 s.obj[s.strings.Values] = domain.values;
117 s.stream.EndObject();
122 if(
auto it_values = s.obj.tryGet(s.strings.Values))
124 domain.values <<= *it_values;
132 using domain_t = ossia::domain_base<ossia::impulse>;
144 using domain_t = ossia::domain_base<bool>;
156 using domain_t = ossia::vector_domain;
159 s.stream.StartObject();
160 s.obj[s.strings.Min] = domain.min;
161 s.obj[s.strings.Max] = domain.max;
162 s.obj[s.strings.Values] = domain.values;
163 s.stream.EndObject();
171 if(
auto it = s.obj.tryGet(s.strings.Min))
175 if(
auto it = s.obj.tryGet(s.strings.Max))
179 if(
auto it = s.obj.tryGet(s.strings.Values))
181 domain.values <<= *it;
186 template <
typename T>
189 using domain_t = ossia::domain_base<T>;
194 bool min_b{domain.min};
197 s.stream() << *domain.min;
202 bool max_b{domain.max};
205 s.stream() << *domain.max;
210 s.stream() << (int32_t)domain.values.size();
211 for(
auto& val : domain.values)
225 typename domain_t::value_type v;
227 domain.min = std::move(v);
236 typename domain_t::value_type v;
238 domain.max = std::move(v);
245 for(
int i = 0; i < count; i++)
247 typename domain_t::value_type v;
249 domain.values.push_back(v);
260 using domain_t = ossia::domain_base<std::string>;
265 s.stream() << (int32_t)domain.values.size();
266 for(
auto& val : domain.values)
278 for(
int i = 0; i < count; i++)
282 domain.values.push_back(v);
293 using domain_t = ossia::domain_base<ossia::impulse>;
302 using domain_t = ossia::domain_base<bool>;
308 template <
typename Functor>
310 Functor&& functor, ossia::domain_base_variant::Type type,
311 ossia::domain_base_variant& var)
313 using namespace ossia;
316 case domain_base_variant::Type::Type0:
317 return functor(
typeholder<ossia::domain_base<ossia::impulse>>{}, var);
318 case domain_base_variant::Type::Type1:
319 return functor(
typeholder<ossia::domain_base<bool>>{}, var);
320 case domain_base_variant::Type::Type2:
321 return functor(
typeholder<ossia::domain_base<int32_t>>{}, var);
322 case domain_base_variant::Type::Type3:
323 return functor(
typeholder<ossia::domain_base<float>>{}, var);
324 case domain_base_variant::Type::Type5:
325 return functor(
typeholder<ossia::domain_base<std::string>>{}, var);
326 case domain_base_variant::Type::Type6:
328 case domain_base_variant::Type::Type7:
329 return functor(
typeholder<ossia::vecf_domain<2>>{}, var);
330 case domain_base_variant::Type::Type8:
331 return functor(
typeholder<ossia::vecf_domain<3>>{}, var);
332 case domain_base_variant::Type::Type9:
333 return functor(
typeholder<ossia::vecf_domain<4>>{}, var);
334 case domain_base_variant::Type::Type10:
335 return functor(
typeholder<ossia::domain_base<ossia::value>>{}, var);
344 using var_t = ossia::domain_base_variant;
347 s.stream() << (quint64)var.which();
351 ossia::apply_nonnull([&](
const auto& v) { s.stream() << v; }, var);
362 if(which != (quint64)var.npos)
365 [&](
auto type, var_t& var) {
366 typename decltype(type)::type value;
368 var = std::move(value);
370 (var_t::Type)which, var);
379 using var_t = ossia::domain_base_variant;
382 s.stream.StartObject();
383 if((quint64)var.which() != (quint64)var.npos)
387 s.stream.EndObject();
390 using value_type_list = ossia::tl<
391 ossia::domain_base<ossia::impulse>, ossia::domain_base<bool>,
392 ossia::domain_base<int32_t>, ossia::domain_base<float>,
393 ossia::domain_base<std::string>, ossia::vector_domain, ossia::vecf_domain<2>,
394 ossia::vecf_domain<3>, ossia::vecf_domain<4>, ossia::domain_base<ossia::value>>;
396 static auto init_keys()
398 std::array<QString, ossia::size<value_type_list>::value> arr;
400 ossia::for_each_tagged(value_type_list{}, [&](
auto t) {
401 using type =
typename decltype(t)::type;
407 static const auto& keys_list()
409 static const auto arr = init_keys();
415 if(!s.base.IsObject() || s.base.MemberCount() == 0)
Definition: VisitorInterface.hpp:53
Definition: DataStreamVisitor.hpp:27
Definition: DataStreamVisitor.hpp:202
Definition: VisitorInterface.hpp:61
Definition: JSONVisitor.hpp:52
Definition: JSONVisitor.hpp:423
Definition: VisitorInterface.hpp:13
Definition: VariantSerialization.hpp:183
Definition: VariantSerialization.hpp:152
Definition: OSSIASerializationImpl.hpp:81