2020-08-09 12:07:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <zmq.hpp>
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <sqlite3.h>
|
|
|
|
#include <filesystem>
|
|
|
|
#include <QDebug>
|
2020-08-13 03:35:22 +00:00
|
|
|
#include <iostream>
|
2020-08-09 12:07:14 +00:00
|
|
|
|
|
|
|
using json = nlohmann::json;
|
2020-08-13 21:25:04 +00:00
|
|
|
|
|
|
|
//major minor patch
|
|
|
|
#define LITTLESNITCH_VERSION 010
|
2020-08-21 18:40:37 +00:00
|
|
|
|
|
|
|
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) {
|
2020-08-28 23:09:41 +00:00
|
|
|
qDebug() << "key " << key << " error " << err.what();
|
2020-08-21 18:40:37 +00:00
|
|
|
} catch (nlohmann::detail::out_of_range& err) {
|
2020-08-28 23:09:41 +00:00
|
|
|
qDebug() << "key " << key << " error " << err.what();
|
2020-08-21 18:40:37 +00:00
|
|
|
} catch (nlohmann::detail::other_error& err) {
|
2020-08-28 23:09:41 +00:00
|
|
|
qDebug() << "key " << key << " error " << err.what();
|
2020-08-21 18:40:37 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T, typename K, typename... Ks>
|
|
|
|
bool json_get(json j, T& value, K key, Ks... keys) noexcept {
|
2020-08-28 23:09:41 +00:00
|
|
|
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;
|
2020-08-21 18:40:37 +00:00
|
|
|
}
|