1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-22 18:34:25 +01:00
doorlockd-mirror/doorlockd/lib/util.h
Ralf Ramsauer 60ed23486b Improved directory structure
Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
2015-09-29 14:33:53 +02:00

27 lines
585 B
C++

#ifndef UTIL_H
#define UTIL_H
#include <algorithm>
#include <exception>
#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 std::runtime_error("Json key not existing");
}
return getJson<T>(root, key);
}
std::string toHexString(uint64_t c);
uint64_t toUint64(const std::string &s);
#endif