serializer.h | serializer.h | |||
---|---|---|---|---|
skipping to change at line 31 | skipping to change at line 31 | |||
#ifndef QJSON_SERIALIZER_H | #ifndef QJSON_SERIALIZER_H | |||
#define QJSON_SERIALIZER_H | #define QJSON_SERIALIZER_H | |||
#include "qjson_export.h" | #include "qjson_export.h" | |||
class QIODevice; | class QIODevice; | |||
class QString; | class QString; | |||
class QVariant; | class QVariant; | |||
namespace QJson { | namespace QJson { | |||
/** | ||||
* @brief Main class used for converting QVariant objects to JSON data. | ||||
* | ||||
* QVariant objects are converted to a string containing the JSON data. | ||||
* If QVariant object is empty or not valid a <em>null</em> json object is | ||||
returned. | ||||
*/ | ||||
class QJSON_EXPORT Serializer { | class QJSON_EXPORT Serializer { | |||
public: | public: | |||
Serializer(); | Serializer(); | |||
~Serializer(); | ~Serializer(); | |||
/** | /** | |||
* This method generates a textual JSON representation and outputs it to the | * This method generates a textual JSON representation and outputs it to the | |||
* passed in I/O Device. | * passed in I/O Device. | |||
* @param variant The JSON document in its in-memory representation as generated by the | * @param variant The JSON document in its in-memory representation as generated by the | |||
* parser. | * parser. | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 7 lines changed or added | |||
serializerrunnable.h | serializerrunnable.h | |||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
#include "qjson_export.h" | #include "qjson_export.h" | |||
#include <QtCore/QObject> | #include <QtCore/QObject> | |||
#include <QtCore/QRunnable> | #include <QtCore/QRunnable> | |||
class QByteArray; | class QByteArray; | |||
class QString; | class QString; | |||
class QVariant; | class QVariant; | |||
/** | namespace QJson { | |||
* @brief Convenience class for converting JSON data to QVariant objects usi | /** | |||
ng a dedicated thread | * @brief Convenience class for converting JSON data to QVariant objects u | |||
*/ | sing a dedicated thread | |||
class QJSON_EXPORT SerializerRunnable : public QObject, public QRunnable | */ | |||
{ | class QJSON_EXPORT SerializerRunnable : public QObject, public QRunnable | |||
Q_OBJECT | { | |||
public: | Q_OBJECT | |||
/** | public: | |||
* This signal is emitted when the conversion process has been completed | /** | |||
* @param data contains the JSON data that has to be converted | * This signal is emitted when the conversion process has been complet | |||
* @param parent parent of the object | ed | |||
**/ | * @param data contains the JSON data that has to be converted | |||
explicit SerializerRunnable(QObject* parent = 0); | * @param parent parent of the object | |||
~SerializerRunnable(); | **/ | |||
explicit SerializerRunnable(QObject* parent = 0); | ||||
~SerializerRunnable(); | ||||
/** | /** | |||
* Sets the json object to serialize. | * Sets the json object to serialize. | |||
* | * | |||
* @param json QVariant containing the json representation to be serial | * @param json QVariant containing the json representation to be seri | |||
ized | alized | |||
*/ | */ | |||
void setJsonObject( const QVariant& json ); | void setJsonObject( const QVariant& json ); | |||
/* reimp */ void run(); | /* reimp */ void run(); | |||
Q_SIGNALS: | Q_SIGNALS: | |||
/** | /** | |||
* This signal is emitted when the serialization process has been comple | * This signal is emitted when the serialization process has been comp | |||
ted | leted | |||
* @param serialized contains the result of the serialization | * @param serialized contains the result of the serialization | |||
* @param ok if a serialization error occurs ok is set to false, otherwi | * @param ok if a serialization error occurs ok is set to false, other | |||
se it's set to true. | wise it's set to true. | |||
* @param error_msg contains a string explaining the failure reason | * @param error_msg contains a string explaining the failure reason | |||
**/ | **/ | |||
void parsingFinished(const QByteArray& serialized, bool ok, const QStri | void parsingFinished(const QByteArray& serialized, bool ok, const QSt | |||
ng& error_msg); | ring& error_msg); | |||
private: | private: | |||
Q_DISABLE_COPY(SerializerRunnable) | Q_DISABLE_COPY(SerializerRunnable) | |||
class Private; | class Private; | |||
Private* const d; | Private* const d; | |||
}; | }; | |||
} | ||||
#endif // SERIALIZERRUNNABLE_H | #endif // SERIALIZERRUNNABLE_H | |||
End of changes. 5 change blocks. | ||||
39 lines changed or deleted | 42 lines changed or added | |||