| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/json/qjsonobject.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | QJsonObject::QJsonObject() | - | ||||||||||||||||||
| 4 | : d(0), o(0) | - | ||||||||||||||||||
| 5 | { | - | ||||||||||||||||||
| 6 | } executed 43512 times by 142 tests: end of blockExecuted by:
| 43512 | ||||||||||||||||||
| 7 | QJsonObject::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 blockExecuted by:
| 42688 | ||||||||||||||||||
| 14 | void QJsonObject::initialize() | - | ||||||||||||||||||
| 15 | { | - | ||||||||||||||||||
| 16 | d = 0; | - | ||||||||||||||||||
| 17 | o = 0; | - | ||||||||||||||||||
| 18 | } never executed: end of block | 0 | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | QJsonObject::~QJsonObject() | - | ||||||||||||||||||
| 24 | { | - | ||||||||||||||||||
| 25 | if (d
| 3039-86845 | ||||||||||||||||||
| 26 | delete d; executed 3039 times by 249 tests: delete d;Executed by:
| 3039 | ||||||||||||||||||
| 27 | } executed 129603 times by 362 tests: end of blockExecuted by:
| 129603 | ||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | QJsonObject::QJsonObject(const QJsonObject &other) | - | ||||||||||||||||||
| 36 | { | - | ||||||||||||||||||
| 37 | d = other.d; | - | ||||||||||||||||||
| 38 | o = other.o; | - | ||||||||||||||||||
| 39 | if (d
| 3-41144 | ||||||||||||||||||
| 40 | d->ref.ref(); executed 41144 times by 111 tests: d->ref.ref();Executed by:
| 41144 | ||||||||||||||||||
| 41 | } executed 41147 times by 112 tests: end of blockExecuted by:
| 41147 | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | QJsonObject &QJsonObject::operator =(const QJsonObject &other) | - | ||||||||||||||||||
| 47 | { | - | ||||||||||||||||||
| 48 | if (d != other.d
| 1-653 | ||||||||||||||||||
| 49 | if (d
| 0-653 | ||||||||||||||||||
| 50 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 51 | d = other.d; | - | ||||||||||||||||||
| 52 | if (d
| 0-653 | ||||||||||||||||||
| 53 | d->ref.ref(); executed 653 times by 110 tests: d->ref.ref();Executed by:
| 653 | ||||||||||||||||||
| 54 | } executed 653 times by 110 tests: end of blockExecuted by:
| 653 | ||||||||||||||||||
| 55 | o = other.o; | - | ||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | return executed 654 times by 111 tests: *this;return *this;Executed by:
executed 654 times by 111 tests: return *this;Executed by:
| 654 | ||||||||||||||||||
| 58 | } | - | ||||||||||||||||||
| 59 | QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map) | - | ||||||||||||||||||
| 60 | { | - | ||||||||||||||||||
| 61 | QJsonObject object; | - | ||||||||||||||||||
| 62 | if (map.isEmpty()
| 0 | ||||||||||||||||||
| 63 | return never executed: object;return 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()
| 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))
| 0 | ||||||||||||||||||
| 85 | return never executed: QJsonObject();return 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
| 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())
| 0 | ||||||||||||||||||
| 104 | return never executed: QJsonObject();return 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: object;return object;never executed: return object; | 0 | ||||||||||||||||||
| 110 | } | - | ||||||||||||||||||
| 111 | QVariantMap QJsonObject::toVariantMap() const | - | ||||||||||||||||||
| 112 | { | - | ||||||||||||||||||
| 113 | QVariantMap map; | - | ||||||||||||||||||
| 114 | if (o
| 0 | ||||||||||||||||||
| 115 | for (uint i = 0; i < o->length
| 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: map;return map;never executed: return map; | 0 | ||||||||||||||||||
| 121 | } | - | ||||||||||||||||||
| 122 | QJsonObject QJsonObject::fromVariantHash(const QVariantHash &hash) | - | ||||||||||||||||||
| 123 | { | - | ||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | QJsonObject object; | - | ||||||||||||||||||
| 127 | for (QVariantHash::const_iterator it = hash.constBegin(); it != hash.constEnd()
| 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: object;return object;never executed: return object; | 0 | ||||||||||||||||||
| 130 | } | - | ||||||||||||||||||
| 131 | QVariantHash QJsonObject::toVariantHash() const | - | ||||||||||||||||||
| 132 | { | - | ||||||||||||||||||
| 133 | QVariantHash hash; | - | ||||||||||||||||||
| 134 | if (o
| 0 | ||||||||||||||||||
| 135 | for (uint i = 0; i < o->length
| 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: hash;return hash;never executed: return hash; | 0 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | QStringList QJsonObject::keys() const | - | ||||||||||||||||||
| 149 | { | - | ||||||||||||||||||
| 150 | QStringList keys; | - | ||||||||||||||||||
| 151 | if (o
| 0-4 | ||||||||||||||||||
| 152 | keys.reserve(o->length); | - | ||||||||||||||||||
| 153 | for (uint i = 0; i < o->length
| 4-18 | ||||||||||||||||||
| 154 | QJsonPrivate::Entry *e = o->entryAt(i); | - | ||||||||||||||||||
| 155 | keys.append(e->key()); | - | ||||||||||||||||||
| 156 | } executed 18 times by 1 test: end of blockExecuted by:
| 18 | ||||||||||||||||||
| 157 | } executed 4 times by 1 test: end of blockExecuted by:
| 4 | ||||||||||||||||||
| 158 | return executed 4 times by 1 test: keys;return keys;Executed by:
executed 4 times by 1 test: return keys;Executed by:
| 4 | ||||||||||||||||||
| 159 | } | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | - | |||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | int QJsonObject::size() const | - | ||||||||||||||||||
| 165 | { | - | ||||||||||||||||||
| 166 | if (!d
| 0 | ||||||||||||||||||
| 167 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | return never executed: o->length;return o->length;never executed: return o->length; | 0 | ||||||||||||||||||
| 170 | } | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | bool QJsonObject::isEmpty() const | - | ||||||||||||||||||
| 178 | { | - | ||||||||||||||||||
| 179 | if (!d
| 0 | ||||||||||||||||||
| 180 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | return never executed: !o->length;return !o->length;never executed: return !o->length; | 0 | ||||||||||||||||||
| 183 | } | - | ||||||||||||||||||
| 184 | QJsonValue QJsonObject::value(const QString &key) const | - | ||||||||||||||||||
| 185 | { | - | ||||||||||||||||||
| 186 | if (!d
| 0-87477 | ||||||||||||||||||
| 187 | return never executed: QJsonValue(QJsonValue::Undefined);return QJsonValue(QJsonValue::Undefined);never executed: return QJsonValue(QJsonValue::Undefined); | 0 | ||||||||||||||||||
| 188 | - | |||||||||||||||||||
| 189 | bool keyExists; | - | ||||||||||||||||||
| 190 | int i = o->indexOf(key, &keyExists); | - | ||||||||||||||||||
| 191 | if (!keyExists
| 302-87175 | ||||||||||||||||||
| 192 | return executed 302 times by 3 tests: QJsonValue(QJsonValue::Undefined);return QJsonValue(QJsonValue::Undefined);Executed by:
executed 302 times by 3 tests: return QJsonValue(QJsonValue::Undefined);Executed by:
| 302 | ||||||||||||||||||
| 193 | return executed 87175 times by 116 tests: QJsonValue(d, o, o->entryAt(i)->value);return QJsonValue(d, o, o->entryAt(i)->value);Executed by:
executed 87175 times by 116 tests: return QJsonValue(d, o, o->entryAt(i)->value);Executed by:
| 87175 | ||||||||||||||||||
| 194 | } | - | ||||||||||||||||||
| 195 | QJsonValue QJsonObject::operator [](const QString &key) const | - | ||||||||||||||||||
| 196 | { | - | ||||||||||||||||||
| 197 | return never executed: value(key);return value(key);never executed: return value(key); | 0 | ||||||||||||||||||
| 198 | } | - | ||||||||||||||||||
| 199 | QJsonValueRef QJsonObject::operator [](const QString &key) | - | ||||||||||||||||||
| 200 | { | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | bool keyExists = false; | - | ||||||||||||||||||
| 203 | int index = o
| 0 | ||||||||||||||||||
| 204 | if (!keyExists
| 0 | ||||||||||||||||||
| 205 | iterator i = insert(key, QJsonValue()); | - | ||||||||||||||||||
| 206 | index = i.i; | - | ||||||||||||||||||
| 207 | } never executed: end of block | 0 | ||||||||||||||||||
| 208 | return never executed: QJsonValueRef(this, index);return QJsonValueRef(this, index);never executed: return QJsonValueRef(this, index); | 0 | ||||||||||||||||||
| 209 | } | - | ||||||||||||||||||
| 210 | QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue &value) | - | ||||||||||||||||||
| 211 | { | - | ||||||||||||||||||
| 212 | if (value.t == QJsonValue::Undefined
| 0-8 | ||||||||||||||||||
| 213 | remove(key); | - | ||||||||||||||||||
| 214 | return never executed: end();return 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))
| 0-8 | ||||||||||||||||||
| 226 | return never executed: iterator();return iterator();never executed: return iterator(); | 0 | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | if (!o->length
| 2-6 | ||||||||||||||||||
| 229 | o->tableOffset = sizeof(QJsonPrivate::Object); executed 2 times by 1 test: o->tableOffset = sizeof(QJsonPrivate::Object);Executed by:
| 2 | ||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | bool keyExists = false; | - | ||||||||||||||||||
| 232 | int pos = o->indexOf(key, &keyExists); | - | ||||||||||||||||||
| 233 | if (keyExists
| 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
| 0-8 | ||||||||||||||||||
| 238 | return never executed: end();return 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
| 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:
| 2 | ||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | if (d->compactionCounter > 32u
| 0-8 | ||||||||||||||||||
| 250 | compact(); never executed: compact(); | 0 | ||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | return executed 8 times by 1 test: iterator(this, pos);return iterator(this, pos);Executed by:
executed 8 times by 1 test: return iterator(this, pos);Executed by:
| 8 | ||||||||||||||||||
| 253 | } | - | ||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | - | |||||||||||||||||||
| 259 | - | |||||||||||||||||||
| 260 | void QJsonObject::remove(const QString &key) | - | ||||||||||||||||||
| 261 | { | - | ||||||||||||||||||
| 262 | if (!d
| 0 | ||||||||||||||||||
| 263 | return; never executed: return; | 0 | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | bool keyExists; | - | ||||||||||||||||||
| 266 | int index = o->indexOf(key, &keyExists); | - | ||||||||||||||||||
| 267 | if (!keyExists
| 0 | ||||||||||||||||||
| 268 | return; never executed: return; | 0 | ||||||||||||||||||
| 269 | - | |||||||||||||||||||
| 270 | detach2(); | - | ||||||||||||||||||
| 271 | o->removeItems(index, 1); | - | ||||||||||||||||||
| 272 | ++d->compactionCounter; | - | ||||||||||||||||||
| 273 | if (d->compactionCounter > 32u
| 0 | ||||||||||||||||||
| 274 | compact(); never executed: compact(); | 0 | ||||||||||||||||||
| 275 | } never executed: end of block | 0 | ||||||||||||||||||
| 276 | QJsonValue QJsonObject::take(const QString &key) | - | ||||||||||||||||||
| 277 | { | - | ||||||||||||||||||
| 278 | if (!o
| 0 | ||||||||||||||||||
| 279 | return never executed: QJsonValue(QJsonValue::Undefined);return QJsonValue(QJsonValue::Undefined);never executed: return QJsonValue(QJsonValue::Undefined); | 0 | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | bool keyExists; | - | ||||||||||||||||||
| 282 | int index = o->indexOf(key, &keyExists); | - | ||||||||||||||||||
| 283 | if (!keyExists
| 0 | ||||||||||||||||||
| 284 | return never executed: QJsonValue(QJsonValue::Undefined);return 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
| 0 | ||||||||||||||||||
| 291 | compact(); never executed: compact(); | 0 | ||||||||||||||||||
| 292 | - | |||||||||||||||||||
| 293 | return never executed: v;return v;never executed: return v; | 0 | ||||||||||||||||||
| 294 | } | - | ||||||||||||||||||
| 295 | - | |||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | bool QJsonObject::contains(const QString &key) const | - | ||||||||||||||||||
| 302 | { | - | ||||||||||||||||||
| 303 | if (!o
| 0-12 | ||||||||||||||||||
| 304 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 305 | - | |||||||||||||||||||
| 306 | bool keyExists; | - | ||||||||||||||||||
| 307 | o->indexOf(key, &keyExists); | - | ||||||||||||||||||
| 308 | return executed 12 times by 1 test: keyExists;return keyExists;Executed by:
executed 12 times by 1 test: return keyExists;Executed by:
| 12 | ||||||||||||||||||
| 309 | } | - | ||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | - | |||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | bool QJsonObject::operator==(const QJsonObject &other) const | - | ||||||||||||||||||
| 315 | { | - | ||||||||||||||||||
| 316 | if (o == other.o
| 0-8 | ||||||||||||||||||
| 317 | return executed 8 times by 1 test: true;return true;Executed by:
executed 8 times by 1 test: return true;Executed by:
| 8 | ||||||||||||||||||
| 318 | - | |||||||||||||||||||
| 319 | if (!o
| 0 | ||||||||||||||||||
| 320 | return never executed: !other.o->length;return !other.o->length;never executed: return !other.o->length; | 0 | ||||||||||||||||||
| 321 | if (!other.o
| 0 | ||||||||||||||||||
| 322 | return never executed: !o->length;return !o->length;never executed: return !o->length; | 0 | ||||||||||||||||||
| 323 | if (o->length != other.o->length
| 0 | ||||||||||||||||||
| 324 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | for (uint i = 0; i < o->length
| 0 | ||||||||||||||||||
| 327 | QJsonPrivate::Entry *e = o->entryAt(i); | - | ||||||||||||||||||
| 328 | QJsonValue v(d, o, e->value); | - | ||||||||||||||||||
| 329 | if (other.value(e->key()) != v
| 0 | ||||||||||||||||||
| 330 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 331 | } never executed: end of block | 0 | ||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 334 | } | - | ||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | bool QJsonObject::operator!=(const QJsonObject &other) const | - | ||||||||||||||||||
| 340 | { | - | ||||||||||||||||||
| 341 | return never executed: !(*this == other);return !(*this == other);never executed: return !(*this == other); | 0 | ||||||||||||||||||
| 342 | } | - | ||||||||||||||||||
| 343 | QJsonObject::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
| 0 | ||||||||||||||||||
| 347 | return never executed: iterator(this, o->length);return 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
| 0 | ||||||||||||||||||
| 354 | compact(); never executed: compact(); | 0 | ||||||||||||||||||
| 355 | - | |||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 | return never executed: it;return it;never executed: return it; | 0 | ||||||||||||||||||
| 358 | } | - | ||||||||||||||||||
| 359 | QJsonObject::iterator QJsonObject::find(const QString &key) | - | ||||||||||||||||||
| 360 | { | - | ||||||||||||||||||
| 361 | bool keyExists = false; | - | ||||||||||||||||||
| 362 | int index = o
| 0 | ||||||||||||||||||
| 363 | if (!keyExists
| 0 | ||||||||||||||||||
| 364 | return never executed: end();return end();never executed: return end(); | 0 | ||||||||||||||||||
| 365 | detach2(); | - | ||||||||||||||||||
| 366 | return never executed: iterator(this, index);return iterator(this, index);never executed: return iterator(this, index); | 0 | ||||||||||||||||||
| 367 | } | - | ||||||||||||||||||
| 368 | QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const | - | ||||||||||||||||||
| 369 | { | - | ||||||||||||||||||
| 370 | bool keyExists = false; | - | ||||||||||||||||||
| 371 | int index = o
| 0 | ||||||||||||||||||
| 372 | if (!keyExists
| 0 | ||||||||||||||||||
| 373 | return never executed: end();return end();never executed: return end(); | 0 | ||||||||||||||||||
| 374 | return never executed: const_iterator(this, index);return const_iterator(this, index);never executed: return const_iterator(this, index); | 0 | ||||||||||||||||||
| 375 | } | - | ||||||||||||||||||
| 376 | void 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 | - | |||||||||||||||||||
| 383 | bool QJsonObject::detach2(uint reserve) | - | ||||||||||||||||||
| 384 | { | - | ||||||||||||||||||
| 385 | if (!d
| 2-6 | ||||||||||||||||||
| 386 | if (reserve >= QJsonPrivate::Value::MaxSize
| 0-2 | ||||||||||||||||||
| 387 | QMessageLogger(__FILE__, 1117, __PRETTY_FUNCTION__).warning("QJson: Document too large to store in data structure"); | - | ||||||||||||||||||
| 388 | return never executed: false;return 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: true;return true;Executed by:
executed 2 times by 1 test: return true;Executed by:
| 2 | ||||||||||||||||||
| 394 | } | - | ||||||||||||||||||
| 395 | if (reserve == 0
| 0-6 | ||||||||||||||||||
| 396 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | QJsonPrivate::Data *x = d->clone(o, reserve); | - | ||||||||||||||||||
| 399 | if (!x
| 0-6 | ||||||||||||||||||
| 400 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 401 | x->ref.ref(); | - | ||||||||||||||||||
| 402 | if (!d->ref.deref()
| 2-4 | ||||||||||||||||||
| 403 | delete d; executed 2 times by 1 test: delete d;Executed by:
| 2 | ||||||||||||||||||
| 404 | d = x; | - | ||||||||||||||||||
| 405 | o = static_cast<QJsonPrivate::Object *>(d->header->root()); | - | ||||||||||||||||||
| 406 | return executed 6 times by 1 test: true;return true;Executed by:
executed 6 times by 1 test: return true;Executed by:
| 6 | ||||||||||||||||||
| 407 | } | - | ||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | void QJsonObject::compact() | - | ||||||||||||||||||
| 413 | { | - | ||||||||||||||||||
| 414 | if (!d
| 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 | - | |||||||||||||||||||
| 425 | QString 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: e->key();return e->key();never executed: return e->key(); | 0 | ||||||||||||||||||
| 431 | } | - | ||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | - | |||||||||||||||||||
| 434 | - | |||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | QJsonValue QJsonObject::valueAt(int i) const | - | ||||||||||||||||||
| 437 | { | - | ||||||||||||||||||
| 438 | if (!o
| 0 | ||||||||||||||||||
| 439 | return never executed: QJsonValue(QJsonValue::Undefined);return QJsonValue(QJsonValue::Undefined);never executed: return QJsonValue(QJsonValue::Undefined); | 0 | ||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | QJsonPrivate::Entry *e = o->entryAt(i); | - | ||||||||||||||||||
| 442 | return never executed: QJsonValue(d, o, e->value);return QJsonValue(d, o, e->value);never executed: return QJsonValue(d, o, e->value); | 0 | ||||||||||||||||||
| 443 | } | - | ||||||||||||||||||
| 444 | - | |||||||||||||||||||
| 445 | - | |||||||||||||||||||
| 446 | - | |||||||||||||||||||
| 447 | - | |||||||||||||||||||
| 448 | void 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 | - | |||||||||||||||||||
| 457 | QDebug operator<<(QDebug dbg, const QJsonObject &o) | - | ||||||||||||||||||
| 458 | { | - | ||||||||||||||||||
| 459 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||
| 460 | if (!o.o
| 0-1 | ||||||||||||||||||
| 461 | dbg << "QJsonObject()"; | - | ||||||||||||||||||
| 462 | return executed 1 time by 1 test: dbg;return dbg;Executed by:
executed 1 time by 1 test: return dbg;Executed by:
| 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: dbg;return dbg;never executed: return dbg; | 0 | ||||||||||||||||||
| 470 | } | - | ||||||||||||||||||
| 471 | - | |||||||||||||||||||
| 472 | - | |||||||||||||||||||
| 473 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |