#include <qmjsonvalue.h>
Signals | |
void | valueChanged (void) |
Public Member Functions | |
QMJsonValue () | |
QMJsonValue (bool value) | |
QMJsonValue (double value) | |
QMJsonValue (const QString &value) | |
QMJsonValue (const QMPointer< QMJsonValue > &value) | |
QMJsonValue (const QMPointer< QMJsonArray > &value) | |
QMJsonValue (const QMPointer< QMJsonObject > &value) | |
QMJsonValue (QMJsonValue *value) | |
QMJsonValue (QMJsonArray *value) | |
QMJsonValue (QMJsonObject *value) | |
template<class T > | |
QMJsonValue (const T &value) | |
QMJsonValue (const char *value) | |
QMJsonValue (float value) | |
QMJsonValue (char value) | |
QMJsonValue (int8_t value) | |
QMJsonValue (uint8_t value) | |
QMJsonValue (int16_t value) | |
QMJsonValue (uint16_t value) | |
QMJsonValue (int32_t value) | |
QMJsonValue (uint32_t value) | |
QMJsonValue (int64_t value) | |
QMJsonValue (uint64_t value) | |
virtual | ~QMJsonValue () |
virtual bool | isNull (void) const |
virtual bool | isBool (void) const |
virtual bool | isDouble (void) const |
virtual bool | isString (void) const |
virtual bool | isArray (void) const |
virtual bool | isObject (void) const |
template<class T > | |
bool | is (void) const |
virtual bool | toBool (void) const |
virtual double | toDouble (void) const |
virtual QString | toString (void) const |
virtual const QMPointer< QMJsonArray > & | toArray (void) const |
virtual const QMPointer< QMJsonObject > & | toObject (void) const |
virtual bool | toBool (bool defaultValue) const |
virtual double | toDouble (double defaultValue) const |
virtual const QString & | toString (const QString &defaultValue) const |
virtual const QMPointer< QMJsonArray > & | toArray (const QMPointer< QMJsonArray > &defaultValue) const |
virtual const QMPointer< QMJsonObject > & | toObject (const QMPointer< QMJsonObject > &defaultValue) const |
template<class T > | |
const T & | to (const T &defaultValue) const |
virtual bool | fromBool (bool value) |
virtual bool | fromDouble (double value) |
virtual bool | fromString (const QString &value) |
virtual bool | fromArray (const QMPointer< QMJsonArray > &value) |
virtual bool | fromObject (const QMPointer< QMJsonObject > &value) |
virtual bool | from (const QMPointer< QMJsonValue > &value) |
template<class T > | |
bool | from (const T &value) |
virtual const QMPointer< QMJsonValue > & | value (int32_t index) const |
virtual const QMPointer< QMJsonValue > & | value (const QString &key) const |
virtual QVariant | toVariant (void) |
virtual QMJsonValueType | type (void) const |
virtual const QString & | typeString (void) const |
virtual QString | toJson (QMJsonFormat format=QMJsonFormat_Pretty, QMJsonSort sort=QMJsonSort_None) const |
virtual bool | toJsonFile (const QString &filename, QMJsonFormat format=QMJsonFormat_Pretty, QMJsonSort sort=QMJsonSort_None) const |
Static Public Member Functions | |
static QMPointer< QMJsonValue > | fromVariant (const QVariant &value) |
static QMPointer< QMJsonValue > | fromJson (const QString &json) |
static QMPointer< QMJsonValue > | fromJsonFile (const QString &filename) |
static void | registerFromComplexJson (const QString &qmjsontype, FromComplexJsonFunc func) |
Friends | |
template<class T > | |
class | QMJsonType |
QDebug QM_JSON_EXPORT | operator<< (QDebug dbg, const QMJsonValue &value) |
Definition at line 48 of file qmjsonvalue.h.
QMJsonValue::QMJsonValue | ( | ) |
Creates a JSON "null" value.
Definition at line 49 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON boolean value.
Definition at line 54 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 62 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON string value.
Definition at line 70 of file qmjsonvalue.cpp.
|
explicit |
Creates a new JSON value from an existing JSON value.
Both JSON values share the same internal pointer, and thus modifying one of the values, modifies them all.
Definition at line 78 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON array, wrapped in a JSON value.
Definition at line 92 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON object, wrapped in a JSON value.
Definition at line 109 of file qmjsonvalue.cpp.
|
explicit |
Creates a new JSON value from an existing JSON value.
Both JSON values share the same internal pointer, and thus modifying one of the values, modifies them all.
Definition at line 126 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON array, wrapped in a JSON value.
Definition at line 140 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON object, wrapped in a JSON value.
Definition at line 158 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON value with type T.
The QtMark JSON Library supports wraping almost anything in a JSON value. If you use this function, the compiler will likely require that you provide a QDebug overload for this type (if one does not already exist).
If you wish to use toJson and fromJson with a non-standard type, you need to provide the Complex JSON template overloads. For an example of how to do this, see the qmjsontype_qsize.cpp file.
This library also supported nested complex types. To see an example of how this works, see the qmjsontype_qrect.cpp file, as the QRect implementation relys on QSize and QPoint.
Definition at line 176 of file qmjsonvalue.h.
|
explicit |
Creates a JSON string value.
Definition at line 176 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 184 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 192 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 200 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 208 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 216 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 224 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 232 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 240 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 248 of file qmjsonvalue.cpp.
|
explicit |
Creates a JSON number value.
Definition at line 256 of file qmjsonvalue.cpp.
|
virtual |
Definition at line 302 of file qmjsonvalue.cpp.
|
virtual |
Returns true if the wrapped JSON value is a "null".
Definition at line 306 of file qmjsonvalue.cpp.
|
virtual |
Returns true if the wrapped JSON value is a boolean
Definition at line 311 of file qmjsonvalue.cpp.
|
virtual |
Returns true if the wrapped JSON value is a double.
Definition at line 316 of file qmjsonvalue.cpp.
|
virtual |
Returns true if the wrapped JSON value is a string.
Definition at line 321 of file qmjsonvalue.cpp.
|
virtual |
Returns true if the wrapped JSON value is a JSON array
Definition at line 326 of file qmjsonvalue.cpp.
|
virtual |
Returns true if the wrapped JSON value is a JSON object
Definition at line 331 of file qmjsonvalue.cpp.
bool QMJsonValue::is | ( | void | ) | const |
Returns true if the wrapped JSON value is of type T. This function is ment to be used with custom, complex types as show below:
Definition at line 185 of file qmjsonvalue.h.
|
virtual |
Unwraps the JSON value and returns the interanl type. Depending on what type the JSON value is, will dictate what is returned:
Definition at line 336 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and returns the interanl type. Depending on what type the JSON value is, will dictate what is returned:
Definition at line 367 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and returns the interanl type. Depending on what type the JSON value is, will dictate what is returned:
Definition at line 395 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and returns a QMJsonArray. If the internal type is not a QMJsonArray, an empty QMJsonArray is returned.
Definition at line 423 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and returns a QMJsonObject. If the internal type is not a QMJsonObject, an empty QMJsonObject is returned.
Definition at line 434 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and returns the interanl type. If the interal type is not a boolean, the default value is returned instead.
Definition at line 445 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and returns the interanl type. If the interal type is not a double, the default value is returned instead.
Definition at line 455 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and returns the interanl type. If the interal type is not a string, the default value is returned instead.
Definition at line 465 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and returns the interanl type. If the interal type is not an array, the default value is returned instead.
Definition at line 475 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and returns the interanl type. If the interal type is not an object, the default value is returned instead.
Definition at line 485 of file qmjsonvalue.cpp.
const T & QMJsonValue::to | ( | const T & | defaultValue | ) | const |
Unwraps the JSON value and returns the interanl type. If the interal type is not of type T, the default value is returned instead. This function is ment to be used with custom, complex types as show below:
Definition at line 191 of file qmjsonvalue.h.
|
virtual |
Unwraps the JSON value and sets the interanl type. Depending on what type the JSON value is, will dictate what the internal type is set to:
Definition at line 495 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and sets the interanl type. Depending on what type the JSON value is, will dictate what the internal type is set to:
Definition at line 526 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and sets the interanl type. Depending on what type the JSON value is, will dictate what the internal type is set to:
Definition at line 554 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and sets the internal type to a QMJsonArray. If the internal type is not a QMJsonArray, the request is ignored
Definition at line 590 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and sets the internal type to a QMJsonObject. If the internal type is not a QMJsonObject, the request is ignored
Definition at line 614 of file qmjsonvalue.cpp.
|
virtual |
Unwraps the JSON value and sets the interanl type. Depending on what type the JSON value is, will dictate what the internal type is set to:
Definition at line 638 of file qmjsonvalue.cpp.
bool QMJsonValue::from | ( | const T & | value | ) |
Unwraps the JSON value and sets the interanl type. If the interal type is not of type T, the request is ignored. This function is ment to be used with custom, complex types as show below:
Definition at line 202 of file qmjsonvalue.h.
|
virtual |
A convenience function. The following two statements are equvilant:
Definition at line 673 of file qmjsonvalue.cpp.
|
virtual |
A convenience function. The following two statements are equvilant:
Definition at line 678 of file qmjsonvalue.cpp.
|
virtual |
Converts the JSON value to a Variant. QMJsonArrays and QMJsonObjects are converted into QVariantLists and QVariantHashs, and wrapped in a QVariant.
Definition at line 683 of file qmjsonvalue.cpp.
|
static |
Converts a QVariant into a QMJsonValue. QVariants can take on a lot of different types. Types that are not supported by this library return QVariant's default constructor.
Definition at line 727 of file qmjsonvalue.cpp.
|
virtual |
Returns the internal type for this QMJsonValue.
Definition at line 831 of file qmjsonvalue.cpp.
|
virtual |
Returns a string representation of the internal type for this QMJsonValue.
Definition at line 836 of file qmjsonvalue.cpp.
|
virtual |
Returns a string representation of this QMJsonValue. If QMJsonFormat_Optimized is provided, the returned string does not contain added whitespace or newlines. This function provides better performance when sort is set to QMJsonSort_None, however sorting is needed if you wish to compare the output of two JSON values.
Non-standard JSON types (i.e. complex types) are converted into their JSON equivalents using the toComplexJson and fromComplexJson template overloads. To see an exmaple of how this is done, see the template overloads withing the GUI portion of this library. Specificaly the overloads for QSize and QRect which demonstration coverting a complex type into native JSON (i.e. QSize) and converting a complex type into other complex types (i.e. QRect)
Definition at line 855 of file qmjsonvalue.cpp.
|
virtual |
Converts the QMJsonValue to a string and saves the results to filename. If the save fails, this function returns false, otherwise true.
Definition at line 896 of file qmjsonvalue.cpp.
|
static |
Converts the provided sting into the QMJsonValue equivlant.
If the provided string contains a JSON object that has a key named 'qmjsontype', QMJsonValue will attempt to convert the JSON object to it's complex type using the fromComplexJson function that was registered with registerFromComplexJson. If no fromComplexJson exists for the type defined by 'qmjsontype', or has not been registered, the JSON object will be treated as a standard JSON object.
Definition at line 910 of file qmjsonvalue.cpp.
|
static |
Read in the contents of filename, and converts the resulting sting into the QMJsonValue equivlant.
Definition at line 1078 of file qmjsonvalue.cpp.
|
static |
Registers a fromComplexJson function with the QMJsonValue class. When fromJson or fromJsonFile are called, fromComplexJson that are registered will be used to convert JSON objects that contain 'qmjsontype' into their complex equivlants.
Definition at line 964 of file qmjsonvalue.cpp.
|
signal |
|
friend |
Definition at line 52 of file qmjsonvalue.h.
|
friend |
Definition at line 1096 of file qmjsonvalue.cpp.