]> git.cworth.org Git - apitrace/blobdiff - thirdparty/qjson/serializer.h
Update bundled QJson
[apitrace] / thirdparty / qjson / serializer.h
index fd301b21c052a4df8c8eaa4b7d97a8d3b3097aad..66b349cf7e5ac226f7a33d369c43328c1439aee5 100644 (file)
@@ -3,16 +3,16 @@
   * Copyright (C) 2009 Till Adam <adam@kde.org>
   *
   * 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)