qjsonvalue.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/json/qjsonvalue.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtCore module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include <qjsonobject.h>-
41#include <qjsonvalue.h>-
42#include <qjsonarray.h>-
43#include <qvariant.h>-
44#include <qstringlist.h>-
45#include <qdebug.h>-
46-
47#include "qjson_p.h"-
48-
49QT_BEGIN_NAMESPACE-
50-
51/*!-
52 \class QJsonValue-
53 \inmodule QtCore-
54 \ingroup json-
55 \ingroup shared-
56 \reentrant-
57 \since 5.0-
58-
59 \brief The QJsonValue class encapsulates a value in JSON.-
60-
61 A value in JSON can be one of 6 basic types:-
62-
63 JSON is a format to store structured data. It has 6 basic data types:-
64-
65 \list-
66 \li bool QJsonValue::Bool-
67 \li double QJsonValue::Double-
68 \li string QJsonValue::String-
69 \li array QJsonValue::Array-
70 \li object QJsonValue::Object-
71 \li null QJsonValue::Null-
72 \endlist-
73-
74 A value can represent any of the above data types. In addition, QJsonValue has one special-
75 flag to represent undefined values. This can be queried with isUndefined().-
76-
77 The type of the value can be queried with type() or accessors like isBool(), isString(), and so on.-
78 Likewise, the value can be converted to the type stored in it using the toBool(), toString() and so on.-
79-
80 Values are strictly typed internally and contrary to QVariant will not attempt to do any implicit type-
81 conversions. This implies that converting to a type that is not stored in the value will return a default-
82 constructed return value.-
83-
84 \section1 QJsonValueRef-
85-
86 QJsonValueRef is a helper class for QJsonArray and QJsonObject.-
87 When you get an object of type QJsonValueRef, you can-
88 use it as if it were a reference to a QJsonValue. If you assign to it,-
89 the assignment will apply to the element in the QJsonArray or QJsonObject-
90 from which you got the reference.-
91-
92 The following methods return QJsonValueRef:-
93 \list-
94 \li \l {QJsonArray}::operator[](int i)-
95 \li \l {QJsonObject}::operator[](const QString & key) const-
96 \endlist-
97-
98 \sa {JSON Support in Qt}, {JSON Save Game Example}-
99*/-
100-
101/*!-
102 Creates a QJsonValue of type \a type.-
103-
104 The default is to create a Null value.-
105 */-
106QJsonValue::QJsonValue(Type type)-
107 : ui(0), d(0), t(type)-
108{-
109}
executed 323 times by 7 tests: end of block
Executed by:
  • tst_QFactoryLoader
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QMetaType
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
  • tst_QVariant
323
110-
111/*!-
112 \internal-
113 */-
114QJsonValue::QJsonValue(QJsonPrivate::Data *data, QJsonPrivate::Base *base, const QJsonPrivate::Value &v)-
115 : d(0)-
116{-
117 t = (Type)(uint)v.type;-
118 switch (t) {-
119 case Undefined:
never executed: case Undefined:
0
120 case Null:
executed 1 time by 1 test: case Null:
Executed by:
  • tst_qmakelib
1
121 dbl = 0;-
122 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_qmakelib
1
123 case Bool:
executed 680 times by 112 tests: case Bool:
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
680
124 b = v.toBoolean();-
125 break;
executed 680 times by 112 tests: break;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
680
126 case Double:
executed 1634 times by 114 tests: case Double:
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
1634
127 dbl = v.toDouble(base);-
128 break;
executed 1634 times by 114 tests: break;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
1634
129 case String: {
executed 69773 times by 115 tests: case String:
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
69773
130 QString s = v.toString(base);-
131 stringData = s.data_ptr();-
132 stringData->ref.ref();-
133 break;
executed 69773 times by 115 tests: break;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
69773
134 }-
135 case Array:
executed 42000 times by 114 tests: case Array:
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
42000
136 case Object:
executed 42069 times by 115 tests: case Object:
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
42069
137 d = data;-
138 this->base = v.base(base);-
139 break;
executed 84069 times by 115 tests: break;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
84069
140 }-
141 if (d)
dDescription
TRUEevaluated 84069 times by 115 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
FALSEevaluated 72088 times by 117 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
72088-84069
142 d->ref.ref();
executed 84069 times by 115 tests: d->ref.ref();
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
84069
143}
executed 156157 times by 117 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
156157
144-
145/*!-
146 Creates a value of type Bool, with value \a b.-
147 */-
148QJsonValue::QJsonValue(bool b)-
149 : d(0), t(Bool)-
150{-
151 this->b = b;-
152}
executed 7 times by 2 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QVariant
7
153-
154/*!-
155 Creates a value of type Double, with value \a n.-
156 */-
157QJsonValue::QJsonValue(double n)-
158 : d(0), t(Double)-
159{-
160 this->dbl = n;-
161}
executed 8 times by 2 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QVariant
8
162-
163/*!-
164 \overload-
165 Creates a value of type Double, with value \a n.-
166 */-
167QJsonValue::QJsonValue(int n)-
168 : d(0), t(Double)-
169{-
170 this->dbl = n;-
171}
executed 5 times by 1 test: end of block
Executed by:
  • tst_QVariant
