Line | Source Code | Coverage |
---|
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 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 | | - |
18 | QSqlRecordPrivate::QSqlRecordPrivate() : ref(1) | - |
19 | { | - |
20 | } executed: } Execution Count:15173 | 15173 |
21 | | - |
22 | QSqlRecordPrivate::QSqlRecordPrivate(const QSqlRecordPrivate &other): fields(other.fields), ref(1) | - |
23 | { | - |
24 | } executed: } Execution Count:1018 | 1018 |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | QString 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 | } | - |
37 | QSqlRecord::QSqlRecord() | - |
38 | { | - |
39 | d = new QSqlRecordPrivate(); | - |
40 | } executed: } Execution Count:15173 | 15173 |
41 | QSqlRecord::QSqlRecord(const QSqlRecord& other) | - |
42 | { | - |
43 | d = other.d; | - |
44 | d->ref.ref(); | - |
45 | } executed: } Execution Count:20181 | 20181 |
46 | QSqlRecord& 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 | | - |
56 | QSqlRecord::~QSqlRecord() | - |
57 | { | - |
58 | if (!d->ref.deref()) evaluated: !d->ref.deref() 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 |
61 | bool 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 | } | - |
65 | QVariant 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 | } | - |
69 | QVariant QSqlRecord::value(const QString& name) const | - |
70 | { | - |
71 | return value(indexOf(name)); executed: return value(indexOf(name)); Execution Count:280 | 280 |
72 | } | - |
73 | QString 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 | } | - |
77 | int QSqlRecord::indexOf(const QString& name) const | - |
78 | { | - |
79 | QString nm = name.toUpper(); | - |
80 | for (int i = 0; i < count(); ++i) { evaluated: i < count() 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 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 | | - |
92 | QSqlField 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 | | - |
100 | QSqlField QSqlRecord::field(const QString &name) const | - |
101 | { | - |
102 | return field(indexOf(name)); executed: return field(indexOf(name)); Execution Count:280 | 280 |
103 | } | - |
104 | void 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 | | - |
115 | void QSqlRecord::insert(int pos, const QSqlField& field) | - |
116 | { | - |
117 | detach(); | - |
118 | d->fields.insert(pos, field); | - |
119 | } executed: } Execution Count:117 | 117 |
120 | void QSqlRecord::replace(int pos, const QSqlField& field) | - |
121 | { | - |
122 | if (!d->contains(pos)) partially evaluated: !d->contains(pos) no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-34 |
123 | return; | 0 |
124 | | - |
125 | detach(); | - |
126 | d->fields[pos] = field; | - |
127 | } executed: } Execution Count:34 | 34 |
128 | void QSqlRecord::remove(int pos) | - |
129 | { | - |
130 | if (!d->contains(pos)) evaluated: !d->contains(pos) 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 | | - |
143 | void QSqlRecord::clear() | - |
144 | { | - |
145 | detach(); | - |
146 | d->fields.clear(); | - |
147 | } executed: } Execution Count:124400 | 124400 |
148 | bool 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 | | - |
159 | bool QSqlRecord::contains(const QString& name) const | - |
160 | { | - |
161 | return indexOf(name) >= 0; executed: return indexOf(name) >= 0; Execution Count:6 | 6 |
162 | } | - |
163 | void QSqlRecord::clearValues() | - |
164 | { | - |
165 | detach(); | - |
166 | int count = d->fields.count(); | - |
167 | for (int i = 0; i < count; ++i) evaluated: i < count 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 |
170 | void QSqlRecord::setGenerated(const QString& name, bool generated) | - |
171 | { | - |
172 | setGenerated(indexOf(name), generated); | - |
173 | } executed: } Execution Count:2 | 2 |
174 | void QSqlRecord::setGenerated(int index, bool generated) | - |
175 | { | - |
176 | if (!d->contains(index)) evaluated: !d->contains(index) 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 | | - |
188 | bool 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 | | - |
199 | bool 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 | | - |
210 | void QSqlRecord::setNull(int index) | - |
211 | { | - |
212 | if (!d->contains(index)) evaluated: !d->contains(index) 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 | | - |
224 | void QSqlRecord::setNull(const QString& name) | - |
225 | { | - |
226 | setNull(indexOf(name)); | - |
227 | } executed: } Execution Count:10 | 10 |
228 | bool QSqlRecord::isGenerated(const QString& name) const | - |
229 | { | - |
230 | return isGenerated(indexOf(name)); executed: return isGenerated(indexOf(name)); Execution Count:16 | 16 |
231 | } | - |
232 | bool 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 | | - |
243 | int QSqlRecord::count() const | - |
244 | { | - |
245 | return d->fields.count(); executed: return d->fields.count(); Execution Count:146899 | 146899 |
246 | } | - |
247 | void QSqlRecord::setValue(int index, const QVariant& val) | - |
248 | { | - |
249 | if (!d->contains(index)) evaluated: !d->contains(index) 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 |
254 | void QSqlRecord::setValue(const QString& name, const QVariant& val) | - |
255 | { | - |
256 | setValue(indexOf(name), val); | - |
257 | } executed: } Execution Count:15 | 15 |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | void QSqlRecord::detach() | - |
263 | { | - |
264 | qAtomicDetach(d); | - |
265 | } executed: } Execution Count:133419 | 133419 |
266 | | - |
267 | | - |
268 | QDebug 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 | | - |
| | |