X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=thirdparty%2Fqjson%2Fserializer.h;fp=thirdparty%2Fqjson%2Fserializer.h;h=66b349cf7e5ac226f7a33d369c43328c1439aee5;hb=0094c61568bff9f9dd7bafb711f111698e683831;hp=fd301b21c052a4df8c8eaa4b7d97a8d3b3097aad;hpb=c391265484ecb3baa2a00c80658c99ad65963ec6;p=apitrace diff --git a/thirdparty/qjson/serializer.h b/thirdparty/qjson/serializer.h index fd301b2..66b349c 100644 --- a/thirdparty/qjson/serializer.h +++ b/thirdparty/qjson/serializer.h @@ -3,16 +3,16 @@ * Copyright (C) 2009 Till Adam * * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * 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 License + * 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 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. @@ -28,6 +28,42 @@ class QString; class QVariant; namespace QJson { + /** + * @brief How the indentation should work. + * + * 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 + * } + * ] + * } + */ + enum IndentMode { + IndentNone, + IndentCompact, + IndentMinimum, + IndentMedium, + IndentFull + }; /** * @brief Main class used to convert QVariant objects to JSON data. * @@ -47,7 +83,7 @@ namespace QJson { * @param out Input output device * @param ok if a conversion error occurs, *ok is set to false; otherwise *ok is set to true */ - void serialize( const QVariant& variant, QIODevice* out, bool* ok = 0 ); + void serialize( const QVariant& variant, QIODevice* out, bool* ok = 0); /** * This is a method provided for convenience. It turns the passed in in-memory @@ -59,7 +95,34 @@ namespace QJson { * parser. */ - QByteArray serialize( const QVariant& variant ); + QByteArray serialize( const QVariant& variant); + + /** + * 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; + + /** + * 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; private: Q_DISABLE_COPY(Serializer)