实现启动splash画面,实现天历史数据的处理和数据库存贮

This commit is contained in:
lixiaoyuan
2025-09-09 19:26:05 +08:00
parent 5c94e2098a
commit b2338f21b0
29 changed files with 426 additions and 71 deletions

View File

@@ -4,6 +4,7 @@
#include <fstream>
#include <memory>
#include <iostream>
#include <common/Spdlogger.h>
using njson = nlohmann::json;
@@ -53,26 +54,36 @@ class JSON
public:
static bool load(std::string jsonfile, njson& json);
static bool parse(std::string jsonstr, njson& json);
template <typename T>
static void read(njson& json, std::string k, T& v)
{
try
{
if (json.contains(k)) { v = json.at(k).get<T>(); }
}
catch (const nlohmann::detail::exception& e)
{
std::cout << "JSON read error: k=" << k << ", err=" << e.what() << std::endl;
}
try { if (json.contains(k)) { v = json.at(k).get<T>(); } }
catch (const nlohmann::detail::exception& e) { Spdlogger::info("JSON read error: k={}, err={}", k, e.what()); }
}
template <typename T>
static T read(njson& json, std::string k)
{
T v {};
try { if (json.contains(k)) { v = json.at(k).get<T>(); } }
catch (const nlohmann::detail::exception& e) { Spdlogger::info("JSON read error: k={}, err={}", k, e.what()); }
return v;
}
template <typename T>
static T get(njson& json)
{
T v {};
try { v = json.get<T>(); }
catch (const nlohmann::detail::exception& e) { Spdlogger::info("JSON read error: err={}, json={}", e.what(), json.dump()); }
return v;
}
static std::string readStr(njson& json, std::string k);
static void parse(std::string jsonstr, std::vector<std::string>& vd);
};