1 #include "json_helper.hpp"
7 using json = nlohmann::json;
10 json_object *to_json_(T const *s) {
11 auto j = json::object({
13 {"size", {{"width", s->size.w}, {"height", s->size.h}}},
15 {{"width", s->dst_rect.w},
16 {"height", s->dst_rect.h},
18 {"y", s->dst_rect.y}}},
20 {{"width", s->src_rect.w},
21 {"height", s->src_rect.h},
23 {"y", s->src_rect.y}}},
24 {"visibility", s->visibility},
25 {"opacity", s->opacity},
26 {"orientation", s->orientation},
28 return json_tokener_parse(j.dump().c_str());
31 json_object *to_json(genivi::surface const *s) { return to_json_(s); }
33 json_object *to_json(genivi::layer const *l) { return to_json_(l); }
35 json_object *to_json(genivi::screen const *s) {
36 auto o = json_object_new_object();
37 json_object_object_add(o, "id", json_object_new_int(s->id));
42 json_object *to_json_(T const &s) {
43 auto a = json_object_new_array();
46 for (auto const &i : s) {
47 json_object_array_add(a, to_json(i.second.get()));
54 json_object *to_json(genivi::controller::surface_map_type const &s) {
58 json_object *to_json(genivi::controller::layer_map_type const &l) {
62 json_object *to_json(genivi::controller::screen_map_type const &s) {
66 json_object *to_json(std::vector<uint32_t> const &v) {
67 auto a = json_object_new_array();
68 for (const auto i : v) {
69 json_object_array_add(a, json_object_new_int(i));