bigsnitch/includes.h
Tim Blume 3b01e35783 sta
2020-08-29 01:09:41 +02:00

42 lines
1.2 KiB
C++

#pragma once
#include <zmq.hpp>
#include <nlohmann/json.hpp>
#include <sqlite3.h>
#include <filesystem>
#include <QDebug>
#include <iostream>
using json = nlohmann::json;
//major minor patch
#define LITTLESNITCH_VERSION 010
template<typename T, typename K>
bool json_get(json j, T& value, K key) noexcept {
try {
j[key].get_to(value);
return true;
} catch (nlohmann::detail::type_error& err) {
qDebug() << "key " << key << " error " << err.what();
} catch (nlohmann::detail::out_of_range& err) {
qDebug() << "key " << key << " error " << err.what();
} catch (nlohmann::detail::other_error& err) {
qDebug() << "key " << key << " error " << err.what();
}
return false;
}
template<typename T, typename K, typename... Ks>
bool json_get(json j, T& value, K key, Ks... keys) noexcept {
try {
return json_get(j[key], value, keys...);
} catch (nlohmann::detail::type_error& err) {
qDebug() << "key " << key << " error " << err.what();
} catch (nlohmann::detail::out_of_range& err) {
qDebug() << "key " << key << " error " << err.what();
} catch (nlohmann::detail::other_error& err) {
qDebug() << "key " << key << " error " << err.what();
}
return false;
}