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 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 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 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 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 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 151 of file JsonValidation.cc.
Referenced by LandingComplexItem::_load(), TransectStyleComplexItem::_load(), FactMetaData::createMapFromJsonFile(), TerrainTileCopernicus::getJsonFromData(), CameraCalc::load(), CameraSpec::load(), FixedWingLandingComplexItem::load(), GeoFenceController::load(), MissionItem::load(), RallyPointController::load(), SimpleMissionItem::load(), StructureScanComplexItem::load(), SurveyComplexItem::load(), VTOLLandingComplexItem::load(), QGCFenceCircle::loadFromJson(), QGCFencePolygon::loadFromJson(), QGCMapCircle::loadFromJson(), TerrainTileCopernicus::serializeFromData(), CompInfoGeneral::setJson(), CompInfoParam::setJson(), validateExternalQGCJsonFile(), and validateInternalQGCJsonFile().
| 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 156 of file JsonValidation.cc.
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 133 of file JsonValidation.cc.
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 122 of file JsonValidation.cc.
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 LandingComplexItem::_load(), TransectStyleComplexItem::_load(), TransectStyleComplexItem::_save(), CameraCalc::load(), FixedWingLandingComplexItem::load(), GeoFenceController::load(), RallyPointController::load(), StructureScanComplexItem::load(), SurveyComplexItem::load(), VTOLLandingComplexItem::load(), QGCFenceCircle::loadFromJson(), QGCFencePolygon::loadFromJson(), CameraMetaData::parseCameraMetaData(), CameraCalc::save(), FixedWingLandingComplexItem::save(), GeoFenceController::save(), MissionController::save(), RallyPointController::save(), StructureScanComplexItem::save(), VTOLLandingComplexItem::save(), saveQGCJsonFileHeader(), QGCFenceCircle::saveToJson(), QGCFencePolygon::saveToJson(), CompInfoGeneral::setJson(), CompInfoParam::setJson(), and validateInternalQGCJsonFile().