@ -34,20 +34,30 @@ public:
@@ -34,20 +34,30 @@ public:
/// jsonFileTypeKey - Required and checked to be equal to expectedFileType
/// jsonVersionKey - Required and checked to be below supportedMajorVersion, supportedMinorVersion
/// jsonGroundStationKey - Required and checked to be string type
/// @return false: validation failed
static bool validateQGCJsonFile ( const QJsonObject & jsonObject , ///< root json object
/// @return false: validation failed, errorString set
static bool validateQGCJsonFile ( const QJsonObject & jsonObject , ///< json object to validate
const QString & expectedFileType , ///< correct file type for file
int minSupportedVersion , ///< minimum supported version
int maxSupportedVersion , ///< maximum supported major version
int & version , ///< returned file version
QString & errorString ) ; ///< returned error string if validation fails
static bool validateRequiredKeys ( const QJsonObject & jsonObject , const QStringList & keys , QString & errorString ) ;
static bool validateKeyTypes ( const QJsonObject & jsonObject , const QStringList & keys , const QList < QJsonValue : : Type > & types , QString & errorString ) ;
/// Validates that the specified keys are in the object
/// @return false: validation failed, errorString set
static bool validateRequiredKeys ( const QJsonObject & jsonObject , ///< json object to validate
const QStringList & keys , ///< keys which are required to be present
QString & errorString ) ; ///< returned error string if validation fails
/// Validates the types of specified keys are in the object
/// @return false: validation failed, errorString set
static bool validateKeyTypes ( const QJsonObject & jsonObject , ///< json object to validate
const QStringList & keys , ///< keys to validate
const QList < QJsonValue : : Type > & types , ///< required type for each key, QJsonValue::Null specifies double with possible NaN
QString & errorString ) ; ///< returned error string if validation fails
typedef struct {
const char * key ; ///< json key name
QJsonValue : : Type type ; ///< type of key
QJsonValue : : Type type ; ///< required type for key, QJsonValue::Null specifies double with possible NaN
bool required ; ///< true: key must be present
} KeyValidateInfo ;
@ -96,6 +106,8 @@ public:
@@ -96,6 +106,8 @@ public:
static bool parseEnum ( const QJsonObject & jsonObject , QStringList & enumStrings , QStringList & enumValues , QString & errorString ) ;
/// Returns NaN if the value is null, or it not the double value
static double possibleNaNJsonValue ( const QJsonValue & value ) ;
static const char * jsonVersionKey ;
static const char * jsonGroundStationKey ;