restructuring
This commit is contained in:
parent
4d020014c0
commit
a0ce50b7cd
11 changed files with 158 additions and 46 deletions
|
|
@ -1,5 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
//major minor patch
|
||||
#define LITTLESNITCH_VERSION 100
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
|
@ -7,6 +10,42 @@
|
|||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include <qdebug.h>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
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) {
|
||||
std::cout << "key " << key << " error " << err.what();
|
||||
} catch (nlohmann::detail::out_of_range& err) {
|
||||
std::cout << "key " << key << " error " << err.what();
|
||||
} catch (nlohmann::detail::other_error& err) {
|
||||
std::cout << "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) {
|
||||
std::cout << "key " << key << " error " << err.what();
|
||||
} catch (nlohmann::detail::out_of_range& err) {
|
||||
std::cout << "key " << key << " error " << err.what();
|
||||
} catch (nlohmann::detail::other_error& err) {
|
||||
std::cout << "key " << key << " error " << err.what();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
//! represents one item in the http history.
|
||||
struct HistoryItem {
|
||||
int id = -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue