libqutim  0.3.1.0
json.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** qutIM - instant messenger
4 **
5 ** Copyright © 2011 Ketmar // Avalon Group <psyc://ketmar.no-ip.org/~Ketmar>
6 **
7 *****************************************************************************
8 **
9 ** $QUTIM_BEGIN_LICENSE$
10 ** This program is free software: you can redistribute it and/or modify
11 ** it under the terms of the GNU General Public License as published by
12 ** the Free Software Foundation, either version 3 of the License, or
13 ** (at your option) any later version.
14 **
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 ** See the GNU General Public License for more details.
19 **
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program. If not, see http://www.gnu.org/licenses/.
22 ** $QUTIM_END_LICENSE$
23 **
24 ****************************************************************************/
25 
26 #ifndef K8JSON_QUTIM_H
27 #define K8JSON_QUTIM_H
28 
29 #include "libqutim_global.h"
30 
31 #include <QString>
32 #include <QVariant>
33 #include <QByteArray>
34 class QObject;
35 
36 namespace qutim_sdk_0_3
37 {
44  namespace Json
45  {
46  // High level api
52  LIBQUTIM_EXPORT QString quote(const QString &str);
58  LIBQUTIM_EXPORT QVariant parse(const QByteArray &data);
64  LIBQUTIM_EXPORT void parseToProperties(const QByteArray &json, QObject *obj);
71  LIBQUTIM_EXPORT QByteArray generate(const QVariant &data, int indent = 0);
72 
73  // Low level api
82  LIBQUTIM_EXPORT bool isValidUtf8(const uchar *s, int maxLen, bool zeroInvalid = false);
86  LIBQUTIM_EXPORT bool isValidUtf8(const QByteArray &data, bool zeroInvalid = false);
90  LIBQUTIM_EXPORT bool isValidUtf8(const char *s, int maxLen, bool zeroInvalid = false);
91 
100  LIBQUTIM_EXPORT const uchar *skipBlanks(const uchar *s, int *maxLength);
104  LIBQUTIM_EXPORT const char *skipBlanks(const char *s, int *maxLength);
105 
113  LIBQUTIM_EXPORT const uchar *skipRecord(const uchar *s, int *maxLength);
117  LIBQUTIM_EXPORT const char *skipRecord(const char *s, int *maxLength);
118 
126  LIBQUTIM_EXPORT const uchar *parseValue(QVariant &fvalue, const uchar *s, int *maxLength);
130  LIBQUTIM_EXPORT const char *parseValue(QVariant &fvalue, const char *s, int *maxLength);
131 
140  LIBQUTIM_EXPORT const uchar *parseField(QString &fname, QVariant &fvalue, const uchar *s,
141  int *maxLength);
145  LIBQUTIM_EXPORT const char *parseField(QString &fname, QVariant &fvalue, const char *s,
146  int *maxLength);
147 
155  LIBQUTIM_EXPORT const uchar *parseRecord(QVariant &res, const uchar *s, int *maxLength);
159  LIBQUTIM_EXPORT const char *parseRecord(QVariant &res, const char *s, int *maxLength);
160 
161  typedef bool(*generatorExt)(QString &err, QByteArray &res, const QVariant &val, int indent);
162 
163  LIBQUTIM_EXPORT bool generate(QByteArray &res, const QVariant &val, int indent = 0,
164  generatorExt cb = 0, QString *err = 0);
165 
166  LIBQUTIM_EXPORT bool generate(QByteArray &res, const QVariant &val, int indent, QString *err);
167  }
168 }
169 
170 #endif // K8JSON_QUTIM_H
171 

Generated by Doxygen