blob: b9d3c92e2081f2c06192a0ddb6e7436bc91b4573 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#ifndef TMCAGLWM_JSON_HELPER_HPP
#define TMCAGLWM_JSON_HELPER_HPP
#include <json.hpp>
#include "wayland.hpp"
#include "result.hpp"
struct json_object;
json_object *to_json(genivi::screen const *s);
json_object *to_json(genivi::controller::props_map const &s);
json_object *to_json(std::vector<uint32_t> const &v);
// We ned to manually unwrap numbers
template <typename T>
wm::result<T> get(nlohmann::json const &j) {
// DB(j);
T r;
std::istringstream s(j.get<std::string>());
s >> r;
return !s.eof() || s.fail() ? wm::Err<T>("Could not read int") : wm::Ok(r);
}
#endif // TMCAGLWM_JSON_HELPER_HPP
|