5
172-
173/*!-
174 \overload-
175 Creates a value of type Double, with value \a n.-
176 NOTE: the integer limits for IEEE 754 double precision data is 2^53 (-9007199254740992 to +9007199254740992).-
177 If you pass in values outside this range expect a loss of precision to occur.-
178 */-
179QJsonValue::QJsonValue(qint64 n)-
180 : d(0), t(Double)-
181{-
182 this->dbl = double(n);-
183}
never executed: end of block
0
184-
185/*!-
186 Creates a value of type String, with value \a s.-
187 */-
188QJsonValue::QJsonValue(const QString &s)-
189 : d(0), t(String)-
190{-
191 stringDataFromQStringHelper(s);-
192}
executed 3 times by 1 test: end of block
Executed by:
  • tst_QVariant
3
193-
194/*!-
195 \fn QJsonValue::QJsonValue(const char *s)-
196-
197 Creates a value of type String with value \a s, assuming-
198 UTF-8 encoding of the input.-
199-
200 You can disable this constructor by defining \c-
201 QT_NO_CAST_FROM_ASCII when you compile your applications.-
202-
203 \since 5.3-
204 */-
205-
206void QJsonValue::stringDataFromQStringHelper(const QString &string)-
207{-
208 stringData = *(QStringData **)(&string);-
209 stringData->ref.ref();-
210}
executed 33 times by 3 tests: end of block
Executed by:
  • tst_QGuiApplication
  • tst_QMetaType
  • tst_QVariant
33
211-
212/*!-
213 Creates a value of type String, with value \a s.-
214 */-
215QJsonValue::QJsonValue(QLatin1String s)-
216 : d(0), t(String)-
217{-
218 // ### FIXME: Avoid creating the temp QString below-
219 QString str(s);-
220 stringDataFromQStringHelper(str);-
221}
executed 30 times by 2 tests: end of block
Executed by:
  • tst_QGuiApplication
  • tst_QMetaType
