libqutim  0.3.1.0
qutim_sdk_0_3::Json Namespace Reference

Typedefs

typedef bool(* generatorExt )(QString &err, QByteArray &res, const QVariant &val, int indent)
 

Functions

Q_DECL_IMPORT QByteArray generate (const QVariant &data, int indent=0)
 
Q_DECL_IMPORT bool generate (QByteArray &res, const QVariant &val, int indent=0, generatorExt cb=0, QString *err=0)
 
Q_DECL_IMPORT bool generate (QByteArray &res, const QVariant &val, int indent, QString *err)
 
Q_DECL_IMPORT bool isValidUtf8 (const uchar *s, int maxLen, bool zeroInvalid=false)
 
Q_DECL_IMPORT bool isValidUtf8 (const QByteArray &data, bool zeroInvalid=false)
 
Q_DECL_IMPORT bool isValidUtf8 (const char *s, int maxLen, bool zeroInvalid=false)
 
Q_DECL_IMPORT QVariant parse (const QByteArray &data)
 
Q_DECL_IMPORT const uchar * parseField (QString &fname, QVariant &fvalue, const uchar *s, int *maxLength)
 
Q_DECL_IMPORT const char * parseField (QString &fname, QVariant &fvalue, const char *s, int *maxLength)
 
Q_DECL_IMPORT const uchar * parseRecord (QVariant &res, const uchar *s, int *maxLength)
 
Q_DECL_IMPORT const char * parseRecord (QVariant &res, const char *s, int *maxLength)
 
Q_DECL_IMPORT void parseToProperties (const QByteArray &json, QObject *obj)
 
Q_DECL_IMPORT const uchar * parseValue (QVariant &fvalue, const uchar *s, int *maxLength)
 
Q_DECL_IMPORT const char * parseValue (QVariant &fvalue, const char *s, int *maxLength)
 
Q_DECL_IMPORT QString quote (const QString &str)
 
Q_DECL_IMPORT const uchar * skipBlanks (const uchar *s, int *maxLength)
 
Q_DECL_IMPORT const char * skipBlanks (const char *s, int *maxLength)
 
Q_DECL_IMPORT const uchar * skipRecord (const uchar *s, int *maxLength)
 
Q_DECL_IMPORT const char * skipRecord (const char *s, int *maxLength)
 

Detailed Description

Namepsace provides both low and high levels for parsing and generating JavaScript Object Notations.

Note
Parser is able to work only with utf-8 strings for better perfomance

Typedef Documentation

typedef bool(* qutim_sdk_0_3::Json::generatorExt)(QString &err, QByteArray &res, const QVariant &val, int indent)

Function Documentation

Q_DECL_IMPORT QByteArray qutim_sdk_0_3::Json::generate ( const QVariant &  data,
int  indent = 0 
)

Generate JSON string from QVariant.

Parameters
dataQVariant with data
indentIdentation of new lines
Returns
JSON string with data
Q_DECL_IMPORT bool qutim_sdk_0_3::Json::generate ( QByteArray &  res,
const QVariant &  val,
int  indent = 0,
generatorExt  cb = 0,
QString *  err = 0 
)
Q_DECL_IMPORT bool qutim_sdk_0_3::Json::generate ( QByteArray &  res,
const QVariant &  val,
int  indent,
QString *  err 
)
Q_DECL_IMPORT bool qutim_sdk_0_3::Json::isValidUtf8 ( const uchar *  s,
int  maxLen,
bool  zeroInvalid = false 
)

Check if given string represents valid UTF-8 sequence.

Parameters
sString to be checked
maxLenMaximum length of string
zeroInvalidIf true check will be continued after finding null-symbol
Returns
True if input is not empty and is valid UTF-8 sequence
Q_DECL_IMPORT bool qutim_sdk_0_3::Json::isValidUtf8 ( const QByteArray &  data,
bool  zeroInvalid = false 
)

Convience fucntion for isValidUtf8.

Q_DECL_IMPORT bool qutim_sdk_0_3::Json::isValidUtf8 ( const char *  s,
int  maxLen,
bool  zeroInvalid = false 
)

Convience fucntion for isValidUtf8.

Q_DECL_IMPORT QVariant qutim_sdk_0_3::Json::parse ( const QByteArray &  data)

Parse JSON data to QVariant.

Parameters
dataString with JSON data
Returns
Result of parsing, QVariant::Null if there was an error
Q_DECL_IMPORT const uchar* qutim_sdk_0_3::Json::parseField ( QString &  fname,
QVariant &  fvalue,
const uchar *  s,
int *  maxLength 
)

Parse one field (field-value pair)

Parameters
fnameField's name
fvalueField's value
sString with JSON data
maxLengthString length, will be changed after skiping
Returns
Pointer to first non-blak char or null-pointer if error
Q_DECL_IMPORT const char* qutim_sdk_0_3::Json::parseField ( QString &  fname,
QVariant &  fvalue,
const char *  s,
int *  maxLength 
)

Convience fucntion for parseField.

Q_DECL_IMPORT const uchar* qutim_sdk_0_3::Json::parseRecord ( QVariant &  res,
const uchar *  s,
int *  maxLength 
)

Parse one record (list or object)

Parameters
resResult of parsing
sString with JSON data
maxLengthString length, will be changed after skiping
Returns
Pointer to first non-blak char or null-pointer if error
Q_DECL_IMPORT const char* qutim_sdk_0_3::Json::parseRecord ( QVariant &  res,
const char *  s,
int *  maxLength 
)

Convience fucntion for parseRecord.

Q_DECL_IMPORT void qutim_sdk_0_3::Json::parseToProperties ( const QByteArray &  json,
QObject *  obj 
)

Parse JSON data and put it's values to object as properties.

Parameters
jsonString with JSON data
objObject which properties will be changed to JSON's object
Q_DECL_IMPORT const uchar* qutim_sdk_0_3::Json::parseValue ( QVariant &  fvalue,
const uchar *  s,
int *  maxLength 
)

Parse field value.

Parameters
fvalueResult of parsing
sString with JSON data
maxLengthString length, will be changed after skiping
Returns
Pointer to first non-blak char after the value or null-pointer if error
Q_DECL_IMPORT const char* qutim_sdk_0_3::Json::parseValue ( QVariant &  fvalue,
const char *  s,
int *  maxLength 
)

Convience fucntion for parseValue.

Q_DECL_IMPORT QString qutim_sdk_0_3::Json::quote ( const QString &  str)

This function quotes string to Json friendly format and surronds it by quotes;.

Parameters
strString which would be quoted
Q_DECL_IMPORT const uchar* qutim_sdk_0_3::Json::skipBlanks ( const uchar *  s,
int *  maxLength 
)

Skip blanks and comments.

Parameters
sString with JSON data
maxLengthString length, will be changed after skiping
Returns
Pointer to first non-blak char or null-pointer if error
Note
Blank is any character with ansii-code lower or equal to space
Q_DECL_IMPORT const char* qutim_sdk_0_3::Json::skipBlanks ( const char *  s,
int *  maxLength 
)

Convience fucntion for skipBlanks.

Q_DECL_IMPORT const uchar* qutim_sdk_0_3::Json::skipRecord ( const uchar *  s,
int *  maxLength 
)

Skip one record.

The 'record' is either one full field (field: val) or one list/object.

Parameters
sString with JSON data
maxLengthString length, will be changed after skiping
Returns
Pointer to first non-blak char after the record or null-pointer if error
Q_DECL_IMPORT const char* qutim_sdk_0_3::Json::skipRecord ( const char *  s,
int *  maxLength 
)

Convience fucntion for skipRecord.


Generated by Doxygen