Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
json.h
Go to the documentation of this file.
1/* Copyright 2011 Eeli Reilin. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 *
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 *
9 * 2. Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
16 * EVENT SHALL EELI REILIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
19 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
22 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation
25 * are those of the authors and should not be interpreted as representing
26 * official policies, either expressed or implied, of Eeli Reilin.
27 */
28
32
33#ifndef JSON_H
34#define JSON_H
35
36#include <QVariant>
37#include <QString>
38
39namespace QtJson
40{
41
60
67class Json
68{
69 public:
75 static QVariant parse(const QString &json);
76
83 static QVariant parse(const QString &json, bool &success);
84
91 static QByteArray serialize(const QVariant &data);
92
101 static QByteArray serialize(const QVariant &data, bool &success);
102
103 private:
113 static QVariant parseValue(const QString &json, int &index,
114 bool &success);
115
125 static QVariant parseObject(const QString &json, int &index,
126 bool &success);
127
137 static QVariant parseArray(const QString &json, int &index,
138 bool &success);
139
149 static QVariant parseString(const QString &json, int &index,
150 bool &success);
151
160 static QVariant parseNumber(const QString &json, int &index);
161
170 static int lastIndexOfNumber(const QString &json, int index);
171
178 static void eatWhitespace(const QString &json, int &index);
179
188 static int lookAhead(const QString &json, int index);
189
198 static int nextToken(const QString &json, int &index);
199};
200
201
202} //end namespace
203
204#endif //JSON_H
A JSON data parser.
Definition json.h:68
static QVariant parseValue(const QString &json, int &index, bool &success)
Definition json.cpp:237
static QByteArray serialize(const QVariant &data)
Definition json.cpp:97
static QVariant parseNumber(const QString &json, int &index)
Definition json.cpp:439
static void eatWhitespace(const QString &json, int &index)
Definition json.cpp:480
static QVariant parseObject(const QString &json, int &index, bool &success)
Definition json.cpp:271
static QVariant parseArray(const QString &json, int &index, bool &success)
Definition json.cpp:330
static QVariant parse(const QString &json)
Definition json.cpp:68
static int lastIndexOfNumber(const QString &json, int index)
Definition json.cpp:463
static int lookAhead(const QString &json, int index)
Definition json.cpp:493
static QVariant parseString(const QString &json, int &index, bool &success)
Definition json.cpp:365
static int nextToken(const QString &json, int &index)
Definition json.cpp:502
Definition json.cpp:39
JsonToken
Definition json.h:46
@ JsonTokenNull
Definition json.h:58
@ JsonTokenString
Definition json.h:54
@ JsonTokenCurlyOpen
Definition json.h:48
@ JsonTokenSquaredOpen
Definition json.h:50
@ JsonTokenFalse
Definition json.h:57
@ JsonTokenTrue
Definition json.h:56
@ JsonTokenNumber
Definition json.h:55
@ JsonTokenSquaredClose
Definition json.h:51
@ JsonTokenCurlyClose
Definition json.h:49
@ JsonTokenNone
Definition json.h:47
@ JsonTokenColon
Definition json.h:52
@ JsonTokenComma
Definition json.h:53