| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/sql/kernel/qsqlfield.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | class QSqlFieldPrivate | - | ||||||
| 5 | { | - | ||||||
| 6 | public: | - | ||||||
| 7 | QSqlFieldPrivate(const QString &name, | - | ||||||
| 8 | QVariant::Type type) : | - | ||||||
| 9 | ref(1), nm(name), ro(false), type(type), req(QSqlField::Unknown), | - | ||||||
| 10 | len(-1), prec(-1), tp(-1), gen(true), autoval(false) | - | ||||||
| 11 | { | - | ||||||
| 12 | } executed 6143 times by 11 tests: end of blockExecuted by:
| 6143 | ||||||
| 13 | - | |||||||
| 14 | QSqlFieldPrivate(const QSqlFieldPrivate &other) | - | ||||||
| 15 | : ref(1), | - | ||||||
| 16 | nm(other.nm), | - | ||||||
| 17 | ro(other.ro), | - | ||||||
| 18 | type(other.type), | - | ||||||
| 19 | req(other.req), | - | ||||||
| 20 | len(other.len), | - | ||||||
| 21 | prec(other.prec), | - | ||||||
| 22 | def(other.def), | - | ||||||
| 23 | tp(other.tp), | - | ||||||
| 24 | gen(other.gen), | - | ||||||
| 25 | autoval(other.autoval) | - | ||||||
| 26 | {} executed 1071 times by 3 tests: end of blockExecuted by:
| 1071 | ||||||
| 27 | - | |||||||
| 28 | bool operator==(const QSqlFieldPrivate& other) const | - | ||||||
| 29 | { | - | ||||||
| 30 | return executed 578 times by 6 tests: (nm == other.nmreturn (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
executed 578 times by 6 tests: return (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
| 578 | ||||||
| 31 | && ro == other.ro executed 578 times by 6 tests: return (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
| 578 | ||||||
| 32 | && type == other.type executed 578 times by 6 tests: return (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
| 578 | ||||||
| 33 | && req == other.req executed 578 times by 6 tests: return (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
| 578 | ||||||
| 34 | && len == other.len executed 578 times by 6 tests: return (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
| 578 | ||||||
| 35 | && prec == other.prec executed 578 times by 6 tests: return (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
| 578 | ||||||
| 36 | && def == other.def executed 578 times by 6 tests: return (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
| 578 | ||||||
| 37 | && gen == other.gen executed 578 times by 6 tests: return (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
| 578 | ||||||
| 38 | && autoval == other.autoval); executed 578 times by 6 tests: return (nm == other.nm && ro == other.ro && type == other.type && req == other.req && len == other.len && prec == other.prec && def == other.def && gen == other.gen && autoval == other.autoval);Executed by:
| 578 | ||||||
| 39 | } | - | ||||||
| 40 | - | |||||||
| 41 | QAtomicInt ref; | - | ||||||
| 42 | QString nm; | - | ||||||
| 43 | uint ro: 1; | - | ||||||
| 44 | QVariant::Type type; | - | ||||||
| 45 | QSqlField::RequiredStatus req; | - | ||||||
| 46 | int len; | - | ||||||
| 47 | int prec; | - | ||||||
| 48 | QVariant def; | - | ||||||
| 49 | int tp; | - | ||||||
| 50 | uint gen: 1; | - | ||||||
| 51 | uint autoval: 1; | - | ||||||
| 52 | }; | - | ||||||
| 53 | QSqlField::QSqlField(const QString& fieldName, QVariant::Type type) | - | ||||||
| 54 | { | - | ||||||
| 55 | d = new QSqlFieldPrivate(fieldName, type); | - | ||||||
| 56 | val = QVariant(type); | - | ||||||
| 57 | } executed 6143 times by 11 tests: end of blockExecuted by:
| 6143 | ||||||
| 58 | - | |||||||
| 59 | - | |||||||
| 60 | - | |||||||
| 61 | - | |||||||
| 62 | - | |||||||
| 63 | QSqlField::QSqlField(const QSqlField& other) | - | ||||||
| 64 | { | - | ||||||
| 65 | d = other.d; | - | ||||||
| 66 | d->ref.ref(); | - | ||||||
| 67 | val = other.val; | - | ||||||
| 68 | } executed 29510 times by 11 tests: end of blockExecuted by:
| 29510 | ||||||
| 69 | - | |||||||
| 70 | - | |||||||
| 71 | - | |||||||
| 72 | - | |||||||
| 73 | - | |||||||
| 74 | QSqlField& QSqlField::operator=(const QSqlField& other) | - | ||||||
| 75 | { | - | ||||||
| 76 | qAtomicAssign(d, other.d); | - | ||||||
| 77 | val = other.val; | - | ||||||
| 78 | return executed 233 times by 5 tests: *this;return *this;Executed by:
executed 233 times by 5 tests: return *this;Executed by:
| 233 | ||||||
| 79 | } | - | ||||||
| 80 | bool QSqlField::operator==(const QSqlField& other) const | - | ||||||
| 81 | { | - | ||||||
| 82 | return executed 604 times by 6 tests: ((d == other.d || *d == *other.d)return ((d == other.d || *d == *other.d) && val == other.val);Executed by:
executed 604 times by 6 tests: return ((d == other.d || *d == *other.d) && val == other.val);Executed by:
| 604 | ||||||
| 83 | && val == other.val); executed 604 times by 6 tests: return ((d == other.d || *d == *other.d) && val == other.val);Executed by:
| 604 | ||||||
| 84 | } | - | ||||||
| 85 | - | |||||||
| 86 | - | |||||||
| 87 | - | |||||||
| 88 | - | |||||||
| 89 | - | |||||||
| 90 | QSqlField::~QSqlField() | - | ||||||
| 91 | { | - | ||||||
| 92 | if (!d->ref.deref()
| 7097-28556 | ||||||
| 93 | delete d; executed 7097 times by 11 tests: delete d;Executed by:
| 7097 | ||||||
| 94 | } executed 35653 times by 11 tests: end of blockExecuted by:
| 35653 | ||||||
| 95 | - | |||||||
| 96 | - | |||||||
| 97 | - | |||||||
| 98 | - | |||||||
| 99 | - | |||||||
| 100 | - | |||||||
| 101 | - | |||||||
| 102 | void QSqlField::setRequiredStatus(RequiredStatus required) | - | ||||||
| 103 | { | - | ||||||
| 104 | detach(); | - | ||||||
| 105 | d->req = required; | - | ||||||
| 106 | } executed 970 times by 7 tests: end of blockExecuted by:
| 970 | ||||||
| 107 | void QSqlField::setLength(int fieldLength) | - | ||||||
| 108 | { | - | ||||||
| 109 | detach(); | - | ||||||
| 110 | d->len = fieldLength; | - | ||||||
| 111 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||
| 112 | - | |||||||
| 113 | - | |||||||
| 114 | - | |||||||
| 115 | - | |||||||
| 116 | - | |||||||
| 117 | - | |||||||
| 118 | - | |||||||
| 119 | void QSqlField::setPrecision(int precision) | - | ||||||
| 120 | { | - | ||||||
| 121 | detach(); | - | ||||||
| 122 | d->prec = precision; | - | ||||||
| 123 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||
| 124 | - | |||||||
| 125 | - | |||||||
| 126 | - | |||||||
| 127 | - | |||||||
| 128 | - | |||||||
| 129 | - | |||||||
| 130 | - | |||||||
| 131 | void QSqlField::setDefaultValue(const QVariant &value) | - | ||||||
| 132 | { | - | ||||||
| 133 | detach(); | - | ||||||
| 134 | d->def = value; | - | ||||||
| 135 | } executed 967 times by 6 tests: end of blockExecuted by:
| 967 | ||||||
| 136 | - | |||||||
| 137 | - | |||||||
| 138 | - | |||||||
| 139 | - | |||||||
| 140 | void QSqlField::setSqlType(int type) | - | ||||||
| 141 | { | - | ||||||
| 142 | detach(); | - | ||||||
| 143 | d->tp = type; | - | ||||||
| 144 | } executed 4556 times by 9 tests: end of blockExecuted by:
| 4556 | ||||||
| 145 | void QSqlField::setGenerated(bool gen) | - | ||||||
| 146 | { | - | ||||||
| 147 | detach(); | - | ||||||
| 148 | d->gen = gen; | - | ||||||
| 149 | } executed 1702 times by 4 tests: end of blockExecuted by:
| 1702 | ||||||
| 150 | void QSqlField::setValue(const QVariant& value) | - | ||||||
| 151 | { | - | ||||||
| 152 | if (isReadOnly()
| 4-1537 | ||||||
| 153 | return; executed 4 times by 1 test: return;Executed by:
| 4 | ||||||
| 154 | val = value; | - | ||||||
| 155 | } executed 1537 times by 8 tests: end of blockExecuted by:
| 1537 | ||||||
| 156 | void QSqlField::clear() | - | ||||||
| 157 | { | - | ||||||
| 158 | if (isReadOnly()
| 14-129 | ||||||
| 159 | return; executed 14 times by 1 test: return;Executed by:
| 14 | ||||||
| 160 | val = QVariant(type()); | - | ||||||
| 161 | } executed 129 times by 3 tests: end of blockExecuted by:
| 129 | ||||||
| 162 | - | |||||||
| 163 | - | |||||||
| 164 | - | |||||||
| 165 | - | |||||||
| 166 | - | |||||||
| 167 | - | |||||||
| 168 | - | |||||||
| 169 | void QSqlField::setName(const QString& name) | - | ||||||
| 170 | { | - | ||||||
| 171 | detach(); | - | ||||||
| 172 | d->nm = name; | - | ||||||
| 173 | } executed 7 times by 1 test: end of blockExecuted by:
| 7 | ||||||
| 174 | - | |||||||
| 175 | - | |||||||
| 176 | - | |||||||
| 177 | - | |||||||
| 178 | - | |||||||
| 179 | - | |||||||
| 180 | void QSqlField::setReadOnly(bool readOnly) | - | ||||||
| 181 | { | - | ||||||
| 182 | detach(); | - | ||||||
| 183 | d->ro = readOnly; | - | ||||||
| 184 | } executed 32 times by 3 tests: end of blockExecuted by:
| 32 | ||||||
| 185 | QString QSqlField::name() const | - | ||||||
| 186 | { | - | ||||||
| 187 | return executed 4401 times by 9 tests: d->nm;return d->nm;Executed by:
executed 4401 times by 9 tests: return d->nm;Executed by:
| 4401 | ||||||
| 188 | } | - | ||||||
| 189 | QVariant::Type QSqlField::type() const | - | ||||||
| 190 | { | - | ||||||
| 191 | return executed 312 times by 8 tests: d->type;return d->type;Executed by:
executed 312 times by 8 tests: return d->type;Executed by:
| 312 | ||||||
| 192 | } | - | ||||||
| 193 | - | |||||||
| 194 | - | |||||||
| 195 | - | |||||||
| 196 | - | |||||||
| 197 | - | |||||||
| 198 | - | |||||||
| 199 | - | |||||||
| 200 | void QSqlField::setType(QVariant::Type type) | - | ||||||
| 201 | { | - | ||||||
| 202 | detach(); | - | ||||||
| 203 | d->type = type; | - | ||||||
| 204 | if (!val.isValid()
| 0 | ||||||
| 205 | val = QVariant(type); never executed: val = QVariant(type); | 0 | ||||||
| 206 | } never executed: end of block | 0 | ||||||
| 207 | bool QSqlField::isReadOnly() const | - | ||||||
| 208 | { return executed 1953 times by 8 tests: d->ro;return d->ro;Executed by:
executed 1953 times by 8 tests: }return d->ro;Executed by:
| 1953 | ||||||
| 209 | - | |||||||
| 210 | - | |||||||
| 211 | - | |||||||
| 212 | - | |||||||
| 213 | - | |||||||
| 214 | - | |||||||
| 215 | - | |||||||
| 216 | bool QSqlField::isNull() const | - | ||||||
| 217 | { return executed 678 times by 6 tests: val.isNull();return val.isNull();Executed by:
executed 678 times by 6 tests: }return val.isNull();Executed by:
| 678 | ||||||
| 218 | - | |||||||
| 219 | - | |||||||
| 220 | - | |||||||
| 221 | void QSqlField::detach() | - | ||||||
| 222 | { | - | ||||||
| 223 | qAtomicDetach(d); | - | ||||||
| 224 | } executed 8261 times by 11 tests: end of blockExecuted by:
| 8261 | ||||||
| 225 | QSqlField::RequiredStatus QSqlField::requiredStatus() const | - | ||||||
| 226 | { | - | ||||||
| 227 | return executed 3 times by 1 test: d->req;return d->req;Executed by:
executed 3 times by 1 test: return d->req;Executed by:
| 3 | ||||||
| 228 | } | - | ||||||
| 229 | int QSqlField::length() const | - | ||||||
| 230 | { | - | ||||||
| 231 | return executed 3 times by 1 test: d->len;return d->len;Executed by:
executed 3 times by 1 test: return d->len;Executed by:
| 3 | ||||||
| 232 | } | - | ||||||
| 233 | int QSqlField::precision() const | - | ||||||
| 234 | { | - | ||||||
| 235 | return executed 4 times by 2 tests: d->prec;return d->prec;Executed by:
executed 4 times by 2 tests: return d->prec;Executed by:
| 4 | ||||||
| 236 | } | - | ||||||
| 237 | - | |||||||
| 238 | - | |||||||
| 239 | - | |||||||
| 240 | - | |||||||
| 241 | - | |||||||
| 242 | - | |||||||
| 243 | - | |||||||
| 244 | QVariant QSqlField::defaultValue() const | - | ||||||
| 245 | { | - | ||||||
| 246 | return never executed: d->def;return d->def;never executed: return d->def; | 0 | ||||||
| 247 | } | - | ||||||
| 248 | int QSqlField::typeID() const | - | ||||||
| 249 | { | - | ||||||
| 250 | return never executed: d->tp;return d->tp;never executed: return d->tp; | 0 | ||||||
| 251 | } | - | ||||||
| 252 | bool QSqlField::isGenerated() const | - | ||||||
| 253 | { | - | ||||||
| 254 | return executed 8549 times by 6 tests: d->gen;return d->gen;Executed by:
executed 8549 times by 6 tests: return d->gen;Executed by:
| 8549 | ||||||
| 255 | } | - | ||||||
| 256 | - | |||||||
| 257 | - | |||||||
| 258 | - | |||||||
| 259 | - | |||||||
| 260 | - | |||||||
| 261 | bool QSqlField::isValid() const | - | ||||||
| 262 | { | - | ||||||
| 263 | return executed 373 times by 3 tests: d->type != QVariant::Invalid;return d->type != QVariant::Invalid;Executed by:
executed 373 times by 3 tests: return d->type != QVariant::Invalid;Executed by:
| 373 | ||||||
| 264 | } | - | ||||||
| 265 | - | |||||||
| 266 | - | |||||||
| 267 | QDebug operator<<(QDebug dbg, const QSqlField &f) | - | ||||||
| 268 | { | - | ||||||
| 269 | QDebugStateSaver saver(dbg); | - | ||||||
| 270 | dbg.nospace(); | - | ||||||
| 271 | dbg << "QSqlField(" << f.name() << ", " << QMetaType::typeName(f.type()); | - | ||||||
| 272 | if (f.length() >= 0
| 0 | ||||||
| 273 | dbg << ", length: " << f.length(); never executed: dbg << ", length: " << f.length(); | 0 | ||||||
| 274 | if (f.precision() >= 0
| 0 | ||||||
| 275 | dbg << ", precision: " << f.precision(); never executed: dbg << ", precision: " << f.precision(); | 0 | ||||||
| 276 | if (f.requiredStatus() != QSqlField::Unknown
| 0 | ||||||
| 277 | dbg << ", required: " never executed: dbg << ", required: " << (f.requiredStatus() == QSqlField::Required ? "yes" : "no"); | 0 | ||||||
| 278 | << (f.requiredStatus() == QSqlField::Required ? "yes" : "no"); never executed: dbg << ", required: " << (f.requiredStatus() == QSqlField::Required ? "yes" : "no"); | 0 | ||||||
| 279 | dbg << ", generated: " << (f.isGenerated() ? "yes" : "no"); | - | ||||||
| 280 | if (f.typeID() >= 0
| 0 | ||||||
| 281 | dbg << ", typeID: " << f.typeID(); never executed: dbg << ", typeID: " << f.typeID(); | 0 | ||||||
| 282 | if (!f.defaultValue().isNull()
| 0 | ||||||
| 283 | dbg << ", defaultValue: \"" << f.defaultValue() << '\"'; never executed: dbg << ", defaultValue: \"" << f.defaultValue() << '\"'; | 0 | ||||||
| 284 | dbg << ", autoValue: " << f.isAutoValue() | - | ||||||
| 285 | << ", readOnly: " << f.isReadOnly() << ')'; | - | ||||||
| 286 | return never executed: dbg;return dbg;never executed: return dbg; | 0 | ||||||
| 287 | } | - | ||||||
| 288 | bool QSqlField::isAutoValue() const | - | ||||||
| 289 | { | - | ||||||
| 290 | return executed 460 times by 4 tests: d->autoval;return d->autoval;Executed by:
executed 460 times by 4 tests: return d->autoval;Executed by:
| 460 | ||||||
| 291 | } | - | ||||||
| 292 | - | |||||||
| 293 | - | |||||||
| 294 | - | |||||||
| 295 | - | |||||||
| 296 | - | |||||||
| 297 | - | |||||||
| 298 | - | |||||||
| 299 | void QSqlField::setAutoValue(bool autoVal) | - | ||||||
| 300 | { | - | ||||||
| 301 | detach(); | - | ||||||
| 302 | d->autoval = autoVal; | - | ||||||
| 303 | } executed 21 times by 4 tests: end of blockExecuted by:
| 21 | ||||||
| 304 | - | |||||||
| 305 | - | |||||||
| Switch to Source code | Preprocessed file |