mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Ref T237, init/read from JSON files
* multi format compatible (automatically detect format) * flag if cache values shall be overridden * init from resource files (those are the files coming with the installer) * automatically read in background if reader is (already) in its own thread (otherwise cache.set() ASSERT)
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "blackmisc/fileutils.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Json;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
|
||||
@@ -356,8 +357,8 @@ namespace BlackCore
|
||||
byteData = qUncompress(ba);
|
||||
}
|
||||
while (false);
|
||||
|
||||
}
|
||||
|
||||
if (byteData.isEmpty()) { return QJsonDocument(); }
|
||||
return QJsonDocument::fromJson(byteData);
|
||||
}
|
||||
@@ -373,7 +374,10 @@ namespace BlackCore
|
||||
{
|
||||
const QString raw = CFileUtils::readFileToString(filename);
|
||||
if (raw.isEmpty()) { return QJsonObject(); }
|
||||
return BlackMisc::Json::jsonObjectFromString(raw);
|
||||
|
||||
// allow also compressed format
|
||||
const QJsonDocument jsonDoc = CDatabaseUtils::databaseJsonToQJsonDocument(raw);
|
||||
return jsonDoc.object();
|
||||
}
|
||||
|
||||
QJsonObject CDatabaseUtils::readQJsonObjectFromDatabaseFile(const QString &directory, const QString &filename)
|
||||
|
||||
Reference in New Issue
Block a user