QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
JsonParsing.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QJsonDocument>
4#include <QtCore/QJsonObject>
5#include <QtCore/QJsonValue>
6#include <QtCore/QStringList>
7
8#include "JsonValidation.h"
9
10class QTranslator;
11
12namespace JsonParsing {
13
14constexpr const char *jsonVersionKey = "version";
15constexpr const char *jsonFileTypeKey = "fileType";
16
17
19bool isJsonFile(const QString& fileName, QJsonDocument& jsonDoc, QString& errorString);
20
22bool isJsonFile(const QByteArray& bytes, QJsonDocument& jsonDoc, QString& errorString);
23
25double possibleNaNJsonValue(const QJsonValue& value);
26
28QTranslator *translator();
29
31void saveQGCJsonFileHeader(QJsonObject &jsonObject, const QString &fileType, int version);
32
35bool validateExternalQGCJsonFile(const QJsonObject &jsonObject,
36 const QString &expectedFileType,
37 int minSupportedVersion,
38 int maxSupportedVersion,
39 int &version,
40 QString &errorString);
41
44bool validateInternalQGCJsonFile(const QJsonObject &jsonObject,
45 const QString &expectedFileType,
46 int minSupportedVersion,
47 int maxSupportedVersion,
48 int &version,
49 QString &errorString);
50
54QJsonObject openInternalQGCJsonFile(const QString &jsonFilename,
55 const QString &expectedFileType,
56 int minSupportedVersion,
57 int maxSupportedVersion,
58 int &version,
59 QString &errorString,
60 const QStringList &defaultTranslateKeys = {},
61 const QStringList &defaultArrayIDKeys = {});
62
63} // namespace JsonParsing
QString errorString
bool validateExternalQGCJsonFile(const QJsonObject &jsonObject, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString)
bool validateInternalQGCJsonFile(const QJsonObject &jsonObject, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString)
bool isJsonFile(const QByteArray &bytes, QJsonDocument &jsonDoc, QString &errorString)
Determines whether an in-memory byte buffer contains parseable JSON content.
constexpr const char * jsonFileTypeKey
Definition JsonParsing.h:15
QJsonObject openInternalQGCJsonFile(const QString &jsonFilename, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString, const QStringList &defaultTranslateKeys, const QStringList &defaultArrayIDKeys)
double possibleNaNJsonValue(const QJsonValue &value)
Returns NaN if the value is null, or the value converted to double otherwise.
void saveQGCJsonFileHeader(QJsonObject &jsonObject, const QString &fileType, int version)
Saves the standard QGC file header (groundStation, fileType, version) into the json object.
QTranslator * translator()
Translator used by openInternalQGCJsonFile for localized strings.
constexpr const char * jsonVersionKey
Definition JsonParsing.h:14