30
222-
223/*!-
224 Creates a value of type Array, with value \a a.-
225 */-
226QJsonValue::QJsonValue(const QJsonArray &a)-
227 : d(a.d), t(Array)-
228{-
229 base = a.a;-
230 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
231 d->ref.ref();
never executed: d->ref.ref();
0
232}
never executed: end of block
0
233-
234/*!-
235 Creates a value of type Object, with value \a o.-
236 */-
237QJsonValue::QJsonValue(const QJsonObject &o)-
238 : d(o.d), t(Object)-
239{-
240 base = o.o;-
241 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
242 d->ref.ref();
never executed: d->ref.ref();
0
243}
never executed: end of block
0
244-
245-
246/*!-
247 Destroys the value.-
248 */-
249QJsonValue::~QJsonValue()-
250{-
251 if (t == String && stringData && !stringData->ref.deref())
t == StringDescription
TRUEevaluated 69823 times by 117 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
FALSEevaluated 86866 times by 119 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
stringDataDescription
TRUEevaluated 69823 times by 117 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
FALSEnever evaluated
!stringData->ref.deref()Description
TRUEevaluated 1826 times by 40 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QApplication
  • tst_QFtp
  • tst_QGuiApplication
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QOpenGlConfig
  • tst_QPrintDevice
  • tst_QPrinter
  • tst_QPrinterInfo
  • tst_QSql
  • ...
FALSEevaluated 67997 times by 116 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
0-86866
252 free(stringData);
executed 1826 times by 40 tests: free(stringData);
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QApplication
  • tst_QFtp
  • tst_QGuiApplication
  • tst_QHostInfo
  • tst_QHttpNetworkConnection
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QItemModel
  • tst_QMetaType
  • tst_QNetworkAccessManager
  • tst_QNetworkAccessManager_And_QProgressDialog
  • tst_QNetworkConfiguration
  • tst_QNetworkConfigurationManager
  • tst_QNetworkCookieJar
  • tst_QNetworkDiskCache
  • tst_QNetworkInterface
  • tst_QNetworkProxyFactory
  • tst_QOpenGlConfig
  • tst_QPrintDevice
  • tst_QPrinter
  • tst_QPrinterInfo
  • tst_QSql
  • ...
1826
253-
254 if (d && !d->ref.deref())
dDescription
TRUEevaluated 84174 times by 115 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
FALSEevaluated 72515 times by 119 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
!d->ref.deref()Description
TRUEnever evaluated
FALSEevaluated 84174 times by 115 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
0-84174
255 delete d;
never executed: delete d;
0
256}
executed 156689 times by 119 tests: end of block
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
156689
257-
258/*!-
259 Creates a copy of \a other.-
260 */-
261QJsonValue::QJsonValue(const QJsonValue &other)-
262{-
263 t = other.t;-
264 d = other.d;-
265 ui = other.ui;-
266 if (d)
dDescription
TRUEevaluated 105 times by 1 test
Evaluated by:
  • tst_QOpenGlConfig
FALSEevaluated 51 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QOpenGlConfig
  • tst_QVariant
51-105
267 d->ref.ref();
executed 105 times by 1 test: d->ref.ref();
Executed by:
  • tst_QOpenGlConfig
105
268-
269 if (t == String && stringData)
t == StringDescription
TRUEevaluated 17 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QOpenGlConfig
  • tst_QVariant
FALSEevaluated 139 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QOpenGlConfig
  • tst_QVariant
stringDataDescription
TRUEevaluated 17 times by 3 tests
Evaluated by:
  • tst_QMetaType
  • tst_QOpenGlConfig
  • tst_QVariant
FALSEnever evaluated
0-139
270 stringData->ref.ref();
executed 17 times by 3 tests: stringData->ref.ref();
Executed by:
  • tst_QMetaType
  • tst_QOpenGlConfig
  • tst_QVariant
17
271}
executed 156 times by 3 tests: end of block
Executed by:
  • tst_QMetaType
  • tst_QOpenGlConfig
  • tst_QVariant
