| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/sql/kernel/qsqlrecord.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | class QSqlRecordPrivate | - | ||||||
| 6 | { | - | ||||||
| 7 | public: | - | ||||||
| 8 | QSqlRecordPrivate(); | - | ||||||
| 9 | QSqlRecordPrivate(const QSqlRecordPrivate &other); | - | ||||||
| 10 | - | |||||||
| 11 | inline bool contains(int index) { return executed 3290 times by 7 tests: index >= 0 && index < fields.count();return index >= 0 && index < fields.count();Executed by:
executed 3290 times by 7 tests: }return index >= 0 && index < fields.count();Executed by:
| 3290 | ||||||
| 12 | QString createField(int index, const QString &prefix) const; | - | ||||||
| 13 | - | |||||||
| 14 | QVector<QSqlField> fields; | - | ||||||
| 15 | QAtomicInt ref; | - | ||||||
| 16 | }; | - | ||||||
| 17 | - | |||||||
| 18 | QSqlRecordPrivate::QSqlRecordPrivate() : ref(1) | - | ||||||
| 19 | { | - | ||||||
| 20 | } executed 15179 times by 10 tests: end of blockExecuted by:
| 15179 | ||||||
| 21 | - | |||||||
| 22 | QSqlRecordPrivate::QSqlRecordPrivate(const QSqlRecordPrivate &other): fields(other.fields), ref(1) | - | ||||||
| 23 | { | - | ||||||
| 24 | } executed 1024 times by 8 tests: end of blockExecuted by:
| 1024 | ||||||
| 25 | - | |||||||
| 26 | - | |||||||
| 27 | - | |||||||
| 28 | - | |||||||
| 29 | QString QSqlRecordPrivate::createField(int index, const QString &prefix) const | - | ||||||
| 30 | { | - | ||||||
| 31 | QString f; | - | ||||||
| 32 | if (!prefix.isEmpty()
| 0 | ||||||
| 33 | f = prefix + QLatin1Char('.'); never executed: f = prefix + QLatin1Char('.'); | 0 | ||||||
| 34 | f += fields.at(index).name(); | - | ||||||
| 35 | return never executed: f;return f;never executed: return f; | 0 | ||||||
| 36 | } | - | ||||||
| 37 | QSqlRecord::QSqlRecord() | - | ||||||
| 38 | { | - | ||||||
| 39 | d = new QSqlRecordPrivate(); | - | ||||||
| 40 | } executed 15179 times by 10 tests: end of blockExecuted by:
| 15179 | ||||||
| 41 | QSqlRecord::QSqlRecord(const QSqlRecord& other) | - | ||||||
| 42 | { | - | ||||||
| 43 | d = other.d; | - | ||||||
| 44 | d->ref.ref(); | - | ||||||
| 45 | } executed 20192 times by 8 tests: end of blockExecuted by:
| 20192 | ||||||
| 46 | QSqlRecord& QSqlRecord::operator=(const QSqlRecord& other) | - | ||||||
| 47 | { | - | ||||||
| 48 | qAtomicAssign(d, other.d); | - | ||||||
| 49 | return executed 1738 times by 8 tests: *this;return *this;Executed by:
executed 1738 times by 8 tests: return *this;Executed by:
| 1738 | ||||||
| 50 | } | - | ||||||
| 51 | - | |||||||
| 52 | - | |||||||
| 53 | - | |||||||
| 54 | - | |||||||
| 55 | - | |||||||
| 56 | QSqlRecord::~QSqlRecord() | - | ||||||
| 57 | { | - | ||||||
| 58 | if (!d->ref.deref()
| 14532-20839 | ||||||
| 59 | delete d; executed 14532 times by 10 tests: delete d;Executed by:
| 14532 | ||||||
| 60 | } executed 35371 times by 10 tests: end of blockExecuted by:
| 35371 | ||||||
| 61 | bool QSqlRecord::operator==(const QSqlRecord &other) const | - | ||||||
| 62 | { | - | ||||||
| 63 | return executed 382 times by 4 tests: d->fields == other.d->fields;return d->fields == other.d->fields;Executed by:
executed 382 times by 4 tests: return d->fields == other.d->fields;Executed by:
| 382 | ||||||
| 64 | } | - | ||||||
| 65 | QVariant QSqlRecord::value(int index) const | - | ||||||
| 66 | { | - | ||||||
| 67 | return executed 1320 times by 5 tests: d->fields.value(index).value();return d->fields.value(index).value();Executed by:
executed 1320 times by 5 tests: return d->fields.value(index).value();Executed by:
| 1320 | ||||||
| 68 | } | - | ||||||
| 69 | QVariant QSqlRecord::value(const QString& name) const | - | ||||||
| 70 | { | - | ||||||
| 71 | return executed 280 times by 3 tests: value(indexOf(name));return value(indexOf(name));Executed by:
executed 280 times by 3 tests: return value(indexOf(name));Executed by:
| 280 | ||||||
| 72 | } | - | ||||||
| 73 | QString QSqlRecord::fieldName(int index) const | - | ||||||
| 74 | { | - | ||||||
| 75 | return executed 2572 times by 8 tests: d->fields.value(index).name();return d->fields.value(index).name();Executed by:
executed 2572 times by 8 tests: return d->fields.value(index).name();Executed by:
| 2572 | ||||||
| 76 | } | - | ||||||
| 77 | int QSqlRecord::indexOf(const QString& name) const | - | ||||||
| 78 | { | - | ||||||
| 79 | QString nm = name.toUpper(); | - | ||||||
| 80 | for (int i = 0; i < count()
| 28-1543 | ||||||
| 81 | if (d->fields.at(i).name().toUpper() == nm
| 729-814 | ||||||
| 82 | return executed 814 times by 5 tests: i;return i;Executed by:
executed 814 times by 5 tests: return i;Executed by:
| 814 | ||||||
| 83 | } executed 729 times by 5 tests: end of blockExecuted by:
| 729 | ||||||
| 84 | return executed 28 times by 4 tests: -1;return -1;Executed by:
executed 28 times by 4 tests: return -1;Executed by:
| 28 | ||||||
| 85 | } | - | ||||||
| 86 | - | |||||||
| 87 | - | |||||||
| 88 | - | |||||||
| 89 | - | |||||||
| 90 | - | |||||||
| 91 | - | |||||||
| 92 | QSqlField QSqlRecord::field(int index) const | - | ||||||
| 93 | { | - | ||||||
| 94 | return executed 1674 times by 8 tests: d->fields.value(index);return d->fields.value(index);Executed by:
executed 1674 times by 8 tests: return d->fields.value(index);Executed by:
| 1674 | ||||||
| 95 | } | - | ||||||
| 96 | - | |||||||
| 97 | - | |||||||
| 98 | - | |||||||
| 99 | - | |||||||
| 100 | QSqlField QSqlRecord::field(const QString &name) const | - | ||||||
| 101 | { | - | ||||||
| 102 | return executed 284 times by 4 tests: field(indexOf(name));return field(indexOf(name));Executed by:
executed 284 times by 4 tests: return field(indexOf(name));Executed by:
| 284 | ||||||
| 103 | } | - | ||||||
| 104 | void QSqlRecord::append(const QSqlField& field) | - | ||||||
| 105 | { | - | ||||||
| 106 | detach(); | - | ||||||
| 107 | d->fields.append(field); | - | ||||||
| 108 | } executed 5623 times by 10 tests: end of blockExecuted by:
| 5623 | ||||||
| 109 | - | |||||||
| 110 | - | |||||||
| 111 | - | |||||||
| 112 | - | |||||||
| 113 | - | |||||||
| 114 | - | |||||||
| 115 | void QSqlRecord::insert(int pos, const QSqlField& field) | - | ||||||
| 116 | { | - | ||||||
| 117 | detach(); | - | ||||||
| 118 | d->fields.insert(pos, field); | - | ||||||
| 119 | } executed 117 times by 3 tests: end of blockExecuted by:
| 117 | ||||||
| 120 | void QSqlRecord::replace(int pos, const QSqlField& field) | - | ||||||
| 121 | { | - | ||||||
| 122 | if (!d->contains(pos)
| 0-34 | ||||||
| 123 | return; never executed: return; | 0 | ||||||
| 124 | - | |||||||
| 125 | detach(); | - | ||||||
| 126 | d->fields[pos] = field; | - | ||||||
| 127 | } executed 34 times by 1 test: end of blockExecuted by:
| 34 | ||||||
| 128 | void QSqlRecord::remove(int pos) | - | ||||||
| 129 | { | - | ||||||
| 130 | if (!d->contains(pos)
| 1-24 | ||||||
| 131 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||
| 132 | - | |||||||
| 133 | detach(); | - | ||||||
| 134 | d->fields.remove(pos); | - | ||||||
| 135 | } executed 24 times by 4 tests: end of blockExecuted by:
| 24 | ||||||
| 136 | - | |||||||
| 137 | - | |||||||
| 138 | - | |||||||
| 139 | - | |||||||
| 140 | - | |||||||
| 141 | - | |||||||
| 142 | - | |||||||
| 143 | void QSqlRecord::clear() | - | ||||||
| 144 | { | - | ||||||
| 145 | detach(); | - | ||||||
| 146 | d->fields.clear(); | - | ||||||
| 147 | } executed 124421 times by 10 tests: end of blockExecuted by:
| 124421 | ||||||
| 148 | bool QSqlRecord::isEmpty() const | - | ||||||
| 149 | { | - | ||||||
| 150 | return executed 89869 times by 10 tests: d->fields.isEmpty();return d->fields.isEmpty();Executed by:
executed 89869 times by 10 tests: return d->fields.isEmpty();Executed by:
| 89869 | ||||||
| 151 | } | - | ||||||
| 152 | - | |||||||
| 153 | - | |||||||
| 154 | - | |||||||
| 155 | - | |||||||
| 156 | - | |||||||
| 157 | - | |||||||
| 158 | - | |||||||
| 159 | bool QSqlRecord::contains(const QString& name) const | - | ||||||
| 160 | { | - | ||||||
| 161 | return executed 6 times by 1 test: indexOf(name) >= 0;return indexOf(name) >= 0;Executed by:
executed 6 times by 1 test: return indexOf(name) >= 0;Executed by:
| 6 | ||||||
| 162 | } | - | ||||||
| 163 | void QSqlRecord::clearValues() | - | ||||||
| 164 | { | - | ||||||
| 165 | detach(); | - | ||||||
| 166 | int count = d->fields.count(); | - | ||||||
| 167 | for (int i = 0; i < count
| 24-72 | ||||||
| 168 | d->fields[i].clear(); executed 72 times by 2 tests: d->fields[i].clear();Executed by:
| 72 | ||||||
| 169 | } executed 24 times by 2 tests: end of blockExecuted by:
| 24 | ||||||
| 170 | void QSqlRecord::setGenerated(const QString& name, bool generated) | - | ||||||
| 171 | { | - | ||||||
| 172 | setGenerated(indexOf(name), generated); | - | ||||||
| 173 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||
| 174 | void QSqlRecord::setGenerated(int index, bool generated) | - | ||||||
| 175 | { | - | ||||||
| 176 | if (!d->contains(index)
| 6-1678 | ||||||
| 177 | return; executed 6 times by 1 test: return;Executed by:
| 6 | ||||||
| 178 | detach(); | - | ||||||
| 179 | d->fields[index].setGenerated(generated); | - | ||||||
| 180 | } executed 1678 times by 3 tests: end of blockExecuted by:
| 1678 | ||||||
| 181 | - | |||||||
| 182 | - | |||||||
| 183 | - | |||||||
| 184 | - | |||||||
| 185 | - | |||||||
| 186 | - | |||||||
| 187 | - | |||||||
| 188 | bool QSqlRecord::isNull(int index) const | - | ||||||
| 189 | { | - | ||||||
| 190 | return executed 532 times by 4 tests: d->fields.value(index).isNull();return d->fields.value(index).isNull();Executed by:
executed 532 times by 4 tests: return d->fields.value(index).isNull();Executed by:
| 532 | ||||||
| 191 | } | - | ||||||
| 192 | - | |||||||
| 193 | - | |||||||
| 194 | - | |||||||
| 195 | - | |||||||
| 196 | - | |||||||
| 197 | - | |||||||
| 198 | - | |||||||
| 199 | bool QSqlRecord::isNull(const QString& name) const | - | ||||||
| 200 | { | - | ||||||
| 201 | return executed 20 times by 1 test: isNull(indexOf(name));return isNull(indexOf(name));Executed by:
executed 20 times by 1 test: return isNull(indexOf(name));Executed by:
| 20 | ||||||
| 202 | } | - | ||||||
| 203 | - | |||||||
| 204 | - | |||||||
| 205 | - | |||||||
| 206 | - | |||||||
| 207 | - | |||||||
| 208 | - | |||||||
| 209 | - | |||||||
| 210 | void QSqlRecord::setNull(int index) | - | ||||||
| 211 | { | - | ||||||
| 212 | if (!d->contains(index)
| 4-48 | ||||||
| 213 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||
| 214 | detach(); | - | ||||||
| 215 | d->fields[index].clear(); | - | ||||||
| 216 | } executed 48 times by 1 test: end of blockExecuted by:
| 48 | ||||||
| 217 | - | |||||||
| 218 | - | |||||||
| 219 | - | |||||||
| 220 | - | |||||||
| 221 | - | |||||||
| 222 | - | |||||||
| 223 | - | |||||||
| 224 | void QSqlRecord::setNull(const QString& name) | - | ||||||
| 225 | { | - | ||||||
| 226 | setNull(indexOf(name)); | - | ||||||
| 227 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||
| 228 | bool QSqlRecord::isGenerated(const QString& name) const | - | ||||||
| 229 | { | - | ||||||
| 230 | return executed 16 times by 1 test: isGenerated(indexOf(name));return isGenerated(indexOf(name));Executed by:
executed 16 times by 1 test: return isGenerated(indexOf(name));Executed by:
| 16 | ||||||
| 231 | } | - | ||||||
| 232 | bool QSqlRecord::isGenerated(int index) const | - | ||||||
| 233 | { | - | ||||||
| 234 | return executed 8549 times by 6 tests: d->fields.value(index).isGenerated();return d->fields.value(index).isGenerated();Executed by:
executed 8549 times by 6 tests: return d->fields.value(index).isGenerated();Executed by:
| 8549 | ||||||
| 235 | } | - | ||||||
| 236 | - | |||||||
| 237 | - | |||||||
| 238 | - | |||||||
| 239 | - | |||||||
| 240 | - | |||||||
| 241 | - | |||||||
| 242 | - | |||||||
| 243 | int QSqlRecord::count() const | - | ||||||
| 244 | { | - | ||||||
| 245 | return executed 146486 times by 9 tests: d->fields.count();return d->fields.count();Executed by:
executed 146486 times by 9 tests: return d->fields.count();Executed by:
| 146486 | ||||||
| 246 | } | - | ||||||
| 247 | void QSqlRecord::setValue(int index, const QVariant& val) | - | ||||||
| 248 | { | - | ||||||
| 249 | if (!d->contains(index)
| 2-1493 | ||||||
| 250 | return; executed 2 times by 1 test: return;Executed by:
| 2 | ||||||
| 251 | detach(); | - | ||||||
| 252 | d->fields[index].setValue(val); | - | ||||||
| 253 | } executed 1493 times by 7 tests: end of blockExecuted by:
| 1493 | ||||||
| 254 | void QSqlRecord::setValue(const QString& name, const QVariant& val) | - | ||||||
| 255 | { | - | ||||||
| 256 | setValue(indexOf(name), val); | - | ||||||
| 257 | } executed 15 times by 2 tests: end of blockExecuted by:
| 15 | ||||||
| 258 | - | |||||||
| 259 | - | |||||||
| 260 | - | |||||||
| 261 | - | |||||||
| 262 | void QSqlRecord::detach() | - | ||||||
| 263 | { | - | ||||||
| 264 | qAtomicDetach(d); | - | ||||||
| 265 | } executed 133462 times by 10 tests: end of blockExecuted by:
| 133462 | ||||||
| 266 | - | |||||||
| 267 | - | |||||||
| 268 | QDebug operator<<(QDebug dbg, const QSqlRecord &r) | - | ||||||
| 269 | { | - | ||||||
| 270 | QDebugStateSaver saver(dbg); | - | ||||||
| 271 | dbg.nospace(); | - | ||||||
| 272 | const int count = r.count(); | - | ||||||
| 273 | dbg << "QSqlRecord(" << count << ')'; | - | ||||||
| 274 | for (int i = 0; i < count
| 0 | ||||||
| 275 | dbg.nospace(); | - | ||||||
| 276 | dbg << '\n' << qSetFieldWidth(2) << right << i << left << qSetFieldWidth(0) << ':'; | - | ||||||
| 277 | dbg.space(); | - | ||||||
| 278 | dbg << r.field(i) << r.value(i).toString(); | - | ||||||
| 279 | } never executed: end of block | 0 | ||||||
| 280 | return never executed: dbg;return dbg;never executed: return dbg; | 0 | ||||||
| 281 | } | - | ||||||
| 282 | - | |||||||
| 283 | - | |||||||
| 284 | - | |||||||
| 285 | - | |||||||
| 286 | - | |||||||
| 287 | - | |||||||
| 288 | - | |||||||
| 289 | QSqlRecord QSqlRecord::keyValues(const QSqlRecord &keyFields) const | - | ||||||
| 290 | { | - | ||||||
| 291 | QSqlRecord retValues(keyFields); | - | ||||||
| 292 | - | |||||||
| 293 | for (int i = retValues.count() - 1; i >= 0
| 133-278 | ||||||
| 294 | retValues.setValue(i, value(retValues.fieldName(i))); executed 278 times by 2 tests: retValues.setValue(i, value(retValues.fieldName(i)));Executed by:
| 278 | ||||||
| 295 | - | |||||||
| 296 | return executed 133 times by 2 tests: retValues;return retValues;Executed by:
executed 133 times by 2 tests: return retValues;Executed by:
| 133 | ||||||
| 297 | } | - | ||||||
| 298 | - | |||||||
| 299 | - | |||||||
| Switch to Source code | Preprocessed file |