QJson home page
serializer.h
1 /* This file is part of qjson
2  *
3  * Copyright (C) 2009 Till Adam <adam@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License version 2.1, as published by the Free Software Foundation.
8  *
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef QJSON_SERIALIZER_H
22 #define QJSON_SERIALIZER_H
23 
24 #include "qjson_export.h"
25 
26 class QIODevice;
27 class QString;
28 class QVariant;
29 
30 namespace QJson {
62  enum IndentMode {
63  IndentNone,
64  IndentCompact,
65  IndentMinimum,
66  IndentMedium,
67  IndentFull
68  };
110  class QJSON_EXPORT Serializer {
111  public:
112  Serializer();
113  ~Serializer();
114 
123  void serialize( const QVariant& variant, QIODevice* out, bool* ok);
124 
136  QByteArray serialize( const QVariant& variant);
137 
148  QByteArray serialize( const QVariant& variant, bool *ok);
149 
153  void allowSpecialNumbers(bool allow);
154 
158  bool specialNumbersAllowed() const;
159 
163  void setIndentMode(IndentMode mode = QJson::IndentNone);
164 
165 
170  void setDoublePrecision(int precision);
171 
175  IndentMode indentMode() const;
176 
180  QString errorMessage() const;
181 
182  private:
183  Q_DISABLE_COPY(Serializer)
184  class SerializerPrivate;
185  SerializerPrivate* const d;
186  };
187 }
188 
189 #endif // QJSON_SERIALIZER_H

SourceForge Logo hosts this site. Send comments to:
QJson Developers