156
272-
273/*!-
274 Assigns the value stored in \a other to this object.-
275 */-
276QJsonValue &QJsonValue::operator =(const QJsonValue &other)-
277{-
278 QJsonValue copy(other);-
279 // swap(copy);-
280 qSwap(dbl, copy.dbl);-
281 qSwap(d, copy.d);-
282 qSwap(t, copy.t);-
283 return *this;
executed 1 time by 1 test: return *this;
Executed by:
  • tst_QVariant
1
284}-
285-
286/*!-
287 \fn bool QJsonValue::isNull() const-
288-
289 Returns \c true if the value is null.-
290*/-
291-
292/*!-
293 \fn bool QJsonValue::isBool() const-
294-
295 Returns \c true if the value contains a boolean.-
296-
297 \sa toBool()-
298 */-
299-
300/*!-
301 \fn bool QJsonValue::isDouble() const-
302-
303 Returns \c true if the value contains a double.-
304-
305 \sa toDouble()-
306 */-
307-
308/*!-
309 \fn bool QJsonValue::isString() const-
310-
311 Returns \c true if the value contains a string.-
312-
313 \sa toString()-
314 */-
315-
316/*!-
317 \fn bool QJsonValue::isArray() const-
318-
319 Returns \c true if the value contains an array.-
320-
321 \sa toArray()-
322 */-
323-
324/*!-
325 \fn bool QJsonValue::isObject() const-
326-
327 Returns \c true if the value contains an object.-
328-
329 \sa toObject()-
330 */-
331-
332/*!-
333 \fn bool QJsonValue::isUndefined() const-
334-
335 Returns \c true if the value is undefined. This can happen in certain-
336 error cases as e.g. accessing a non existing key in a QJsonObject.-
337 */-
338-
339-
340/*!-
341 Converts \a variant to a QJsonValue and returns it.-
342-
343 The conversion will convert QVariant types as follows:-
344-
345 \table-
346 \header-
347 \li Source type-
348 \li Destination type-
349 \row-
350 \li-
351 \list-
352 \li QMetaType::Bool-
353 \endlist-
354 \li QJsonValue::Bool-
355 \row-
356 \li-
357 \list-
358 \li QMetaType::Int-
359 \li QMetaType::UInt-
360 \li QMetaType::LongLong-
361 \li QMetaType::ULongLong-
362 \li QMetaType::Float-
363 \li QMetaType::Double-
364 \endlist-
365 \li QJsonValue::Double-
366 \row-
367 \li-
368 \list-
369 \li QMetaType::QString-
370 \endlist-
371 \li QJsonValue::String-
372 \row-
373 \li-
374 \list-
375 \li QMetaType::QStringList-
376 \li QMetaType::QVariantList-
377 \endlist-
378 \li QJsonValue::Array-
379 \row-
380 \li-
381 \list-
382 \li QMetaType::QVariantMap-
383 \li QMetaType::QVariantHash-
384 \endlist-
385 \li QJsonValue::Object-
386 \endtable-
387-
388 For all other QVariant types a conversion to a QString will be attempted. If the returned string-
389 is empty, a Null QJsonValue will be stored, otherwise a String value using the returned QString.-
390-
391 \sa toVariant()-
392 */-
393QJsonValue QJsonValue::fromVariant(const QVariant &variant)-
394{-
395 switch (variant.userType()) {-
396 case QVariant::Bool:
never executed: case QVariant::Bool:
0
397 return QJsonValue(variant.toBool());
never executed: return QJsonValue(variant.toBool());
0
398 case QVariant::Int:
never executed: case QVariant::Int:
0
399 case QMetaType::Float:
never executed: case QMetaType::Float:
0
400 case QVariant::Double:
never executed: case QVariant::Double:
0
401 case QVariant::LongLong:
never executed: case QVariant::LongLong:
0
402 case QVariant::ULongLong:
never executed: case QVariant::ULongLong:
0
403 case QVariant::UInt:
never executed: case QVariant::UInt:
0
404 return QJsonValue(variant.toDouble());
never executed: return QJsonValue(variant.toDouble());
0
405 case QVariant::String:
never executed: case QVariant::String:
0
406 return QJsonValue(variant.toString());
never executed: return QJsonValue(variant.toString());
0
407 case QVariant::StringList:
never executed: case QVariant::StringList:
0
408 return QJsonValue(QJsonArray::fromStringList(variant.toStringList()));
never executed: return QJsonValue(QJsonArray::fromStringList(variant.toStringList()));
0
409 case QVariant::List:
never executed: case QVariant::List:
0
410 return QJsonValue(QJsonArray::fromVariantList(variant.toList()));
never executed: return QJsonValue(QJsonArray::fromVariantList(variant.toList()));
0
411 case QVariant::Map:
never executed: case QVariant::Map:
0
412 return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));
never executed: return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));
0
413 case QVariant::Hash:
never executed: case QVariant::Hash:
0
414 return QJsonValue(QJsonObject::fromVariantHash(variant.toHash()));
never executed: return QJsonValue(QJsonObject::fromVariantHash(variant.toHash()));
0
415#ifndef QT_BOOTSTRAPPED-
416 case QMetaType::QJsonValue:
never executed: case QMetaType::QJsonValue:
0
417 return variant.toJsonValue();
never executed: return variant.toJsonValue();
0
418 case QMetaType::QJsonObject:
never executed: case QMetaType::QJsonObject:
0
419 return variant.toJsonObject();
never executed: return variant.toJsonObject();
0
420 case QMetaType::QJsonArray:
never executed: case QMetaType::QJsonArray:
0
421 return variant.toJsonArray();
never executed: return variant.toJsonArray();
0
422 case QMetaType::QJsonDocument: {
never executed: case QMetaType::QJsonDocument:
0
423 QJsonDocument doc = variant.toJsonDocument();-
424 return doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object());
never executed: return doc.isArray() ? QJsonValue(doc.array()) : QJsonValue(doc.object());
0
425 }-
426#endif-
427 default:
never executed: default:
0
428 break;
never executed: break;
0
429 }-
430 QString string = variant.toString();-
431 if (string.isEmpty())
string.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
432 return QJsonValue();
never executed: return QJsonValue();
0
433 return QJsonValue(string);
never executed: return QJsonValue(string);
0
434}-
435-
436/*!-
437 Converts the value to a \l {QVariant::}{QVariant()}.-
438-
439 The QJsonValue types will be converted as follows:-
440-
441 \value Null \l {QVariant::}{QVariant()}-
442 \value Bool QMetaType::Bool-
443 \value Double QMetaType::Double-
444 \value String QString-
445 \value Array QVariantList-
446 \value Object QVariantMap-
447 \value Undefined \l {QVariant::}{QVariant()}-
448-
449 \sa fromVariant()-
450 */-
451QVariant QJsonValue::toVariant() const-
452{-
453 switch (t) {-
454 case Bool:
never executed: case Bool:
0
455 return b;
never executed: return b;
0
456 case Double:
never executed: case Double:
0
457 return dbl;
never executed: return dbl;
0
458 case String:
never executed: case String:
0
459 return toString();
never executed: return toString();
0
460 case Array:
never executed: case Array:
0
461 return d ?
never executed: return d ? QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() : QVariantList();
0
462 QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() :
never executed: return d ? QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() : QVariantList();
0
463 QVariantList();
never executed: return d ? QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)).toVariantList() : QVariantList();
0
464 case Object:
never executed: case Object:
0
465 return d ?
never executed: return d ? QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() : QVariantMap();
0
466 QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() :
never executed: return d ? QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() : QVariantMap();
0
467 QVariantMap();
never executed: return d ? QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() : QVariantMap();
0
468 case Null:
never executed: case Null:
0
469 case Undefined:
never executed: case Undefined:
0
470 break;
never executed: break;
0
471 }-
472 return QVariant();
never executed: return QVariant();
0
473}-
474-
475/*!-
476 \enum QJsonValue::Type-
477-
478 This enum describes the type of the JSON value.-
479-
480 \value Null A Null value-
481 \value Bool A boolean value. Use toBool() to convert to a bool.-
482 \value Double A double. Use toDouble() to convert to a double.-
483 \value String A string. Use toString() to convert to a QString.-
484 \value Array An array. Use toArray() to convert to a QJsonArray.-
485 \value Object An object. Use toObject() to convert to a QJsonObject.-
486 \value Undefined The value is undefined. This is usually returned as an-
487 error condition, when trying to read an out of bounds value-
488 in an array or a non existent key in an object.-
489*/-
490-
491/*!-
492 Returns the type of the value.-
493-
494 \sa QJsonValue::Type-
495 */-
496QJsonValue::Type QJsonValue::type() const-
497{-
498 return t;
executed 272 times by 3 tests: return t;
Executed by:
  • tst_QOpenGlConfig
  • tst_QVariant
  • tst_qmakelib
272
499}-
500-
501/*!-
502 Converts the value to a bool and returns it.-
503-
504 If type() is not bool, the \a defaultValue will be returned.-
505 */-
506bool QJsonValue::toBool(bool defaultValue) const-
507{-
508 if (t != Bool)
t != BoolDescription
TRUEnever evaluated
FALSEevaluated 682 times by 113 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
0-682
509 return defaultValue;
never executed: return defaultValue;
0
510 return b;
executed 682 times by 113 tests: return b;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
682
511}-
512-
513/*!-
514 Converts the value to an int and returns it.-
515-
516 If type() is not Double or the value is not a whole number,-
517 the \a defaultValue will be returned.-
518 */-
519int QJsonValue::toInt(int defaultValue) const-
520{-
521 if (t == Double && int(dbl) == dbl)
t == DoubleDescription
TRUEnever evaluated
FALSEnever evaluated
int(dbl) == dblDescription
TRUEnever evaluated
FALSEnever evaluated
0
522 return int(dbl);
never executed: return int(dbl);
0
523 return defaultValue;
never executed: return defaultValue;
0
524}-
525-
526/*!-
527 Converts the value to a double and returns it.-
528-
529 If type() is not Double, the \a defaultValue will be returned.-
530 */-
531double QJsonValue::toDouble(double defaultValue) const-
532{-
533 if (t != Double)
t != DoubleDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QVariant
FALSEevaluated 1640 times by 115 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
2-1640
534 return defaultValue;
executed 2 times by 1 test: return defaultValue;
Executed by:
  • tst_QVariant
2
535 return dbl;
executed 1640 times by 115 tests: return dbl;
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
1640
536}-
537-
538/*!-
539 Converts the value to a QString and returns it.-
540-
541 If type() is not String, the \a defaultValue will be returned.-
542 */-
543QString QJsonValue::toString(const QString &defaultValue) const-
544{-
545 if (t != String)
t != StringDescription
TRUEnever evaluated
FALSEnever evaluated
0
546 return defaultValue;
never executed: return defaultValue;
0
547 stringData->ref.ref(); // the constructor below doesn't add a ref.-
548 QStringDataPtr holder = { stringData };-
549 return QString(holder);
never executed: return QString(holder);
0
550}-
551-
552/*!-
553 Converts the value to a QString and returns it.-
554-
555 If type() is not String, a null QString will be returned.-
556-
557 \sa QString::isNull()-
558 */-
559QString QJsonValue::toString() const-
560{-
561 if (t != String)
t != StringDescription
TRUEevaluated 157 times by 3 tests
Evaluated by:
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QNetworkCookieJar
FALSEevaluated 69808 times by 117 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
157-69808
562 return QString();
executed 157 times by 3 tests: return QString();
Executed by:
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QNetworkCookieJar
157
563 stringData->ref.ref(); // the constructor below doesn't add a ref.-
564 QStringDataPtr holder = { stringData };-
565 return QString(holder);
executed 69808 times by 117 tests: return QString(holder);
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
69808
566}-
567-
568/*!-
569 Converts the value to an array and returns it.-
570-
571 If type() is not Array, the \a defaultValue will be returned.-
572 */-
573QJsonArray QJsonValue::toArray(const QJsonArray &defaultValue) const-
574{-
575 if (!d || t != Array)
!dDescription
TRUEevaluated 42 times by 2 tests
Evaluated by:
  • tst_QFactoryLoader
  • tst_QOpenGlConfig
FALSEevaluated 42000 times by 114 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
t != ArrayDescription
TRUEnever evaluated
FALSEevaluated 42000 times by 114 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
0-42000
576 return defaultValue;
executed 42 times by 2 tests: return defaultValue;
Executed by:
  • tst_QFactoryLoader
  • tst_QOpenGlConfig
42
577-
578 return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base));
executed 42000 times by 114 tests: return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base));
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
42000
579}-
580-
581/*!-
582 \overload-
583-
584 Converts the value to an array and returns it.-
585-
586 If type() is not Array, a \l{QJsonArray::}{QJsonArray()} will be returned.-
587 */-
588QJsonArray QJsonValue::toArray() const-
589{-
590 return toArray(QJsonArray());
executed 42042 times by 115 tests: return toArray(QJsonArray());
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
42042
591}-
592-
593/*!-
594 Converts the value to an object and returns it.-
595-
596 If type() is not Object, the \a defaultValue will be returned.-
597 */-
598QJsonObject QJsonValue::toObject(const QJsonObject &defaultValue) const-
599{-
600 if (!d || t != Object)
!dDescription
TRUEnever evaluated
FALSEevaluated 42019 times by 115 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
t != ObjectDescription
TRUEnever evaluated
FALSEevaluated 42019 times by 115 tests
Evaluated by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
0-42019
601 return defaultValue;
never executed: return defaultValue;
0
602-
603 return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base));
executed 42019 times by 115 tests: return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base));
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
42019
604}-
605-
606/*!-
607 \overload-
608-
609 Converts the value to an object and returns it.-
610-
611 If type() is not Object, the \l {QJsonObject::}{QJsonObject()} will be returned.-
612*/-
613QJsonObject QJsonValue::toObject() const-
614{-
615 return toObject(QJsonObject());
executed 42019 times by 115 tests: return toObject(QJsonObject());
Executed by:
  • tst_NetworkSelfTest
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAccessibility
  • tst_QApplication
  • tst_QBrush
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDataStream
  • tst_QDateTimeEdit
  • tst_QDialog
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • ...
42019
616}-
617-
618/*!-
619 Returns \c true if the value is equal to \a other.-
620 */-
621bool QJsonValue::operator==(const QJsonValue &other) const-
622{-
623 if (t != other.t)
t != other.tDescription
TRUEnever evaluated
FALSEevaluated 34 times by 2 tests
Evaluated by:
  • tst_QGuiApplication
  • tst_QMetaType
0-34
624 return false;
never executed: return false;
0
625-
626 switch (t) {-
627 case Undefined:
never executed: case Undefined:
0
628 case Null:
executed 4 times by 1 test: case Null:
Executed by:
  • tst_QMetaType
4
629 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_QMetaType
4
630 case Bool:
never executed: case Bool:
0
631 return b == other.b;
never executed: return b == other.b;
0
632 case Double:
executed 4 times by 1 test: case Double:
Executed by:
  • tst_QMetaType
4
633 return dbl == other.dbl;
executed 4 times by 1 test: return dbl == other.dbl;
Executed by:
  • tst_QMetaType
4
634 case String:
executed 26 times by 1 test: case String:
Executed by:
  • tst_QGuiApplication
26
635 return toString() == other.toString();
executed 26 times by 1 test: return toString() == other.toString();
Executed by:
  • tst_QGuiApplication
26
636 case Array:
never executed: case Array:
0
637 if (base == other.base)
base == other.baseDescription
TRUEnever evaluated
FALSEnever evaluated
0
638 return true;
never executed: return true;
0
639 if (!base)
!baseDescription
TRUEnever evaluated
FALSEnever evaluated
0
640 return !other.base->length;
never executed: return !other.base->length;
0
641 if (!other.base)
!other.baseDescription
TRUEnever evaluated
FALSEnever evaluated
0
642 return !base->length;
never executed: return !base->length;
0
643 return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base))
never executed: return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)) == QJsonArray(other.d, static_cast<QJsonPrivate::Array *>(other.base));
0
644 == QJsonArray(other.d, static_cast<QJsonPrivate::Array *>(other.base));
never executed: return QJsonArray(d, static_cast<QJsonPrivate::Array *>(base)) == QJsonArray(other.d, static_cast<QJsonPrivate::Array *>(other.base));
0
645 case Object:
never executed: case Object:
0
646 if (base == other.base)
base == other.baseDescription
TRUEnever evaluated
FALSEnever evaluated
0
647 return true;
never executed: return true;
0
648 if (!base)
!baseDescription
TRUEnever evaluated
FALSEnever evaluated
0
649 return !other.base->length;
never executed: return !other.base->length;
0
650 if (!other.base)
!other.baseDescription
TRUEnever evaluated
FALSEnever evaluated
0
651 return !base->length;
never executed: return !base->length;
0
652 return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base))
never executed: return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)) == QJsonObject(other.d, static_cast<QJsonPrivate::Object *>(other.base));
0
653 == QJsonObject(other.d, static_cast<QJsonPrivate::Object *>(other.base));
never executed: return QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)) == QJsonObject(other.d, static_cast<QJsonPrivate::Object *>(other.base));
0
654 }-
655 return true;
executed 4 times by 1 test: return true;
Executed by:
  • tst_QMetaType
