|
QGroundControl
Ground Control Station for MAVLink Drones
|
Classes | |
| struct | KeyValidateInfo |
Functions | |
| bool | isJsonFile (const QByteArray &bytes, QJsonDocument &jsonDoc, QString &errorString) |
| Determines whether an in-memory byte buffer contains parseable JSON content. | |
| bool | isJsonFile (const QString &fileName, QJsonDocument &jsonDoc, QString &errorString) |
| Determines whether a file path contains parseable JSON content. | |
| double | possibleNaNJsonValue (const QJsonValue &value) |
| Returns NaN if the value is null, or the value converted to double otherwise. | |
| QTranslator * | translator () |
Translator used by openInternalQGCJsonFile for localized strings. | |
| void | saveQGCJsonFileHeader (QJsonObject &jsonObject, const QString &fileType, int version) |
| Saves the standard QGC file header (groundStation, fileType, version) into the json object. | |
| bool | validateInternalQGCJsonFile (const QJsonObject &jsonObject, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString) |
| bool | validateExternalQGCJsonFile (const QJsonObject &jsonObject, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString) |
| QJsonObject | openInternalQGCJsonFile (const QString &jsonFilename, const QString &expectedFileType, int minSupportedVersion, int maxSupportedVersion, int &version, QString &errorString, const QStringList &defaultTranslateKeys, const QStringList &defaultArrayIDKeys) |
| bool | validateRequiredKeys (const QJsonObject &jsonObject, const QStringList &keys, QString &errorString) |
| Validates that all listed keys are present in the object. | |
| bool | validateKeyTypes (const QJsonObject &jsonObject, const QStringList &keys, const QList< QJsonValue::Type > &types, QString &errorString) |
| bool | validateKeys (const QJsonObject &jsonObject, const QList< KeyValidateInfo > &keyInfo, QString &errorString) |
| Validates that all required keys are present and that listed keys have the expected type. | |
| bool | validateKeysStrict (const QJsonObject &jsonObject, const QList< KeyValidateInfo > &keyInfo, QString &errorString) |
Validates keys like validateKeys but also rejects any keys not listed in keyInfo. | |
Variables | |
| constexpr const char * | jsonVersionKey = "version" |
| constexpr const char * | jsonFileTypeKey = "fileType" |
| bool JsonParsing::isJsonFile | ( | const QByteArray & | bytes, |
| QJsonDocument & | jsonDoc, | ||
| QString & | errorString | ||
| ) |
Determines whether an in-memory byte buffer contains parseable JSON content.
Definition at line 19 of file JsonParsing.cc.
References errorString, isJsonFile(), QGCCompression::looksLikeCompressedData(), and QGCCompression::parseCompressedJson().
Referenced by GeoJsonHelper::_loadFile(), isJsonFile(), isJsonFile(), ParameterMetaData::loadParameterFactMetaDataFile(), openInternalQGCJsonFile(), CompInfoActuators::setJson(), CompInfoGeneral::setJson(), CompInfoParam::setJson(), ComponentInformationTranslation::translateJsonUsingTS(), and ParameterMetaData::versionFromJsonData().
| bool JsonParsing::isJsonFile | ( | const QString & | fileName, |
| QJsonDocument & | jsonDoc, | ||
| QString & | errorString | ||
| ) |
Determines whether a file path contains parseable JSON content.
Definition at line 41 of file JsonParsing.cc.
References errorString, isJsonFile(), and QGCCompression::readFile().
| QJsonObject JsonParsing::openInternalQGCJsonFile | ( | const QString & | jsonFilename, |
| const QString & | expectedFileType, | ||
| int | minSupportedVersion, | ||
| int | maxSupportedVersion, | ||
| int & | version, | ||
| QString & | errorString, | ||
| const QStringList & | defaultTranslateKeys = {}, |
||
| const QStringList & | defaultArrayIDKeys = {} |
||
| ) |
Opens, validates, and translates an internal QGC json file.
| defaultTranslateKeys | Keys to translate when translateKeys is absent from the JSON. |
| defaultArrayIDKeys | Array ID keys to use when _arrayIDKeys is absent from the JSON. |
Definition at line 217 of file JsonParsing.cc.
References errorString, isJsonFile(), and validateInternalQGCJsonFile().
Referenced by FactMetaData::createMapFromJsonFile(), CameraMetaData::parseCameraMetaData(), and PowerModulePresetController::powerModulePresets().
| double JsonParsing::possibleNaNJsonValue | ( | const QJsonValue & | value | ) |
Returns NaN if the value is null, or the value converted to double otherwise.
Definition at line 52 of file JsonParsing.cc.
References possibleNaNJsonValue().
Referenced by MissionItem::load(), SimpleMissionItem::load(), GeoJsonHelper::loadGeoCoordinate(), GeoJsonHelper::loadGeoJsonCoordinate(), MissionCommandUIInfo::loadJsonInfo(), and possibleNaNJsonValue().
| void JsonParsing::saveQGCJsonFileHeader | ( | QJsonObject & | jsonObject, |
| const QString & | fileType, | ||
| int | version | ||
| ) |
Saves the standard QGC file header (groundStation, fileType, version) into the json object.
Definition at line 159 of file JsonParsing.cc.
References jsonFileTypeKey, and jsonVersionKey.
Referenced by PlanMasterController::saveToJson().
| QTranslator * JsonParsing::translator | ( | ) |
Translator used by openInternalQGCJsonFile for localized strings.
Definition at line 154 of file JsonParsing.cc.
Referenced by QGCApplication::setLanguage().
| bool JsonParsing::validateExternalQGCJsonFile | ( | const QJsonObject & | jsonObject, |
| const QString & | expectedFileType, | ||
| int | minSupportedVersion, | ||
| int | maxSupportedVersion, | ||
| int & | version, | ||
| QString & | errorString | ||
| ) |
Validates the standard parts of an external QGC json file (Plan file, ...). Checks groundStation, fileType, and version keys.
Definition at line 201 of file JsonParsing.cc.
References errorString, validateInternalQGCJsonFile(), and validateKeys().
| bool JsonParsing::validateInternalQGCJsonFile | ( | const QJsonObject & | jsonObject, |
| const QString & | expectedFileType, | ||
| int | minSupportedVersion, | ||
| int | maxSupportedVersion, | ||
| int & | version, | ||
| QString & | errorString | ||
| ) |
Validates the standard parts of an internal QGC json file (FactMetaData, ...). Checks fileType and version keys.
Definition at line 166 of file JsonParsing.cc.
References errorString, jsonFileTypeKey, jsonVersionKey, and validateKeys().
Referenced by openInternalQGCJsonFile(), and validateExternalQGCJsonFile().
| bool JsonParsing::validateKeys | ( | const QJsonObject & | jsonObject, |
| const QList< KeyValidateInfo > & | keyInfo, | ||
| QString & | errorString | ||
| ) |
Validates that all required keys are present and that listed keys have the expected type.
Definition at line 86 of file JsonValidation.cc.
References errorString.
Referenced by TransectStyleComplexItem::_load(), LandingComplexItem::_load(), FactMetaData::createMapFromJsonFile(), TerrainTileCopernicus::getJsonFromData(), FixedWingLandingComplexItem::load(), StructureScanComplexItem::load(), SurveyComplexItem::load(), VTOLLandingComplexItem::load(), CameraCalc::load(), MissionItem::load(), SimpleMissionItem::load(), CameraSpec::load(), GeoFenceController::load(), RallyPointController::load(), QGCFencePolygon::loadFromJson(), QGCFenceCircle::loadFromJson(), QGCMapCircle::loadFromJson(), TerrainTileCopernicus::serializeFromData(), CompInfoGeneral::setJson(), CompInfoParam::setJson(), validateExternalQGCJsonFile(), validateInternalQGCJsonFile(), and validateKeysStrict().
| bool JsonParsing::validateKeysStrict | ( | const QJsonObject & | jsonObject, |
| const QList< KeyValidateInfo > & | keyInfo, | ||
| QString & | errorString | ||
| ) |
Validates keys like validateKeys but also rejects any keys not listed in keyInfo.
Definition at line 108 of file JsonValidation.cc.
References errorString, and validateKeys().
Referenced by FactMetaData::createFromJsonObject(), CameraMetaData::parseCameraMetaData(), and PowerModulePresetController::powerModulePresets().
| bool JsonParsing::validateKeyTypes | ( | const QJsonObject & | jsonObject, |
| const QStringList & | keys, | ||
| const QList< QJsonValue::Type > & | types, | ||
| QString & | errorString | ||
| ) |
Validates value types for listed keys that are present in the object. QJsonValue::Null as expected type means "double value with possible NaN".
Definition at line 68 of file JsonValidation.cc.
References errorString, and keys.
Referenced by MissionCommandUIInfo::loadJsonInfo().
| bool JsonParsing::validateRequiredKeys | ( | const QJsonObject & | jsonObject, |
| const QStringList & | keys, | ||
| QString & | errorString | ||
| ) |
Validates that all listed keys are present in the object.
Definition at line 57 of file JsonValidation.cc.
References errorString, and keys.
Referenced by QGCMapPolygon::loadFromJson(), QGCMapPolyline::loadFromJson(), and MissionCommandUIInfo::loadJsonInfo().
|
constexpr |
Definition at line 15 of file JsonParsing.h.
Referenced by CameraMetaData::parseCameraMetaData(), saveQGCJsonFileHeader(), and validateInternalQGCJsonFile().
|
constexpr |
Definition at line 14 of file JsonParsing.h.
Referenced by TransectStyleComplexItem::_load(), LandingComplexItem::_load(), TransectStyleComplexItem::_save(), FixedWingLandingComplexItem::load(), StructureScanComplexItem::load(), SurveyComplexItem::load(), VTOLLandingComplexItem::load(), CameraCalc::load(), GeoFenceController::load(), RallyPointController::load(), QGCFencePolygon::loadFromJson(), QGCFenceCircle::loadFromJson(), CameraMetaData::parseCameraMetaData(), FixedWingLandingComplexItem::save(), StructureScanComplexItem::save(), VTOLLandingComplexItem::save(), CameraCalc::save(), GeoFenceController::save(), MissionController::save(), RallyPointController::save(), saveQGCJsonFileHeader(), QGCFenceCircle::saveToJson(), QGCFencePolygon::saveToJson(), CompInfoGeneral::setJson(), CompInfoParam::setJson(), and validateInternalQGCJsonFile().