libqutim 0.3.1.0
json.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** qutIM - instant messenger
00004 **
00005 ** Copyright © 2011 Ketmar // Avalon Group <psyc://ketmar.no-ip.org/~Ketmar>
00006 **
00007 *****************************************************************************
00008 **
00009 ** $QUTIM_BEGIN_LICENSE$
00010 ** This program is free software: you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation, either version 3 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 ** See the GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program.  If not, see http://www.gnu.org/licenses/.
00022 ** $QUTIM_END_LICENSE$
00023 **
00024 ****************************************************************************/
00025 
00026 #ifndef K8JSON_QUTIM_H
00027 #define K8JSON_QUTIM_H
00028 
00029 #include "libqutim_global.h"
00030 
00031 #include <QString>
00032 #include <QVariant>
00033 #include <QByteArray>
00034 class QObject;
00035 
00036 namespace qutim_sdk_0_3
00037 {
00044     namespace Json
00045     {
00046         // High level api
00052         LIBQUTIM_EXPORT QString quote(const QString &str);
00058         LIBQUTIM_EXPORT QVariant parse(const QByteArray &data);
00064         LIBQUTIM_EXPORT void parseToProperties(const QByteArray &json, QObject *obj);
00071         LIBQUTIM_EXPORT QByteArray generate(const QVariant &data, int indent = 0);
00072 
00073         // Low level api
00082         LIBQUTIM_EXPORT bool isValidUtf8(const uchar *s, int maxLen, bool zeroInvalid = false);
00086         LIBQUTIM_EXPORT bool isValidUtf8(const QByteArray &data, bool zeroInvalid = false);
00090         LIBQUTIM_EXPORT bool isValidUtf8(const  char *s, int maxLen, bool zeroInvalid = false);
00091 
00100         LIBQUTIM_EXPORT const uchar *skipBlanks(const uchar *s, int *maxLength);
00104         LIBQUTIM_EXPORT const  char *skipBlanks(const  char *s, int *maxLength);
00105 
00113         LIBQUTIM_EXPORT const uchar *skipRecord(const uchar *s, int *maxLength);
00117         LIBQUTIM_EXPORT const  char *skipRecord(const  char *s, int *maxLength);
00118 
00126         LIBQUTIM_EXPORT const uchar *parseValue(QVariant &fvalue, const uchar *s, int *maxLength);
00130         LIBQUTIM_EXPORT const  char *parseValue(QVariant &fvalue, const  char *s, int *maxLength);
00131 
00140         LIBQUTIM_EXPORT const uchar *parseField(QString &fname, QVariant &fvalue, const uchar *s,
00141                                                 int *maxLength);
00145         LIBQUTIM_EXPORT const  char *parseField(QString &fname, QVariant &fvalue, const  char *s,
00146                                                 int *maxLength);
00147 
00155         LIBQUTIM_EXPORT const uchar *parseRecord(QVariant &res, const uchar *s, int *maxLength);
00159         LIBQUTIM_EXPORT const  char *parseRecord(QVariant &res, const  char *s, int *maxLength);
00160 
00161         typedef bool(*generatorExt)(QString &err, QByteArray &res, const QVariant &val, int indent);
00162 
00163         LIBQUTIM_EXPORT bool generate(QByteArray &res, const QVariant &val, int indent = 0,
00164                                       generatorExt cb = 0, QString *err = 0);
00165 
00166         LIBQUTIM_EXPORT bool generate(QByteArray &res, const QVariant &val, int indent, QString *err);
00167     }
00168 }
00169 
00170 #endif // K8JSON_QUTIM_H
00171