4
656}-
657-
658/*!-
659 Returns \c true if the value is not equal to \a other.-
660 */-
661bool QJsonValue::operator!=(const QJsonValue &other) const-
662{-
663 return !(*this == other);
executed 26 times by 1 test: return !(*this == other);
Executed by:
  • tst_QGuiApplication
26
664}-
665-
666/*!-
667 \internal-
668 */-
669void QJsonValue::detach()-
670{-
671 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
672 return;
never executed: return;
0
673-
674 QJsonPrivate::Data *x = d->clone(base);-
675 x->ref.ref();-
676 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
677 delete d;
never executed: delete d;
0
678 d = x;-
679 base = static_cast<QJsonPrivate::Object *>(d->header->root());-
680}
never executed: end of block
0
681-
682-
683/*!-
684 \class QJsonValueRef-
685 \inmodule QtCore-
686 \reentrant-
687 \brief The QJsonValueRef class is a helper class for QJsonValue.-
688-
689 \internal-
690-
691 \ingroup json-
692-
693 When you get an object of type QJsonValueRef, if you can assign to it,-
694 the assignment will apply to the character in the string from-
695 which you got the reference. That is its whole purpose in life.-
696-
697 You can use it exactly in the same way as a reference to a QJsonValue.-
698-
699 The QJsonValueRef becomes invalid once modifications are made to the-
700 string: if you want to keep the character, copy it into a QJsonValue.-
701-
702 Most of the QJsonValue member functions also exist in QJsonValueRef.-
703 However, they are not explicitly documented here.-
704*/-
705-
706-
707QJsonValueRef &QJsonValueRef::operator =(const QJsonValue &val)-
708{-
709 if (is_object)
is_objectDescription
TRUEnever evaluated
FALSEnever evaluated
0
710 o->setValueAt(index, val);
never executed: o->setValueAt(index, val);
0
711 else-
712 a->replace(index, val);
never executed: a->replace(index, val);
0
713-
714 return *this;
never executed: return *this;
0
715}-
716-
717QJsonValueRef &QJsonValueRef::operator =(const QJsonValueRef &ref)-
718{-
719 if (is_object)
is_objectDescription
TRUEnever evaluated
FALSEnever evaluated
0
720 o->setValueAt(index, ref);
never executed: o->setValueAt(index, ref);
0
721 else-
722 a->replace(index, ref);
never executed: a->replace(index, ref);
0
723-
724 return *this;
never executed: return *this;
0
725}-
726-
727QVariant QJsonValueRef::toVariant() const-
728{-
729 return toValue().toVariant();
never executed: return toValue().toVariant();
0
730}-
731-
732QJsonArray QJsonValueRef::toArray() const-
733{-
734 return toValue().toArray();
never executed: return toValue().toArray();
0
735}-
736-
737QJsonObject QJsonValueRef::toObject() const-
738{-
739 return toValue().toObject();
never executed: return toValue().toObject();
0
740}-
741-
742QJsonValue QJsonValueRef::toValue() const-
743{-
744 if (!is_object)
!is_objectDescription
TRUEnever evaluated
FALSEnever evaluated
0
745 return a->at(index);
never executed: return a->at(index);
0
746 return o->valueAt(index);
never executed: return o->valueAt(index);
0
747}-
748-
749#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)-
750QDebug operator<<(QDebug dbg, const QJsonValue &o)-
751{-
752 QDebugStateSaver saver(dbg);-
753 switch (o.t) {-
754 case QJsonValue::Undefined:
never executed: case QJsonValue::Undefined:
0
755 dbg << "QJsonValue(undefined)";-
756 break;
never executed: break;
0
757 case QJsonValue::Null:
executed 1 time by 1 test: case QJsonValue::Null:
Executed by:
  • tst_QVariant
1
758 dbg << "QJsonValue(null)";-
759 break;
executed 1 time by 1 test: break;
Executed by:
  • tst_QVariant
1
760 case QJsonValue::Bool:
never executed: case QJsonValue::Bool:
0
761 dbg.nospace() << "QJsonValue(bool, " << o.toBool() << ')';-
762 break;
never executed: break;
0
763 case QJsonValue::Double:
never executed: case QJsonValue::Double:
0
764 dbg.nospace() << "QJsonValue(double, " << o.toDouble() << ')';-
765 break;
never executed: break;
0
766 case QJsonValue::String:
never executed: case QJsonValue::String:
0
767 dbg.nospace() << "QJsonValue(string, " << o.toString() << ')';-
768 break;
never executed: break;
0
769 case QJsonValue::Array:
never executed: case QJsonValue::Array:
0
770 dbg.nospace() << "QJsonValue(array, ";-
771 dbg << o.toArray();-
772 dbg << ')';-
773 break;
never executed: break;
0
774 case QJsonValue::Object:
never executed: case QJsonValue::Object:
0
775 dbg.nospace() << "QJsonValue(object, ";-
776 dbg << o.toObject();-
777 dbg << ')';-
778 break;
never executed: break;
0
779 }-
780 return dbg;
executed 1 time by 1 test: return dbg;
Executed by:
  • tst_QVariant
1
781}-
782#endif-
783-
784QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9