1 /* This file is part of qjson
3 * Copyright (C) 2009 Frank Osterfeld <osterfeld@kde.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License version 2.1, as published by the Free Software Foundation.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef SERIALIZERRUNNABLE_H
22 #define SERIALIZERRUNNABLE_H
24 #include "qjson_export.h"
26 #include <QtCore/QObject>
27 #include <QtCore/QRunnable>
35 * @brief Convenience class for converting JSON data to QVariant objects using a dedicated thread
37 class QJSON_EXPORT SerializerRunnable : public QObject, public QRunnable
42 * This signal is emitted when the conversion process has been completed
43 * @param data contains the JSON data that has to be converted
44 * @param parent parent of the object
46 explicit SerializerRunnable(QObject* parent = 0);
47 ~SerializerRunnable();
50 * Sets the json object to serialize.
52 * @param json QVariant containing the json representation to be serialized
54 void setJsonObject( const QVariant& json );
56 /* reimp */ void run();
60 * This signal is emitted when the serialization process has been completed
61 * @param serialized contains the result of the serialization
62 * @param ok if a serialization error occurs ok is set to false, otherwise it's set to true.
63 * @param error_msg contains a string explaining the failure reason
65 void parsingFinished(const QByteArray& serialized, bool ok, const QString& error_msg);
68 Q_DISABLE_COPY(SerializerRunnable)
74 #endif // SERIALIZERRUNNABLE_H