1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-07-01 19:37:43 +02:00
doorlockd-mirror/doorlockd/util.h

26 lines
544 B
C
Raw Normal View History

2015-05-11 00:18:22 +02:00
#ifndef UTIL_H
#define UTIL_H
#include <algorithm>
#include <json/json.h>
template <typename T>
T getJson(const Json::Value &root, const std::string &key);
template <typename T>
T getJsonOrFail(const Json::Value &root, const std::string &key)
{
const auto members = root.getMemberNames();
if (std::find(members.begin(), members.end(), key) == members.end())
{
throw "Json key not existing";
}
return getJson<T>(root, key);
}
std::string toHexString(uint64_t c);
uint64_t toUint64(const std::string &s);
#endif