kernel/qsqlrecord.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5class QSqlRecordPrivate -
6{ -
7public: -
8 QSqlRecordPrivate(); -
9 QSqlRecordPrivate(const QSqlRecordPrivate &other); -
10 -
11 inline bool contains(int index) { return index >= 0 && index < fields.count(); }
executed: return index >= 0 && index < fields.count();
Execution Count:3280
3280
12 QString createField(int index, const QString &prefix) const; -
13 -
14 QVector<QSqlField> fields; -
15 QAtomicInt ref; -
16}; -
17 -
18QSqlRecordPrivate::QSqlRecordPrivate() : ref(1) -
19{ -
20}
executed: }
Execution Count:15173
15173
21 -
22QSqlRecordPrivate::QSqlRecordPrivate(const QSqlRecordPrivate &other): fields(other.fields), ref(1) -
23{ -
24}
executed: }
Execution Count:1018
1018
25 -
26 -
27 -
28 -
29QString QSqlRecordPrivate::createField(int index, const QString &prefix) const -
30{ -
31 QString f; -
32 if (!prefix.isEmpty())
never evaluated: !prefix.isEmpty()
0
33 f = prefix + QLatin1Char('.');
never executed: f = prefix + QLatin1Char('.');
0
34 f += fields.at(index).name(); -
35 return f;
never executed: return f;
0
36} -
37QSqlRecord::QSqlRecord() -
38{ -
39 d = new QSqlRecordPrivate(); -
40}
executed: }
Execution Count:15173
15173
41QSqlRecord::QSqlRecord(const QSqlRecord& other) -
42{ -
43 d = other.d; -
44 d->ref.ref(); -
45}
executed: }
Execution Count:20181
20181
46QSqlRecord& QSqlRecord::operator=(const QSqlRecord& other) -
47{ -
48 qAtomicAssign(d, other.d); -
49 return *this;
executed: return *this;
Execution Count:1738
1738
50} -
51 -
52 -
53 -
54 -
55 -
56QSqlRecord::~QSqlRecord() -
57{ -
58 if (!d->ref.deref())
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:14520
yes
Evaluation Count:20834
14520-20834
59 delete d;
executed: delete d;
Execution Count:14520
14520
60}
executed: }
Execution Count:35354
35354
61bool QSqlRecord::operator==(const QSqlRecord &other) const -
62{ -
63 return d->fields == other.d->fields;
executed: return d->fields == other.d->fields;
Execution Count:382
382
64} -
65QVariant QSqlRecord::value(int index) const -
66{ -
67 return d->fields.value(index).value();
executed: return d->fields.value(index).value();
Execution Count:1318
1318
68} -
69QVariant QSqlRecord::value(const QString& name) const -
70{ -
71 return value(indexOf(name));
executed: return value(indexOf(name));
Execution Count:280
280
72} -
73QString QSqlRecord::fieldName(int index) const -
74{ -
75 return d->fields.value(index).name();
executed: return d->fields.value(index).name();
Execution Count:2570
2570
76} -
77int QSqlRecord::indexOf(const QString& name) const -
78{ -
79 QString nm = name.toUpper(); -
80 for (int i = 0; i < count(); ++i) {
evaluated: i < count()
TRUEFALSE
yes
Evaluation Count:1524
yes
Evaluation Count:27
27-1524
81 if (d->fields.at(i).name().toUpper() == nm)
evaluated: d->fields.at(i).name().toUpper() == nm
TRUEFALSE
yes
Evaluation Count:804
yes
Evaluation Count:720
720-804
82 return i;
executed: return i;
Execution Count:804
804
83 }
executed: }
Execution Count:720
720
84 return -1;
executed: return -1;
Execution Count:27
27
85} -
86 -
87 -
88 -
89 -
90 -
91 -
92QSqlField QSqlRecord::field(int index) const -
93{ -
94 return d->fields.value(index);
executed: return d->fields.value(index);
Execution Count:1677
1677
95} -
96 -
97 -
98 -
99 -
100QSqlField QSqlRecord::field(const QString &name) const -
101{ -
102 return field(indexOf(name));
executed: return field(indexOf(name));
Execution Count:280
280
103} -
104void QSqlRecord::append(const QSqlField& field) -
105{ -
106 detach(); -
107 d->fields.append(field); -
108}
executed: }
Execution Count:5611
5611
109 -
110 -
111 -
112 -
113 -
114 -
115void QSqlRecord::insert(int pos, const QSqlField& field) -
116{ -
117 detach(); -
118 d->fields.insert(pos, field); -
119}
executed: }
Execution Count:117
117
120void QSqlRecord::replace(int pos, const QSqlField& field) -
121{ -
122 if (!d->contains(pos))
partially evaluated: !d->contains(pos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
123 return;
never executed: return;
0
124 -
125 detach(); -
126 d->fields[pos] = field; -
127}
executed: }
Execution Count:34
34
128void QSqlRecord::remove(int pos) -
129{ -
130 if (!d->contains(pos))
evaluated: !d->contains(pos)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:24
1-24
131 return;
executed: return;
Execution Count:1
1
132 -
133 detach(); -
134 d->fields.remove(pos); -
135}
executed: }
Execution Count:24
24
136 -
137 -
138 -
139 -
140 -
141 -
142 -
143void QSqlRecord::clear() -
144{ -
145 detach(); -
146 d->fields.clear(); -
147}
executed: }
Execution Count:124400
124400
148bool QSqlRecord::isEmpty() const -
149{ -
150 return d->fields.isEmpty();
executed: return d->fields.isEmpty();
Execution Count:90102
90102
151} -
152 -
153 -
154 -
155 -
156 -
157 -
158 -
159bool QSqlRecord::contains(const QString& name) const -
160{ -
161 return indexOf(name) >= 0;
executed: return indexOf(name) >= 0;
Execution Count:6
6
162} -
163void QSqlRecord::clearValues() -
164{ -
165 detach(); -
166 int count = d->fields.count(); -
167 for (int i = 0; i < count; ++i)
evaluated: i < count
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:24
24-72
168 d->fields[i].clear();
executed: d->fields[i].clear();
Execution Count:72
72
169}
executed: }
Execution Count:24
24
170void QSqlRecord::setGenerated(const QString& name, bool generated) -
171{ -
172 setGenerated(indexOf(name), generated); -
173}
executed: }
Execution Count:2
2
174void QSqlRecord::setGenerated(int index, bool generated) -
175{ -
176 if (!d->contains(index))
evaluated: !d->contains(index)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1678
6-1678
177 return;
executed: return;
Execution Count:6
6
178 detach(); -
179 d->fields[index].setGenerated(generated); -
180}
executed: }
Execution Count:1678
1678
181 -
182 -
183 -
184 -
185 -
186 -
187 -
188bool QSqlRecord::isNull(int index) const -
189{ -
190 return d->fields.value(index).isNull();
executed: return d->fields.value(index).isNull();
Execution Count:406
406
191} -
192 -
193 -
194 -
195 -
196 -
197 -
198 -
199bool QSqlRecord::isNull(const QString& name) const -
200{ -
201 return isNull(indexOf(name));
executed: return isNull(indexOf(name));
Execution Count:20
20
202} -
203 -
204 -
205 -
206 -
207 -
208 -
209 -
210void QSqlRecord::setNull(int index) -
211{ -
212 if (!d->contains(index))
evaluated: !d->contains(index)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:48
4-48
213 return;
executed: return;
Execution Count:4
4
214 detach(); -
215 d->fields[index].clear(); -
216}
executed: }
Execution Count:48
48
217 -
218 -
219 -
220 -
221 -
222 -
223 -
224void QSqlRecord::setNull(const QString& name) -
225{ -
226 setNull(indexOf(name)); -
227}
executed: }
Execution Count:10
10
228bool QSqlRecord::isGenerated(const QString& name) const -
229{ -
230 return isGenerated(indexOf(name));
executed: return isGenerated(indexOf(name));
Execution Count:16
16
231} -
232bool QSqlRecord::isGenerated(int index) const -
233{ -
234 return d->fields.value(index).isGenerated();
executed: return d->fields.value(index).isGenerated();
Execution Count:8263
8263
235} -
236 -
237 -
238 -
239 -
240 -
241 -
242 -
243int QSqlRecord::count() const -
244{ -
245 return d->fields.count();
executed: return d->fields.count();
Execution Count:146899
146899
246} -
247void QSqlRecord::setValue(int index, const QVariant& val) -
248{ -
249 if (!d->contains(index))
evaluated: !d->contains(index)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1483
2-1483
250 return;
executed: return;
Execution Count:2
2
251 detach(); -
252 d->fields[index].setValue(val); -
253}
executed: }
Execution Count:1483
1483
254void QSqlRecord::setValue(const QString& name, const QVariant& val) -
255{ -
256 setValue(indexOf(name), val); -
257}
executed: }
Execution Count:15
15
258 -
259 -
260 -
261 -
262void QSqlRecord::detach() -
263{ -
264 qAtomicDetach(d); -
265}
executed: }
Execution Count:133419
133419
266 -
267 -
268QDebug operator<<(QDebug dbg, const QSqlRecord &r) -
269{ -
270 dbg << "QSqlRecord(" << r.count() << ')'; -
271 for (int i = 0; i < r.count(); ++i)
never evaluated: i < r.count()
0
272 dbg << '\n' << QString::fromLatin1("%1:").arg(i, 2) << r.field(i) << r.value(i).toString();
never executed: dbg << '\n' << QString::fromLatin1("%1:").arg(i, 2) << r.field(i) << r.value(i).toString();
0
273 return dbg;
never executed: return dbg;
0
274} -
275 -
276 -
277 -
278 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial