35 ossia::json_writer& writer;
36 void operator()() { writer.Null(); }
38 void operator()(
const ossia::domain_base<impulse>& dom) { writer.Null(); }
40 void operator()(
const ossia::domain_base<bool>& dom)
46 write_json(writer,
false);
47 write_json(writer,
true);
54 void operator()(
const ossia::domain_base<T>& dom)
56 bool has_min = bool(dom.min);
57 bool has_max = bool(dom.max);
58 bool has_values = !dom.values.empty();
59 if(has_min || has_max || has_values)
66 write_json(writer, *dom.min);
71 write_json(writer, *dom.max);
77 for(
auto val : dom.values)
78 write_json(writer, val);
90 void operator()(
const ossia::domain_base<std::string>& dom)
92 if(!dom.values.empty())
98 for(
auto val : dom.values)
99 write_json(writer, val);
110 void operator()(
const ossia::vector_domain& dom)
112 const auto min_count = dom.min.size();
113 const auto max_count = dom.max.size();
114 const auto values_count = dom.values.size();
115 const auto N = std::max(std::max(min_count, max_count), values_count);
119 for(std::size_t i = 0; i < N; i++)
121 if(values_count > i && !dom.values[i].empty())
123 writer.StartObject();
128 for(
const auto& val : dom.values[i])
129 write_json(writer, val);
135 (min_count > i && dom.min[i].valid())
136 || (max_count > i && dom.max[i].valid()))
138 writer.StartObject();
139 if(dom.min[i].valid())
142 write_json(writer, dom.min[i]);
145 if(dom.max[i].valid())
148 write_json(writer, dom.max[i]);
165 template <std::
size_t N>
166 void operator()(
const ossia::vecf_domain<N>& dom)
170 for(std::size_t i = 0; i < N; i++)
172 if(!dom.values[i].empty())
174 writer.StartObject();
179 for(
const auto val : dom.values[i])
185 else if(dom.min[i] || dom.max[i])
187 writer.StartObject();
191 write_json(writer, *dom.min[i]);
197 write_json(writer, *dom.max[i]);
209 void operator()(
const ossia::domain_base<ossia::value>& dom)
Write a domain to json.
Definition domain_to_json.hpp:34