qjsonobject.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/json/qjsonobject.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3QJsonObject::QJsonObject()-
4 : d(0), o(0)-
5{-
6}
executed 43512 times by 142 tests: end of block
Executed by:
  • tst_Lancelot
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • 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_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QDoubleSpinBox
  • tst_QFactoryLoader
  • tst_QFileDialog2
  • ...
43512
7QJsonObject::QJsonObject(QJsonPrivate::Data *data, QJsonPrivate::Object *object)-
8 : d(data), o(object)-
9{-
10 ((!(d)) ? qt_assert("d",__FILE__,131) : qt_noop());-
11 ((!(o)) ? qt_assert("o",__FILE__,132) : qt_noop());-
12 d->ref.ref();-
13}
executed 42688 times by 116 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
  • ...
42688
14void QJsonObject::initialize()-
15{-
16 d = 0;-
17 o = 0;-
18}
never executed: end of block
0
19-
20-
21-
22-
23QJsonObject::~QJsonObject()-
24{-
25 if (d
dDescription
TRUEevaluated 86845 times by 359 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 42758 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()
!d->ref.deref()Description
TRUEevaluated 3039 times by 249 tests
Evaluated by:
  • tst_QFactoryLoader
  • tst_QGuiApplication
  • tst_QMetaType
  • tst_QPluginLoader
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_qabstractbutton - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qabstractprintdialog - unknown status
  • tst_qabstractproxymodel - unknown status
  • tst_qabstractscrollarea - unknown status
  • tst_qabstractslider - unknown status
  • tst_qabstractspinbox - unknown status
  • tst_qabstracttextdocumentlayout - unknown status
  • tst_qaccessibility - unknown status
  • tst_qaction - unknown status
  • tst_qactiongroup - unknown status
  • tst_qapplication - unknown status
  • tst_qbackingstore - unknown status
  • tst_qboxlayout - unknown status
  • tst_qbrush - unknown status
  • ...
FALSEevaluated 83806 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
  • ...
)
3039-86845
26 delete d;
executed 3039 times by 249 tests: delete d;
Executed by:
  • tst_QFactoryLoader
  • tst_QGuiApplication
  • tst_QMetaType
  • tst_QPluginLoader
  • tst_gestures - unknown status
  • tst_lancelot - unknown status
  • tst_languagechange - unknown status
  • tst_modeltest - unknown status
  • tst_networkselftest - unknown status
  • tst_qabstractbutton - unknown status
  • tst_qabstractitemview - unknown status
  • tst_qabstractnetworkcache - unknown status
  • tst_qabstractprintdialog - unknown status
  • tst_qabstractproxymodel - unknown status
  • tst_qabstractscrollarea - unknown status
  • tst_qabstractslider - unknown status
  • tst_qabstractspinbox - unknown status
  • tst_qabstracttextdocumentlayout - unknown status
  • tst_qaccessibility - unknown status
  • tst_qaction - unknown status
  • tst_qactiongroup - unknown status
  • tst_qapplication - unknown status
  • tst_qbackingstore - unknown status
  • tst_qboxlayout - unknown status
  • tst_qbrush - unknown status
  • ...
3039
27}
executed 129603 times by 362 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
  • ...
129603
28-
29-
30-
31-
32-
33-
34-
35QJsonObject::QJsonObject(const QJsonObject &other)-
36{-
37 d = other.d;-
38 o = other.o;-
39 if (d
dDescription
TRUEevaluated 41144 times by 111 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
  • ...
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QVariant
)
3-41144
40 d->ref.ref();
executed 41144 times by 111 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_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
41144
41}
executed 41147 times by 112 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_QFileDialog2
  • tst_QFileIconProvider
  • tst_QFileSystemModel
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontComboBox
  • ...
41147
42-
43-
44-
45-
46QJsonObject &QJsonObject::operator =(const QJsonObject &other)-
47{-
48 if (d != other.d
d != other.dDescription
TRUEevaluated 653 times by 110 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 1 time by 1 test
Evaluated by:
  • tst_QVariant
) {
1-653
49 if (d
dDescription
TRUEnever evaluated
FALSEevaluated 653 times by 110 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()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0-653
50 delete d;
never executed: delete d;
0
51 d = other.d;-
52 if (d
dDescription
TRUEevaluated 653 times by 110 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
)
0-653
53 d->ref.ref();
executed 653 times by 110 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
  • ...
653
54 }
executed 653 times by 110 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
  • ...
653
55 o = other.o;-
56-
57 return
executed 654 times by 111 tests: return *this;
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
  • ...
*this;
executed 654 times by 111 tests: return *this;
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
  • ...
654
58}-
59QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map)-
60{-
61 QJsonObject object;-
62 if (map.isEmpty()
map.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
63 return
never executed: return object;
object;
never executed: return object;
0
64-
65 object.detach2(1024);-
66-
67 QVector<QJsonPrivate::offset> offsets;-
68 QJsonPrivate::offset currentOffset;-
69 currentOffset = sizeof(QJsonPrivate::Base);-
70-
71-
72-
73 for (QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd()
it != map.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
74 QString key = it.key();-
75 QJsonValue val = QJsonValue::fromVariant(it.value());-
76-
77 bool latinOrIntValue;-
78 int valueSize = QJsonPrivate::Value::requiredStorage(val, &latinOrIntValue);-
79-
80 bool latinKey = QJsonPrivate::useCompressed(key);-
81 int valueOffset = sizeof(QJsonPrivate::Entry) + QJsonPrivate::qStringSize(key, latinKey);-
82 int requiredSize = valueOffset + valueSize;-
83-
84 if (!object.detach2(requiredSize + sizeof(QJsonPrivate::offset))
!object.detach...vate::offset))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
85 return
never executed: return QJsonObject();
QJsonObject();
never executed: return QJsonObject();
0
86-
87 QJsonPrivate::Entry *e = reinterpret_cast<QJsonPrivate::Entry *>(reinterpret_cast<char *>(object.o) + currentOffset);-
88 e->value.type = val.t;-
89 e->value.latinKey = latinKey;-
90 e->value.latinOrIntValue = latinOrIntValue;-
91 e->value.value = QJsonPrivate::Value::valueToStore(val, (char *)e - (char *)object.o + valueOffset);-
92 QJsonPrivate::copyString((char *)(e + 1), key, latinKey);-
93 if (valueSize
valueSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
94 QJsonPrivate::Value::copyData(val, (char *)e + valueOffset, latinOrIntValue);
never executed: QJsonPrivate::Value::copyData(val, (char *)e + valueOffset, latinOrIntValue);
0
95-
96 offsets << currentOffset;-
97 currentOffset += requiredSize;-
98 object.o->size = currentOffset;-
99 }
never executed: end of block
0
100-
101-
102 object.o->tableOffset = currentOffset;-
103 if (!object.detach2(sizeof(QJsonPrivate::offset)*offsets.size())
!object.detach...ffsets.size())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
104 return
never executed: return QJsonObject();
QJsonObject();
never executed: return QJsonObject();
0
105 memcpy(object.o->table(), offsets.constData(), offsets.size()*sizeof(uint));-
106 object.o->length = offsets.size();-
107 object.o->size = currentOffset + sizeof(QJsonPrivate::offset)*offsets.size();-
108-
109 return
never executed: return object;
object;
never executed: return object;
0
110}-
111QVariantMap QJsonObject::toVariantMap() const-
112{-
113 QVariantMap map;-
114 if (o
oDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
115 for (uint i = 0; i < o->length
i < o->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
116 QJsonPrivate::Entry *e = o->entryAt(i);-
117 map.insert(e->key(), QJsonValue(d, o, e->value).toVariant());-
118 }
never executed: end of block
0
119 }
never executed: end of block
0
120 return
never executed: return map;
map;
never executed: return map;
0
121}-
122QJsonObject QJsonObject::fromVariantHash(const QVariantHash &hash)-
123{-
124-
125-
126 QJsonObject object;-
127 for (QVariantHash::const_iterator it = hash.constBegin(); it != hash.constEnd()
it != hash.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
128 object.insert(it.key(), QJsonValue::fromVariant(it.value()));
never executed: object.insert(it.key(), QJsonValue::fromVariant(it.value()));
0
129 return
never executed: return object;
object;
never executed: return object;
0
130}-
131QVariantHash QJsonObject::toVariantHash() const-
132{-
133 QVariantHash hash;-
134 if (o
oDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
135 for (uint i = 0; i < o->length
i < o->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
136 QJsonPrivate::Entry *e = o->entryAt(i);-
137 hash.insert(e->key(), QJsonValue(d, o, e->value).toVariant());-
138 }
never executed: end of block
0
139 }
never executed: end of block
0
140 return
never executed: return hash;
hash;
never executed: return hash;
0
141}-
142-
143-
144-
145-
146-
147-
148QStringList QJsonObject::keys() const-
149{-
150 QStringList keys;-
151 if (o
oDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmakelib
FALSEnever evaluated
) {
0-4
152 keys.reserve(o->length);-
153 for (uint i = 0; i < o->length
i < o->lengthDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qmakelib
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qmakelib
; ++i) {
4-18
154 QJsonPrivate::Entry *e = o->entryAt(i);-
155 keys.append(e->key());-
156 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_qmakelib
18
157 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qmakelib
4
158 return
executed 4 times by 1 test: return keys;
Executed by:
  • tst_qmakelib
keys;
executed 4 times by 1 test: return keys;
Executed by:
  • tst_qmakelib
4
159}-
160-
161-
162-
163-
164int QJsonObject::size() const-
165{-
166 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
167 return
never executed: return 0;
0;
never executed: return 0;
0
168-
169 return
never executed: return o->length;
o->length;
never executed: return o->length;
0
170}-
171-
172-
173-
174-
175-
176-
177bool QJsonObject::isEmpty() const-
178{-
179 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
180 return
never executed: return true;
true;
never executed: return true;
0
181-
182 return
never executed: return !o->length;
!o->length;
never executed: return !o->length;
0
183}-
184QJsonValue QJsonObject::value(const QString &key) const-
185{-
186 if (!d
!dDescription
TRUEnever evaluated
FALSEevaluated 87477 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-87477
187 return
never executed: return QJsonValue(QJsonValue::Undefined);
QJsonValue(QJsonValue::Undefined);
never executed: return QJsonValue(QJsonValue::Undefined);
0
188-
189 bool keyExists;-
190 int i = o->indexOf(key, &keyExists);-
191 if (!keyExists
!keyExistsDescription
TRUEevaluated 302 times by 3 tests
Evaluated by:
  • tst_QFactoryLoader
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
FALSEevaluated 87175 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
  • ...
)
302-87175
192 return
executed 302 times by 3 tests: return QJsonValue(QJsonValue::Undefined);
Executed by:
  • tst_QFactoryLoader
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
QJsonValue(QJsonValue::Undefined);
executed 302 times by 3 tests: return QJsonValue(QJsonValue::Undefined);
Executed by:
  • tst_QFactoryLoader
  • tst_QNetworkCookieJar
  • tst_QOpenGlConfig
302
193 return
executed 87175 times by 116 tests: return QJsonValue(d, o, o->entryAt(i)->value);
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
  • ...
QJsonValue(d, o, o->entryAt(i)->value);
executed 87175 times by 116 tests: return QJsonValue(d, o, o->entryAt(i)->value);
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
  • ...
87175
194}-
195QJsonValue QJsonObject::operator [](const QString &key) const-
196{-
197 return
never executed: return value(key);
value(key);
never executed: return value(key);
0
198}-
199QJsonValueRef QJsonObject::operator [](const QString &key)-
200{-
201-
202 bool keyExists = false;-
203 int index = o
oDescription
TRUEnever evaluated
FALSEnever evaluated
? o->indexOf(key, &keyExists) : -1;
0
204 if (!keyExists
!keyExistsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
205 iterator i = insert(key, QJsonValue());-
206 index = i.i;-
207 }
never executed: end of block
0
208 return
never executed: return QJsonValueRef(this, index);
QJsonValueRef(this, index);
never executed: return QJsonValueRef(this, index);
0
209}-
210QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &value)-
211{-
212 if (value.t == QJsonValue::Undefined
value.t == QJs...lue::UndefinedDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
) {
0-8
213 remove(key);-
214 return
never executed: return end();
end();
never executed: return end();
0
215 }-
216 QJsonValue val = value;-
217-
218 bool latinOrIntValue;-
219 int valueSize = QJsonPrivate::Value::requiredStorage(val, &latinOrIntValue);-
220-
221 bool latinKey = QJsonPrivate::useCompressed(key);-
222 int valueOffset = sizeof(QJsonPrivate::Entry) + QJsonPrivate::qStringSize(key, latinKey);-
223 int requiredSize = valueOffset + valueSize;-
224-
225 if (!detach2(requiredSize + sizeof(QJsonPrivate::offset))
!detach2(requi...vate::offset))Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
)
0-8
226 return
never executed: return iterator();
iterator();
never executed: return iterator();
0
227-
228 if (!o->length
!o->lengthDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
)
2-6
229 o->tableOffset = sizeof(QJsonPrivate::Object);
executed 2 times by 1 test: o->tableOffset = sizeof(QJsonPrivate::Object);
Executed by:
  • tst_QMetaType
2
230-
231 bool keyExists = false;-
232 int pos = o->indexOf(key, &keyExists);-
233 if (keyExists
keyExistsDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
)
0-8
234 ++
never executed: ++d->compactionCounter;
d->compactionCounter;
never executed: ++d->compactionCounter;
0
235-
236 uint off = o->reserveSpace(requiredSize, pos, 1, keyExists);-
237 if (!off
!offDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
)
0-8
238 return
never executed: return end();
end();
never executed: return end();
0
239-
240 QJsonPrivate::Entry *e = o->entryAt(pos);-
241 e->value.type = val.t;-
242 e->value.latinKey = latinKey;-
243 e->value.latinOrIntValue = latinOrIntValue;-
244 e->value.value = QJsonPrivate::Value::valueToStore(val, (char *)e - (char *)o + valueOffset);-
245 QJsonPrivate::copyString((char *)(e + 1), key, latinKey);-
246 if (valueSize
valueSizeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
)
2-6
247 QJsonPrivate::Value::copyData(val, (char *)e + valueOffset, latinOrIntValue);
executed 2 times by 1 test: QJsonPrivate::Value::copyData(val, (char *)e + valueOffset, latinOrIntValue);
Executed by:
  • tst_QMetaType
2
248-
249 if (d->compactionCounter > 32u
d->compactionCounter > 32uDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
&& d->compactionCounter >= unsigned(o->length) / 2u
d->compactionC...->length) / 2uDescription
TRUEnever evaluated
FALSEnever evaluated
)
0-8
250 compact();
never executed: compact();
0
251-
252 return
executed 8 times by 1 test: return iterator(this, pos);
Executed by:
  • tst_QMetaType
iterator(this, pos);
executed 8 times by 1 test: return iterator(this, pos);
Executed by:
  • tst_QMetaType
8
253}-
254-
255-
256-
257-
258-
259-
260void QJsonObject::remove(const QString &key)-
261{-
262 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
263 return;
never executed: return;
0
264-
265 bool keyExists;-
266 int index = o->indexOf(key, &keyExists);-
267 if (!keyExists
!keyExistsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
268 return;
never executed: return;
0
269-
270 detach2();-
271 o->removeItems(index, 1);-
272 ++d->compactionCounter;-
273 if (d->compactionCounter > 32u
d->compactionCounter > 32uDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->compactionCounter >= unsigned(o->length) / 2u
d->compactionC...->length) / 2uDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
274 compact();
never executed: compact();
0
275}
never executed: end of block
0
276QJsonValue QJsonObject::take(const QString &key)-
277{-
278 if (!o
!oDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
279 return
never executed: return QJsonValue(QJsonValue::Undefined);
QJsonValue(QJsonValue::Undefined);
never executed: return QJsonValue(QJsonValue::Undefined);
0
280-
281 bool keyExists;-
282 int index = o->indexOf(key, &keyExists);-
283 if (!keyExists
!keyExistsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
284 return
never executed: return QJsonValue(QJsonValue::Undefined);
QJsonValue(QJsonValue::Undefined);
never executed: return QJsonValue(QJsonValue::Undefined);
0
285-
286 QJsonValue v(d, o, o->entryAt(index)->value);-
287 detach2();-
288 o->removeItems(index, 1);-
289 ++d->compactionCounter;-
290 if (d->compactionCounter > 32u
d->compactionCounter > 32uDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->compactionCounter >= unsigned(o->length) / 2u
d->compactionC...->length) / 2uDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
291 compact();
never executed: compact();
0
292-
293 return
never executed: return v;
v;
never executed: return v;
0
294}-
295-
296-
297-
298-
299-
300-
301bool QJsonObject::contains(const QString &key) const-
302{-
303 if (!o
!oDescription
TRUEnever evaluated
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_QOpenGlConfig
)
0-12
304 return
never executed: return false;
false;
never executed: return false;
0
305-
306 bool keyExists;-
307 o->indexOf(key, &keyExists);-
308 return
executed 12 times by 1 test: return keyExists;
Executed by:
  • tst_QOpenGlConfig
keyExists;
executed 12 times by 1 test: return keyExists;
Executed by:
  • tst_QOpenGlConfig
12
309}-
310-
311-
312-
313-
314bool QJsonObject::operator==(const QJsonObject &other) const-
315{-
316 if (o == other.o
o == other.oDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEnever evaluated
)
0-8
317 return
executed 8 times by 1 test: return true;
Executed by:
  • tst_QMetaType
true;
executed 8 times by 1 test: return true;
Executed by:
  • tst_QMetaType
8
318-
319 if (!o
!oDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
320 return
never executed: return !other.o->length;
!other.o->length;
never executed: return !other.o->length;
0
321 if (!other.o
!other.oDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
322 return
never executed: return !o->length;
!o->length;
never executed: return !o->length;
0
323 if (o->length != other.o->length
o->length != other.o->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
324 return
never executed: return false;
false;
never executed: return false;
0
325-
326 for (uint i = 0; i < o->length
i < o->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
327 QJsonPrivate::Entry *e = o->entryAt(i);-
328 QJsonValue v(d, o, e->value);-
329 if (other.value(e->key()) != v
other.value(e->key()) != vDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
330 return
never executed: return false;
false;
never executed: return false;
0
331 }
never executed: end of block
0
332-
333 return
never executed: return true;
true;
never executed: return true;
0
334}-
335-
336-
337-
338-
339bool QJsonObject::operator!=(const QJsonObject &other) const-
340{-
341 return
never executed: return !(*this == other);
!(*this == other);
never executed: return !(*this == other);
0
342}-
343QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it)-
344{-
345 ((!(d && d->ref.load() == 1)) ? qt_assert("d && d->ref.load() == 1",__FILE__,573) : qt_noop());-
346 if (it.o != this
it.o != thisDescription
TRUEnever evaluated
FALSEnever evaluated
|| it.i < 0
it.i < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| it.i >= (int)o->length
it.i >= (int)o->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
347 return
never executed: return iterator(this, o->length);
iterator(this, o->length);
never executed: return iterator(this, o->length);
0
348-
349 int index = it.i;-
350-
351 o->removeItems(index, 1);-
352 ++d->compactionCounter;-
353 if (d->compactionCounter > 32u
d->compactionCounter > 32uDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->compactionCounter >= unsigned(o->length) / 2u
d->compactionC...->length) / 2uDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
354 compact();
never executed: compact();
0
355-
356-
357 return
never executed: return it;
it;
never executed: return it;
0
358}-
359QJsonObject::iterator QJsonObject::find(const QString &key)-
360{-
361 bool keyExists = false;-
362 int index = o
oDescription
TRUEnever evaluated
FALSEnever evaluated
? o->indexOf(key, &keyExists) : 0;
0
363 if (!keyExists
!keyExistsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
364 return
never executed: return end();
end();
never executed: return end();
0
365 detach2();-
366 return
never executed: return iterator(this, index);
iterator(this, index);
never executed: return iterator(this, index);
0
367}-
368QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const-
369{-
370 bool keyExists = false;-
371 int index = o
oDescription
TRUEnever evaluated
FALSEnever evaluated
? o->indexOf(key, &keyExists) : 0;
0
372 if (!keyExists
!keyExistsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
373 return
never executed: return end();
end();
never executed: return end();
0
374 return
never executed: return const_iterator(this, index);
const_iterator(this, index);
never executed: return const_iterator(this, index);
0
375}-
376void QJsonObject::detach(uint reserve)-
377{-
378 (void)reserve;-
379 ((!(!reserve)) ? qt_assert("!reserve",__FILE__,1109) : qt_noop());-
380 detach2(reserve);-
381}
never executed: end of block
0
382-
383bool QJsonObject::detach2(uint reserve)-
384{-
385 if (!d
!dDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
) {
2-6
386 if (reserve >= QJsonPrivate::Value::MaxSize
reserve >= QJs...Value::MaxSizeDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
) {
0-2
387 QMessageLogger(__FILE__, 1117, __PRETTY_FUNCTION__).warning("QJson: Document too large to store in data structure");-
388 return
never executed: return false;
false;
never executed: return false;
0
389 }-
390 d = new QJsonPrivate::Data(reserve, QJsonValue::Object);-
391 o = static_cast<QJsonPrivate::Object *>(d->header->root());-
392 d->ref.ref();-
393 return
executed 2 times by 1 test: return true;
Executed by:
  • tst_QMetaType
true;
executed 2 times by 1 test: return true;
Executed by:
  • tst_QMetaType
2
394 }-
395 if (reserve == 0
reserve == 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
&& d->ref.load() == 1
d->ref.load() == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0-6
396 return
never executed: return true;
true;
never executed: return true;
0
397-
398 QJsonPrivate::Data *x = d->clone(o, reserve);-
399 if (!x
!xDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QMetaType
)
0-6
400 return
never executed: return false;
false;
never executed: return false;
0
401 x->ref.ref();-
402 if (!d->ref.deref()
!d->ref.deref()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QMetaType
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QMetaType
)
2-4
403 delete d;
executed 2 times by 1 test: delete d;
Executed by:
  • tst_QMetaType
2
404 d = x;-
405 o = static_cast<QJsonPrivate::Object *>(d->header->root());-
406 return
executed 6 times by 1 test: return true;
Executed by:
  • tst_QMetaType
true;
executed 6 times by 1 test: return true;
Executed by:
  • tst_QMetaType
6
407}-
408-
409-
410-
411-
412void QJsonObject::compact()-
413{-
414 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->compactionCounter
!d->compactionCounterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
415 return;
never executed: return;
0
416-
417 detach2();-
418 d->compact();-
419 o = static_cast<QJsonPrivate::Object *>(d->header->root());-
420}
never executed: end of block
0
421-
422-
423-
424-
425QString QJsonObject::keyAt(int i) const-
426{-
427 ((!(o && i >= 0 && i < (int)o->length)) ? qt_assert("o && i >= 0 && i < (int)o->length",__FILE__,1157) : qt_noop());-
428-
429 QJsonPrivate::Entry *e = o->entryAt(i);-
430 return
never executed: return e->key();
e->key();
never executed: return e->key();
0
431}-
432-
433-
434-
435-
436QJsonValue QJsonObject::valueAt(int i) const-
437{-
438 if (!o
!oDescription
TRUEnever evaluated
FALSEnever evaluated
|| i < 0
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| i >= (int)o->length
i >= (int)o->lengthDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
439 return
never executed: return QJsonValue(QJsonValue::Undefined);
QJsonValue(QJsonValue::Undefined);
never executed: return QJsonValue(QJsonValue::Undefined);
0
440-
441 QJsonPrivate::Entry *e = o->entryAt(i);-
442 return
never executed: return QJsonValue(d, o, e->value);
QJsonValue(d, o, e->value);
never executed: return QJsonValue(d, o, e->value);
0
443}-
444-
445-
446-
447-
448void QJsonObject::setValueAt(int i, const QJsonValue &val)-
449{-
450 ((!(o && i >= 0 && i < (int)o->length)) ? qt_assert("o && i >= 0 && i < (int)o->length",__FILE__,1180) : qt_noop());-
451-
452 QJsonPrivate::Entry *e = o->entryAt(i);-
453 insert(e->key(), val);-
454}
never executed: end of block
0
455-
456-
457QDebug operator<<(QDebug dbg, const QJsonObject &o)-
458{-
459 QDebugStateSaver saver(dbg);-
460 if (!o.o
!o.oDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QVariant
FALSEnever evaluated
) {
0-1
461 dbg << "QJsonObject()";-
462 return
executed 1 time by 1 test: return dbg;
Executed by:
  • tst_QVariant
dbg;
executed 1 time by 1 test: return dbg;
Executed by:
  • tst_QVariant
1
463 }-
464 QByteArray json;-
465 QJsonPrivate::Writer::objectToJson(o.o, json, 0, true);-
466 dbg.nospace() << "QJsonObject("-
467 << json.constData()-
468 << ")";-
469 return
never executed: return dbg;
dbg;
never executed: return dbg;
0
470}-
471-
472-
473-
Switch to Source codePreprocessed file

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