MCPcopy Create free account
hub / github.com/baldurk/renderdoc / LoadFromJSON

Function LoadFromJSON

qrenderdoc/Code/QRDUtils.cpp:2308–2343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2306}
2307
2308bool LoadFromJSON(QVariantMap &data, QIODevice &f, const char *magicIdentifier, uint32_t magicVersion)
2309{
2310 QByteArray json = f.readAll();
2311
2312 if(json.isEmpty())
2313 {
2314 qCritical() << "Read invalid empty JSON data from file " << f.errorString();
2315 return false;
2316 }
2317
2318 QJsonDocument doc = QJsonDocument::fromJson(json);
2319
2320 if(doc.isEmpty() || doc.isNull())
2321 {
2322 qCritical() << "Failed to convert file to JSON document";
2323 return false;
2324 }
2325
2326 data = doc.toVariant().toMap();
2327
2328 QString ident = QString::fromLatin1(magicIdentifier);
2329
2330 if(data.isEmpty() || !data.contains(ident))
2331 {
2332 qCritical() << "Converted config data is invalid or unrecognised";
2333 return false;
2334 }
2335
2336 if(data[ident].toUInt() != magicVersion)
2337 {
2338 qCritical() << "Converted config data is not the right version";
2339 return false;
2340 }
2341
2342 return true;
2343}
2344
2345QString VariantToJSON(const QVariantMap &data)
2346{

Callers 6

LoadMethod · 0.85
DeserializeMethod · 0.85
LoadLayoutMethod · 0.85
CreateFilterDialogMethod · 0.85
LoadMethod · 0.85
LoadSettingsFromDiskMethod · 0.85

Calls 6

fromLatin1Function · 0.85
errorStringMethod · 0.80
toVariantMethod · 0.80
isEmptyMethod · 0.45
isNullMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected