parser.h   parser.h 
/* This file is part of QJson /* This file is part of QJson
* *
* Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com> * Copyright (C) 2008 Flavio Castelli <flavio.castelli@gmail.com>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License version 2.1, as published by the Free Software Foundation.
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef QJSON_PARSER_H #ifndef QJSON_PARSER_H
#define QJSON_PARSER_H #define QJSON_PARSER_H
#include "qjson_export.h" #include "qjson_export.h"
class QIODevice; class QIODevice;
class QVariant; class QVariant;
/**
* Namespace used by QJson
*/
namespace QJson { namespace QJson {
class ParserPrivate; class ParserPrivate;
/** /**
* @brief Main class used to convert JSON data to QVariant objects * @brief Main class used to convert JSON data to QVariant objects
*/ */
class QJSON_EXPORT Parser class QJSON_EXPORT Parser
{ {
public: public:
Parser(); Parser();
~Parser(); ~Parser();
/** /**
* Read JSON string from the I/O Device and converts it to a QVariant object * Read JSON string from the I/O Device and converts it to a QVariant object
* @param io Input output device * @param io Input output device
* @param ok if a conversion error occurs, *ok is set to false; otherw ise *ok is set to true. * @param ok if a conversion error occurs, *ok is set to false; otherw ise *ok is set to true.
skipping to change at line 74 skipping to change at line 77
*/ */
QString errorString() const; QString errorString() const;
/** /**
* This method returns line number where the error occurred * This method returns line number where the error occurred
* @returns the line number where the error occurred * @returns the line number where the error occurred
* @sa errorString * @sa errorString
*/ */
int errorLine() const; int errorLine() const;
/**
* Sets whether special numbers (Infinity, -Infinity, NaN) are allowe
d as an extension to
* the standard
* @param allowSpecialNumbers new value of whether special numbers a
re allowed
* @sa specialNumbersAllowed
*/
void allowSpecialNumbers(bool allowSpecialNumbers);
/**
* @returns whether special numbers (Infinity, -Infinity, NaN) are al
lowed
* @sa allowSpecialNumbers
*/
bool specialNumbersAllowed() const;
private: private:
Q_DISABLE_COPY(Parser) Q_DISABLE_COPY(Parser)
ParserPrivate* const d; ParserPrivate* const d;
}; };
} }
#endif // QJSON_PARSER_H #endif // QJSON_PARSER_H
 End of changes. 6 change blocks. 
7 lines changed or deleted 27 lines changed or added


 parserrunnable.h   parserrunnable.h 
/* This file is part of qjson /* This file is part of qjson
* *
* Copyright (C) 2009 Flavio Castelli <flavio@castelli.name> * Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License version 2.1, as published by the Free Software Foundation.
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licen se * You should have received a copy of the GNU Lesser General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef PARSERRUNNABLE_H #ifndef PARSERRUNNABLE_H
#define PARSERRUNNABLE_H #define PARSERRUNNABLE_H
#include "qjson_export.h" #include "qjson_export.h"
skipping to change at line 39 skipping to change at line 39
class QVariant; class QVariant;
namespace QJson { namespace QJson {
/** /**
* @brief Convenience class for converting JSON data to QVariant objects u sing a dedicated thread * @brief Convenience class for converting JSON data to QVariant objects u sing a dedicated thread
*/ */
class QJSON_EXPORT ParserRunnable : public QObject, public QRunnable class QJSON_EXPORT ParserRunnable : public QObject, public QRunnable
{ {
Q_OBJECT Q_OBJECT
public: public:
/**
* This signal is emitted when the conversion process has been complet
ed
* @param data contains the JSON data that has to be converted
* @param parent parent of the object
**/
explicit ParserRunnable(QObject* parent = 0); explicit ParserRunnable(QObject* parent = 0);
~ParserRunnable(); ~ParserRunnable();
void setData( const QByteArray& data ); void setData( const QByteArray& data );
void run(); void run();
Q_SIGNALS: Q_SIGNALS:
/** /**
* This signal is emitted when the parsing process has been completed * This signal is emitted when the parsing process has been completed
 End of changes. 4 change blocks. 
11 lines changed or deleted 5 lines changed or added


 qjson_export.h   qjson_export.h 
/* This file is part of the KDE project /* This file is part of the KDE project
Copyright (C) 2009 Pino Toscano <pino@kde.org> Copyright (C) 2009 Pino Toscano <pino@kde.org>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License version 2.1, as published by the Free Software Foundation.
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Library General Public Licen se You should have received a copy of the GNU Lesser General Public Licens e
along with this library; see the file COPYING.LIB. If not, write to along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. Boston, MA 02110-1301, USA.
*/ */
#ifndef QJSON_EXPORT_H #ifndef QJSON_EXPORT_H
#define QJSON_EXPORT_H #define QJSON_EXPORT_H
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
 End of changes. 3 change blocks. 
5 lines changed or deleted 4 lines changed or added


 qobjecthelper.h   qobjecthelper.h 
/* This file is part of qjson /* This file is part of qjson
* *
* Copyright (C) 2009 Flavio Castelli <flavio@castelli.name> * Copyright (C) 2009 Flavio Castelli <flavio@castelli.name>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License version 2.1, as published by the Free Software Foundation.
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licen se * You should have received a copy of the GNU Lesser General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef QOBJECTHELPER_H #ifndef QOBJECTHELPER_H
#define QOBJECTHELPER_H #define QOBJECTHELPER_H
#include "qjson_export.h" #include "qjson_export.h"
skipping to change at line 37 skipping to change at line 37
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtCore/QVariantMap> #include <QtCore/QVariantMap>
class QObject; class QObject;
namespace QJson { namespace QJson {
/** /**
* @brief Class used to convert QObject into QVariant and vivce-versa. * @brief Class used to convert QObject into QVariant and vivce-versa.
* During these operations only the class attributes defined as properties will * During these operations only the class attributes defined as properties will
* be considered. * be considered.
* Properties marked as 'non-stored' will be ignored.
* *
* Suppose the declaration of the Person class looks like this: * Suppose the declaration of the Person class looks like this:
* \code * \code
* class Person : public QObject * class Person : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber) Q_PROPERTY(int phoneNumber READ phoneNumber WRITE setPhoneNumber)
Q_PROPERTY(Gender gender READ gender WRITE setGender) Q_PROPERTY(Gender gender READ gender WRITE setGender)
skipping to change at line 132 skipping to change at line 133
* *
* @param object The QObject instance to be converted. * @param object The QObject instance to be converted.
* @param ignoredProperties Properties that won't be converted. * @param ignoredProperties Properties that won't be converted.
*/ */
static QVariantMap qobject2qvariant( const QObject* object, static QVariantMap qobject2qvariant( const QObject* object,
const QStringList& ignoredProperties = QS tringList(QString(QLatin1String("objectName")))); const QStringList& ignoredProperties = QS tringList(QString(QLatin1String("objectName"))));
/** /**
* This method converts a QVariantMap instance into a QObject * This method converts a QVariantMap instance into a QObject
* *
* @param object The QObject instance to be converted. * @param variant Attributes to assign to the object.
* @param object The QObject instance to update.
*/ */
static void qvariant2qobject(const QVariantMap& variant, QObject* objec t); static void qvariant2qobject(const QVariantMap& variant, QObject* objec t);
private: private:
Q_DISABLE_COPY(QObjectHelper) Q_DISABLE_COPY(QObjectHelper)
class QObjectHelperPrivate; class QObjectHelperPrivate;
QObjectHelperPrivate* const d; QObjectHelperPrivate* const d;
}; };
} }
 End of changes. 5 change blocks. 
6 lines changed or deleted 8 lines changed or added


 serializer.h   serializer.h 
/* This file is part of qjson /* This file is part of qjson
* *
* Copyright (C) 2009 Till Adam <adam@kde.org> * Copyright (C) 2009 Till Adam <adam@kde.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License version 2.1, as published by the Free Software Foundation.
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licen se * You should have received a copy of the GNU Lesser General Public Licens e
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#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 How the indentation should work.
\verbatim
none (default) : { "foo" : 0, "foo1" : 1, "foo2" : [ { "foo3" : 3, "foo4
" : 4 } ] }
compact : {"foo":0,"foo1":1,"foo2":[{"foo3":3,"foo4":4}]}
minimum : { "foo" : 0, "foo1" : 1, "foo2" : [
{ "foo3" : 3, "foo4" : 4 }
] }
medium : {
"foo" : 0, "foo1" : 1, "foo2" : [
{
"foo3" : 3, "foo4" : 4
}
]
}
full : {
"foo" : 0,
"foo1" : 1,
"foo2" : [
{
"foo3" : 3,
"foo4" : 4
}
]
}
\endverbatim
*/
enum IndentMode {
IndentNone,
IndentCompact,
IndentMinimum,
IndentMedium,
IndentFull
};
/**
* @brief Main class used to convert QVariant objects to JSON data. * @brief Main class used to convert QVariant objects to JSON data.
* *
* QVariant objects are converted to a string containing the 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. *
* Usage:
*
* \code
* QVariantList people;
*
* QVariantMap bob;
* bob.insert("Name", "Bob");
* bob.insert("Phonenumber", 123);
*
* QVariantMap alice;
* alice.insert("Name", "Alice");
* alice.insert("Phonenumber", 321);
*
* people << bob << alice;
*
* QJson::Serializer serializer;
* bool ok;
* QByteArray json = serializer.serialize(people, &ok);
*
* if (ok) {
* qDebug() << json;
* } else {
* qCritical() << "Something went wrong:" << serializer.errorMessage();
* }
* \endcode
*
* The output will be:
*
* \code
* "[ { "Name" : "Bob", "Phonenumber" : 123 },
* { "Name" : "Alice", "Phonenumber" : 321 } ]"
* \endcode
*
* It's possible to tune the indentation level of the resulting string. \s
a setIndentMode
*/ */
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.
* @param out Input output device * @param out Input output device
* @param ok if a conversion error occurs, *ok is set to false; otherw ise *ok is set to true * @param ok if a conversion error occurs, *ok is set to false; otherw ise *ok is set to true
*/ */
void serialize( const QVariant& variant, QIODevice* out, bool* ok = 0 ) ; void serialize( const QVariant& variant, QIODevice* out, bool* ok);
/** /**
* This is a method provided for convenience. It turns the passed in i n-memory * This is a method provided for convenience. It turns the passed in i n-memory
* representation of the JSON document into a textual one, which is re turned. * representation of the JSON document into a textual one, which is re turned.
* If the returned string is empty, the document was empty. If it was null, there * If the returned string is empty, the document was empty. If it was null, there
* was a parsing error. * was a parsing error.
* *
* @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.
* @param ok if a conversion error occurs, *ok is set to false; otherw ise *ok is set to true
*/ */
QByteArray serialize( const QVariant& variant, bool *ok = 0);
/**
* Allow or disallow writing of NaN and/or Infinity (as an extension to
QJson)
*/
void allowSpecialNumbers(bool allow);
/**
* Is Nan and/or Infinity allowed?
*/
bool specialNumbersAllowed() const;
QByteArray serialize( const QVariant& variant ); /**
* set output indentation mode as defined in QJson::IndentMode
*/
void setIndentMode(IndentMode mode = QJson::IndentNone);
/**
* set double precision used while converting Double
* \sa QByteArray::number
*/
void setDoublePrecision(int precision);
/**
* Returns one of the indentation modes defined in QJson::IndentMode
*/
IndentMode indentMode() const;
/**
* Returns the error message
*/
QString errorMessage() const;
private: private:
Q_DISABLE_COPY(Serializer) Q_DISABLE_COPY(Serializer)
class SerializerPrivate; class SerializerPrivate;
SerializerPrivate* const d; SerializerPrivate* const d;
}; };
} }
#endif // QJSON_SERIALIZER_H #endif // QJSON_SERIALIZER_H
 End of changes. 9 change blocks. 
9 lines changed or deleted 115 lines changed or added


 serializerrunnable.h   serializerrunnable.h 
/* This file is part of qjson /* This file is part of qjson
* *
* Copyright (C) 2009 Frank Osterfeld <osterfeld@kde.org> * Copyright (C) 2009 Frank Osterfeld <osterfeld@kde.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License version 2.1, as published by the Free Software Foundation.
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public Licens e * You should have received a copy of the GNU Lesser General Public License
* along with this library; see the file COPYING.LIB. If not, write to * along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
#ifndef SERIALIZERRUNNABLE_H #ifndef SERIALIZERRUNNABLE_H
#define SERIALIZERRUNNABLE_H #define SERIALIZERRUNNABLE_H
#include "qjson_export.h" #include "qjson_export.h"
skipping to change at line 41 skipping to change at line 41
class QVariant; class QVariant;
namespace QJson { namespace QJson {
/** /**
* @brief Convenience class for converting JSON data to QVariant objects u sing 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 Q_OBJECT
public: public:
/**
* This signal is emitted when the conversion process has been complet
ed
* @param data contains the JSON data that has to be converted
* @param parent parent of the object
**/
explicit SerializerRunnable(QObject* parent = 0); explicit SerializerRunnable(QObject* parent = 0);
~SerializerRunnable(); ~SerializerRunnable();
/** /**
* Sets the json object to serialize. * Sets the json object to serialize.
* *
* @param json QVariant containing the json representation to be seri alized * @param json QVariant containing the json representation to be seri alized
*/ */
void setJsonObject( const QVariant& json ); void setJsonObject( const QVariant& json );
 End of changes. 4 change blocks. 
11 lines changed or deleted 5 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/