2020-08-09 12:07:14 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-09-10 19:26:41 +00:00
|
|
|
#include <include/api.h>
|
2020-08-09 12:07:14 +00:00
|
|
|
#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-09-02 23:14:10 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <string>
|
2020-08-09 12:07:14 +00:00
|
|
|
|
|
|
|
using json = nlohmann::json;
|
2020-08-13 21:25:04 +00:00
|
|
|
|
|
|
|
//major minor patch
|
2020-09-10 19:26:41 +00:00
|
|
|
#define LITTLESNITCH_VERSION 100
|
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
|
|
|
}
|