io/qiodevice.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7QIODevicePrivate::QIODevicePrivate() -
8 : openMode(QIODevice::NotOpen), buffer(static_cast<long long>(16384LL)), -
9 pos(0), devicePos(0), seqDumpPos(0) -
10 , pPos(&pos), pDevicePos(&devicePos) -
11 , baseReadLineDataCalled(false) -
12 , firstRead(true) -
13 , accessMode(Unset) -
14 -
15 -
16 -
17{ -
18}
executed: }
Execution Count:39960
39960
19 -
20 -
21 -
22 -
23QIODevicePrivate::~QIODevicePrivate() -
24{ -
25} -
26QIODevice::QIODevice() -
27 : QObject(*new QIODevicePrivate, 0) -
28{ -
29 -
30 -
31 -
32 -
33 -
34}
executed: }
Execution Count:34
34
35 -
36 -
37 -
38 -
39 -
40QIODevice::QIODevice(QObject *parent) -
41 : QObject(*new QIODevicePrivate, parent) -
42{ -
43 -
44 -
45 -
46}
executed: }
Execution Count:11
11
47 -
48 -
49 -
50 -
51QIODevice::QIODevice(QIODevicePrivate &dd, QObject *parent) -
52 : QObject(dd, parent) -
53{ -
54}
executed: }
Execution Count:39915
39915
55QIODevice::~QIODevice() -
56{ -
57 -
58 -
59 -
60} -
61bool QIODevice::isSequential() const -
62{ -
63 return false;
executed: return false;
Execution Count:8352
8352
64} -
65 -
66 -
67 -
68 -
69 -
70 -
71 -
72QIODevice::OpenMode QIODevice::openMode() const -
73{ -
74 return d_func()->openMode;
executed: return d_func()->openMode;
Execution Count:6601
6601
75} -
76void QIODevice::setOpenMode(OpenMode openMode) -
77{ -
78 QIODevicePrivate * const d = d_func(); -
79 -
80 -
81 -
82 d->openMode = openMode; -
83 d->accessMode = QIODevicePrivate::Unset; -
84 d->firstRead = true; -
85 if (!isReadable())
evaluated: !isReadable()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:108
2-108
86 d->buffer.clear();
executed: d->buffer.clear();
Execution Count:2
2
87}
executed: }
Execution Count:110
110
88void QIODevice::setTextModeEnabled(bool enabled) -
89{ -
90 QIODevicePrivate * const d = d_func(); -
91 if (!isOpen()) {
partially evaluated: !isOpen()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:82078611
0-82078611
92 QMessageLogger("io/qiodevice.cpp", 467, __PRETTY_FUNCTION__).warning("QIODevice::setTextModeEnabled: The device is not open"); -
93 return;
never executed: return;
0
94 } -
95 if (enabled)
evaluated: enabled
TRUEFALSE
yes
Evaluation Count:41038132
yes
Evaluation Count:41040479
41038132-41040479
96 d->openMode |= Text;
executed: d->openMode |= Text;
Execution Count:41038132
41038132
97 else -
98 d->openMode &= ~Text;
executed: d->openMode &= ~Text;
Execution Count:41040479
41040479
99} -
100 -
101 -
102 -
103 -
104 -
105 -
106bool QIODevice::isTextModeEnabled() const -
107{ -
108 return d_func()->openMode & Text;
executed: return d_func()->openMode & Text;
Execution Count:41042456
41042456
109} -
110bool QIODevice::isOpen() const -
111{ -
112 return d_func()->openMode != NotOpen;
executed: return d_func()->openMode != NotOpen;
Execution Count:82403739
82403739
113} -
114bool QIODevice::isReadable() const -
115{ -
116 return (openMode() & ReadOnly) != 0;
executed: return (openMode() & ReadOnly) != 0;
Execution Count:4769
4769
117} -
118bool QIODevice::isWritable() const -
119{ -
120 return (openMode() & WriteOnly) != 0;
executed: return (openMode() & WriteOnly) != 0;
Execution Count:1806
1806
121} -
122bool QIODevice::open(OpenMode mode) -
123{ -
124 QIODevicePrivate * const d = d_func(); -
125 d->openMode = mode; -
126 d->pos = (mode & Append) ? size() : qint64(0);
evaluated: (mode & Append)
TRUEFALSE
yes
Evaluation Count:274
yes
Evaluation Count:31302
274-31302
127 d->buffer.clear(); -
128 d->accessMode = QIODevicePrivate::Unset; -
129 d->firstRead = true; -
130 -
131 -
132 -
133 return true;
executed: return true;
Execution Count:31576
31576
134} -
135 -
136 -
137 -
138 -
139 -
140 -
141 -
142void QIODevice::close() -
143{ -
144 QIODevicePrivate * const d = d_func(); -
145 if (d->openMode == NotOpen)
evaluated: d->openMode == NotOpen
TRUEFALSE
yes
Evaluation Count:3627
yes
Evaluation Count:22074
3627-22074
146 return;
executed: return;
Execution Count:3627
3627
147 -
148 -
149 -
150 -
151 -
152 -
153 aboutToClose(); -
154 -
155 d->openMode = NotOpen; -
156 d->errorString.clear(); -
157 d->pos = 0; -
158 d->seqDumpPos = 0; -
159 d->buffer.clear(); -
160 d->firstRead = true; -
161}
executed: }
Execution Count:22074
22074
162qint64 QIODevice::pos() const -
163{ -
164 const QIODevicePrivate * const d = d_func(); -
165 -
166 -
167 -
168 return d->pos;
executed: return d->pos;
Execution Count:460014
460014
169} -
170qint64 QIODevice::size() const -
171{ -
172 return d_func()->isSequential() ? bytesAvailable() : qint64(0);
executed: return d_func()->isSequential() ? bytesAvailable() : qint64(0);
Execution Count:69
69
173} -
174bool QIODevice::seek(qint64 pos) -
175{ -
176 QIODevicePrivate * const d = d_func(); -
177 if (d->isSequential()) {
evaluated: d->isSequential()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:262918
1-262918
178 QMessageLogger("io/qiodevice.cpp", 627, __PRETTY_FUNCTION__).warning("QIODevice::seek: Cannot call seek on a sequential device"); -
179 return false;
executed: return false;
Execution Count:1
1
180 } -
181 if (d->openMode == NotOpen) {
partially evaluated: d->openMode == NotOpen
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:262918
0-262918
182 QMessageLogger("io/qiodevice.cpp", 631, __PRETTY_FUNCTION__).warning("QIODevice::seek: The device is not open"); -
183 return false;
never executed: return false;
0
184 } -
185 if (pos < 0) {
partially evaluated: pos < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:262918
0-262918
186 QMessageLogger("io/qiodevice.cpp", 635, __PRETTY_FUNCTION__).warning("QIODevice::seek: Invalid pos: %d", int(pos)); -
187 return false;
never executed: return false;
0
188 } -
189 -
190 -
191 -
192 -
193 -
194 -
195 qint64 offset = pos - d->pos; -
196 d->pos = pos; -
197 d->devicePos = pos; -
198 -
199 if (offset < 0
evaluated: offset < 0
TRUEFALSE
yes
Evaluation Count:126245
yes
Evaluation Count:136673
126245-136673
200 || offset >= qint64(d->buffer.size()))
evaluated: offset >= qint64(d->buffer.size())
TRUEFALSE
yes
Evaluation Count:117886
yes
Evaluation Count:18787
18787-117886
201 -
202 -
203 -
204 -
205 d->buffer.clear();
executed: d->buffer.clear();
Execution Count:244131
244131
206 else if (!d->buffer.isEmpty())
partially evaluated: !d->buffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:18787
no
Evaluation Count:0
0-18787
207 d->buffer.skip(int(offset));
executed: d->buffer.skip(int(offset));
Execution Count:18787
18787
208 -
209 -
210 -
211 -
212 -
213 return true;
executed: return true;
Execution Count:262918
262918
214} -
215bool QIODevice::atEnd() const -
216{ -
217 const QIODevicePrivate * const d = d_func(); -
218 -
219 -
220 -
221 -
222 return d->openMode == NotOpen || (d->buffer.isEmpty() && bytesAvailable() == 0);
executed: return d->openMode == NotOpen || (d->buffer.isEmpty() && bytesAvailable() == 0);
Execution Count:5530
5530
223} -
224bool QIODevice::reset() -
225{ -
226 -
227 -
228 -
229 return seek(0);
executed: return seek(0);
Execution Count:102
102
230} -
231qint64 QIODevice::bytesAvailable() const -
232{ -
233 const QIODevicePrivate * const d = d_func(); -
234 if (!d->isSequential())
evaluated: !d->isSequential()
TRUEFALSE
yes
Evaluation Count:5587
yes
Evaluation Count:45931
5587-45931
235 return qMax(size() - d->pos, qint64(0));
executed: return qMax(size() - d->pos, qint64(0));
Execution Count:5587
5587
236 return d->buffer.size();
executed: return d->buffer.size();
Execution Count:45932
45932
237} -
238qint64 QIODevice::bytesToWrite() const -
239{ -
240 return qint64(0);
never executed: return qint64(0);
0
241} -
242qint64 QIODevice::read(char *data, qint64 maxSize) -
243{ -
244 QIODevicePrivate * const d = d_func(); -
245 -
246 -
247 -
248 -
249 -
250 -
251 -
252 if (maxSize == 1) {
evaluated: maxSize == 1
TRUEFALSE
yes
Evaluation Count:43557679
yes
Evaluation Count:327886
327886-43557679
253 int chint; -
254 while ((chint = d->buffer.getChar()) != -1) {
evaluated: (chint = d->buffer.getChar()) != -1
TRUEFALSE
yes
Evaluation Count:43410030
yes
Evaluation Count:147786
147786-43410030
255 ++(*d->pPos); -
256 -
257 char c = char(uchar(chint)); -
258 if (c == '\r' && (d->openMode & Text))
evaluated: c == '\r'
TRUEFALSE
yes
Evaluation Count:16062
yes
Evaluation Count:43393968
evaluated: (d->openMode & Text)
TRUEFALSE
yes
Evaluation Count:137
yes
Evaluation Count:15925
137-43393968
259 continue;
executed: continue;
Execution Count:137
137
260 *data = c; -
261 -
262 -
263 -
264 -
265 if (d->buffer.isEmpty())
evaluated: d->buffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:2949
yes
Evaluation Count:43406944
2949-43406944
266 readData(data, 0);
executed: readData(data, 0);
Execution Count:2949
2949
267 return qint64(1);
executed: return qint64(1);
Execution Count:43409893
43409893
268 } -
269 }
executed: }
Execution Count:147786
147786
270 -
271 do { if (maxSize < 0) { QMessageLogger("io/qiodevice.cpp", 786, __PRETTY_FUNCTION__).warning("QIODevice::""read"": Called with maxSize < 0"); return qint64(-1); } } while (0);
partially evaluated: maxSize < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:475672
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:475672
never executed: return qint64(-1);
executed: }
Execution Count:475672
0-475672
272 qint64 readSoFar = 0; -
273 bool moreToRead = true; -
274 do { -
275 -
276 int lastReadChunkSize = d->buffer.read(data, maxSize); -
277 if (lastReadChunkSize > 0) {
evaluated: lastReadChunkSize > 0
TRUEFALSE
yes
Evaluation Count:216588
yes
Evaluation Count:259102
216588-259102
278 *d->pPos += lastReadChunkSize; -
279 readSoFar += lastReadChunkSize; -
280 -
281 if (lastReadChunkSize == maxSize && !(d->openMode & Text)) {
evaluated: lastReadChunkSize == maxSize
TRUEFALSE
yes
Evaluation Count:197649
yes
Evaluation Count:18939
evaluated: !(d->openMode & Text)
TRUEFALSE
yes
Evaluation Count:197643
yes
Evaluation Count:6
6-197649
282 if (d->buffer.isEmpty()) {
evaluated: d->buffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:6085
yes
Evaluation Count:191558
6085-191558
283 d->buffer.clear(); -
284 readData(data, 0); -
285 }
executed: }
Execution Count:6085
6085
286 return readSoFar;
executed: return readSoFar;
Execution Count:197643
197643
287 } -
288 -
289 data += lastReadChunkSize; -
290 maxSize -= lastReadChunkSize; -
291 -
292 -
293 -
294 -
295 } else {
executed: }
Execution Count:18945
18945
296 if (d->firstRead) {
evaluated: d->firstRead
TRUEFALSE
yes
Evaluation Count:19231
yes
Evaluation Count:239871
19231-239871
297 -
298 -
299 do { if ((d->openMode & ReadOnly) == 0) { if (d->openMode == NotOpen) return qint64(-1); QMessageLogger("io/qiodevice.cpp", 814, __PRETTY_FUNCTION__).warning("QIODevice::""read"": WriteOnly device"); return qint64(-1); } } while (0);
evaluated: (d->openMode & ReadOnly) == 0
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:19204
evaluated: d->openMode == NotOpen
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:2
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19205
executed: return qint64(-1);
Execution Count:25
executed: return qint64(-1);
Execution Count:2
executed: }
Execution Count:19205
0-19205
300 d->firstRead = false; -
301 if (d->isSequential()) {
evaluated: d->isSequential()
TRUEFALSE
yes
Evaluation Count:2591
yes
Evaluation Count:16614
2591-16614
302 d->pPos = &d->seqDumpPos; -
303 d->pDevicePos = &d->seqDumpPos; -
304 }
executed: }
Execution Count:2591
2591
305 }
executed: }
Execution Count:19205
19205
306 -
307 if (!maxSize)
evaluated: !maxSize
TRUEFALSE
yes
Evaluation Count:1961
yes
Evaluation Count:257115
1961-257115
308 return readSoFar;
executed: return readSoFar;
Execution Count:1961
1961
309 -
310 if ((d->openMode & Unbuffered) == 0 && maxSize < static_cast<long long>(16384LL)) {
evaluated: (d->openMode & Unbuffered) == 0
TRUEFALSE
yes
Evaluation Count:118741
yes
Evaluation Count:138374
evaluated: maxSize < static_cast<long long>(16384LL)
TRUEFALSE
yes
Evaluation Count:103685
yes
Evaluation Count:15056
15056-138374
311 -
312 -
313 -
314 int bytesToBuffer = static_cast<long long>(16384LL); -
315 char *writePointer = d->buffer.reserve(bytesToBuffer); -
316 -
317 -
318 if (d->pos != d->devicePos && !d->isSequential() && !seek(d->pos))
evaluated: d->pos != d->devicePos
TRUEFALSE
yes
Evaluation Count:3357
yes
Evaluation Count:100328
evaluated: !d->isSequential()
TRUEFALSE
yes
Evaluation Count:420
yes
Evaluation Count:2937
partially evaluated: !seek(d->pos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:420
0-100328
319 return readSoFar ? readSoFar : qint64(-1);
never executed: return readSoFar ? readSoFar : qint64(-1);
0
320 qint64 readFromDevice = readData(writePointer, bytesToBuffer); -
321 d->buffer.chop(bytesToBuffer - (readFromDevice < 0 ? 0 : int(readFromDevice))); -
322 -
323 if (readFromDevice > 0) {
evaluated: readFromDevice > 0
TRUEFALSE
yes
Evaluation Count:39153
yes
Evaluation Count:64532
39153-64532
324 *d->pDevicePos += readFromDevice; -
325 -
326 -
327 -
328 -
329 if (!d->buffer.isEmpty()) {
evaluated: !d->buffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:39083
yes
Evaluation Count:70
70-39083
330 lastReadChunkSize = d->buffer.read(data, maxSize); -
331 readSoFar += lastReadChunkSize; -
332 data += lastReadChunkSize; -
333 maxSize -= lastReadChunkSize; -
334 *d->pPos += lastReadChunkSize; -
335 -
336 -
337 -
338 -
339 }
executed: }
Execution Count:39083
39083
340 }
executed: }
Execution Count:39153
39153
341 }
executed: }
Execution Count:103685
103685
342 }
executed: }
Execution Count:257115
257115
343 -
344 -
345 if (maxSize > 0) {
evaluated: maxSize > 0
TRUEFALSE
yes
Evaluation Count:239414
yes
Evaluation Count:36646
36646-239414
346 -
347 if (d->pos != d->devicePos && !d->isSequential() && !seek(d->pos))
evaluated: d->pos != d->devicePos
TRUEFALSE
yes
Evaluation Count:5340
yes
Evaluation Count:234073
evaluated: !d->isSequential()
TRUEFALSE
yes
Evaluation Count:491
yes
Evaluation Count:4849
partially evaluated: !seek(d->pos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:491
0-234073
348 return readSoFar ? readSoFar : qint64(-1);
never executed: return readSoFar ? readSoFar : qint64(-1);
0
349 qint64 readFromDevice = readData(data, maxSize); -
350 -
351 -
352 -
353 if (readFromDevice == -1 && readSoFar == 0) {
evaluated: readFromDevice == -1
TRUEFALSE
yes
Evaluation Count:4600
yes
Evaluation Count:234814
evaluated: readSoFar == 0
TRUEFALSE
yes
Evaluation Count:4590
yes
Evaluation Count:10
10-234814
354 -
355 return -1;
executed: return -1;
Execution Count:4590
4590
356 } -
357 if (readFromDevice > 0) {
evaluated: readFromDevice > 0
TRUEFALSE
yes
Evaluation Count:149898
yes
Evaluation Count:84926
84926-149898
358 lastReadChunkSize += int(readFromDevice); -
359 readSoFar += readFromDevice; -
360 data += readFromDevice; -
361 maxSize -= readFromDevice; -
362 *d->pPos += readFromDevice; -
363 *d->pDevicePos += readFromDevice; -
364 }
executed: }
Execution Count:149898
149898
365 }
executed: }
Execution Count:234824
234824
366 -
367 moreToRead = false; -
368 -
369 if (readSoFar && d->openMode & Text) {
evaluated: readSoFar
TRUEFALSE
yes
Evaluation Count:202502
yes
Evaluation Count:68968
evaluated: d->openMode & Text
TRUEFALSE
yes
Evaluation Count:824
yes
Evaluation Count:201678
824-202502
370 char *readPtr = data - lastReadChunkSize; -
371 const char *endPtr = data; -
372 -
373 if (readPtr < endPtr) {
evaluated: readPtr < endPtr
TRUEFALSE
yes
Evaluation Count:808
yes
Evaluation Count:16
16-808
374 -
375 while (*readPtr != '\r') {
evaluated: *readPtr != '\r'
TRUEFALSE
yes
Evaluation Count:2463955
yes
Evaluation Count:18
18-2463955
376 if (++readPtr == endPtr)
evaluated: ++readPtr == endPtr
TRUEFALSE
yes
Evaluation Count:790
yes
Evaluation Count:2463165
790-2463165
377 return readSoFar;
executed: return readSoFar;
Execution Count:790
790
378 }
executed: }
Execution Count:2463165
2463165
379 -
380 char *writePtr = readPtr; -
381 -
382 while (readPtr < endPtr) {
evaluated: readPtr < endPtr
TRUEFALSE
yes
Evaluation Count:5253
yes
Evaluation Count:18
18-5253
383 char ch = *readPtr++; -
384 if (ch != '\r')
evaluated: ch != '\r'
TRUEFALSE
yes
Evaluation Count:5168
yes
Evaluation Count:85
85-5168
385 *writePtr++ = ch;
executed: *writePtr++ = ch;
Execution Count:5168
5168
386 else { -
387 --readSoFar; -
388 --data; -
389 ++maxSize; -
390 }
executed: }
Execution Count:85
85
391 } -
392 -
393 -
394 -
395 -
396 moreToRead = (readPtr != writePtr); -
397 }
executed: }
Execution Count:18
18
398 }
executed: }
Execution Count:34
34
399 } while (moreToRead);
evaluated: moreToRead
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:270662
executed: }
Execution Count:270680
18-270680
400 -
401 -
402 -
403 -
404 -
405 -
406 -
407 if (d->buffer.isEmpty())
evaluated: d->buffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:239931
yes
Evaluation Count:30731
30731-239931
408 readData(data, 0);
executed: readData(data, 0);
Execution Count:239931
239931
409 -
410 return readSoFar;
executed: return readSoFar;
Execution Count:270662
270662
411} -
412QByteArray QIODevice::read(qint64 maxSize) -
413{ -
414 QIODevicePrivate * const d = d_func(); -
415 QByteArray result; -
416 -
417 do { if (maxSize < 0) { QMessageLogger("io/qiodevice.cpp", 947, __PRETTY_FUNCTION__).warning("QIODevice::""read"": Called with maxSize < 0"); return result; } } while (0);
partially evaluated: maxSize < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49464
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49464
never executed: return result;
executed: }
Execution Count:49464
0-49464
418 -
419 -
420 -
421 -
422 -
423 (void)d;; -
424 -
425 -
426 if (maxSize != qint64(int(maxSize))) {
partially evaluated: maxSize != qint64(int(maxSize))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49464
0-49464
427 QMessageLogger("io/qiodevice.cpp", 957, __PRETTY_FUNCTION__).warning("QIODevice::read: maxSize argument exceeds QByteArray size limit"); -
428 maxSize = 2147483647; -
429 }
never executed: }
0
430 -
431 qint64 readBytes = 0; -
432 if (maxSize) {
evaluated: maxSize
TRUEFALSE
yes
Evaluation Count:49463
yes
Evaluation Count:1
1-49463
433 result.resize(int(maxSize)); -
434 if (!result.size()) {
partially evaluated: !result.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49463
0-49463
435 -
436 qint64 readResult; -
437 do { -
438 result.resize(int(qMin(maxSize, result.size() + static_cast<long long>(16384LL)))); -
439 readResult = read(result.data() + readBytes, result.size() - readBytes); -
440 if (readResult > 0 || readBytes == 0)
never evaluated: readResult > 0
never evaluated: readBytes == 0
0
441 readBytes += readResult;
never executed: readBytes += readResult;
0
442 } while (readResult == static_cast<long long>(16384LL));
never evaluated: readResult == static_cast<long long>(16384LL)
never executed: }
0
443 } else {
never executed: }
0
444 readBytes = read(result.data(), result.size()); -
445 }
executed: }
Execution Count:49463
49463
446 } -
447 -
448 if (readBytes <= 0)
evaluated: readBytes <= 0
TRUEFALSE
yes
Evaluation Count:93
yes
Evaluation Count:49371
93-49371
449 result.clear();
executed: result.clear();
Execution Count:93
93
450 else -
451 result.resize(int(readBytes));
executed: result.resize(int(readBytes));
Execution Count:49371
49371
452 -
453 return result;
executed: return result;
Execution Count:49464
49464
454} -
455QByteArray QIODevice::readAll() -
456{ -
457 QIODevicePrivate * const d = d_func(); -
458 -
459 -
460 -
461 -
462 -
463 QByteArray result; -
464 qint64 readBytes = 0; -
465 -
466 -
467 if (!(d->openMode & Text) && !d->buffer.isEmpty()) {
evaluated: !(d->openMode & Text)
TRUEFALSE
yes
Evaluation Count:9519
yes
Evaluation Count:606
evaluated: !d->buffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:1373
yes
Evaluation Count:8146
606-9519
468 result = d->buffer.readAll(); -
469 readBytes = result.size(); -
470 d->pos += readBytes; -
471 }
executed: }
Execution Count:1373
1373
472 -
473 qint64 theSize; -
474 if (d->isSequential() || (theSize = size()) == 0) {
evaluated: d->isSequential()
TRUEFALSE
yes
Evaluation Count:3665
yes
Evaluation Count:6460
evaluated: (theSize = size()) == 0
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:6440
20-6460
475 -
476 qint64 readResult; -
477 do { -
478 result.resize(result.size() + static_cast<long long>(16384LL)); -
479 readResult = read(result.data() + readBytes, result.size() - readBytes); -
480 if (readResult > 0 || readBytes == 0)
evaluated: readResult > 0
TRUEFALSE
yes
Evaluation Count:1887
yes
Evaluation Count:3685
evaluated: readBytes == 0
TRUEFALSE
yes
Evaluation Count:923
yes
Evaluation Count:2762
923-3685
481 readBytes += readResult;
executed: readBytes += readResult;
Execution Count:2810
2810
482 } while (readResult > 0);
evaluated: readResult > 0
TRUEFALSE
yes
Evaluation Count:1887
yes
Evaluation Count:3685
executed: }
Execution Count:5572
1887-5572
483 } else {
executed: }
Execution Count:3685
3685
484 -
485 -
486 result.resize(int(readBytes + theSize - d->pos)); -
487 readBytes += read(result.data() + readBytes, result.size() - readBytes); -
488 }
executed: }
Execution Count:6440
6440
489 -
490 if (readBytes <= 0)
evaluated: readBytes <= 0
TRUEFALSE
yes
Evaluation Count:2144
yes
Evaluation Count:7981
2144-7981
491 result.clear();
executed: result.clear();
Execution Count:2144
2144
492 else -
493 result.resize(int(readBytes));
executed: result.resize(int(readBytes));
Execution Count:7981
7981
494 -
495 return result;
executed: return result;
Execution Count:10125
10125
496} -
497qint64 QIODevice::readLine(char *data, qint64 maxSize) -
498{ -
499 QIODevicePrivate * const d = d_func(); -
500 if (maxSize < 2) {
evaluated: maxSize < 2
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:77493
5-77493
501 QMessageLogger("io/qiodevice.cpp", 1085, __PRETTY_FUNCTION__).warning("QIODevice::readLine: Called with maxSize < 2"); -
502 return qint64(-1);
executed: return qint64(-1);
Execution Count:5
5
503 } -
504 -
505 -
506 -
507 -
508 -
509 -
510 -
511 --maxSize; -
512 -
513 const bool sequential = d->isSequential(); -
514 -
515 qint64 readSoFar = 0; -
516 if (!d->buffer.isEmpty()) {
evaluated: !d->buffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:77057
yes
Evaluation Count:436
436-77057
517 readSoFar = d->buffer.readLine(data, maxSize); -
518 if (d->buffer.isEmpty())
evaluated: d->buffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:1223
yes
Evaluation Count:75834
1223-75834
519 readData(data,0);
executed: readData(data,0);
Execution Count:1223
1223
520 if (!sequential)
evaluated: !sequential
TRUEFALSE
yes
Evaluation Count:75882
yes
Evaluation Count:1175
1175-75882
521 d->pos += readSoFar;
executed: d->pos += readSoFar;
Execution Count:75882
75882
522 -
523 -
524 -
525 -
526 -
527 -
528 if (readSoFar && data[readSoFar - 1] == '\n') {
partially evaluated: readSoFar
TRUEFALSE
yes
Evaluation Count:77057
no
Evaluation Count:0
evaluated: data[readSoFar - 1] == '\n'
TRUEFALSE
yes
Evaluation Count:76407
yes
Evaluation Count:650
0-77057
529 if (d->openMode & Text) {
evaluated: d->openMode & Text
TRUEFALSE
yes
Evaluation Count:163
yes
Evaluation Count:76244
163-76244
530 -
531 if (readSoFar > 1 && data[readSoFar - 2] == '\r') {
partially evaluated: readSoFar > 1
TRUEFALSE
yes
Evaluation Count:163
no
Evaluation Count:0
evaluated: data[readSoFar - 2] == '\r'
TRUEFALSE
yes
Evaluation Count:161
yes
Evaluation Count:2
0-163
532 --readSoFar; -
533 data[readSoFar - 1] = '\n'; -
534 }
executed: }
Execution Count:161
161
535 }
executed: }
Execution Count:163
163
536 data[readSoFar] = '\0'; -
537 return readSoFar;
executed: return readSoFar;
Execution Count:76407
76407
538 } -
539 }
executed: }
Execution Count:650
650
540 -
541 if (d->pos != d->devicePos && !sequential && !seek(d->pos))
evaluated: d->pos != d->devicePos
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:1021
evaluated: !sequential
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:1
partially evaluated: !seek(d->pos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:64
0-1021
542 return qint64(-1);
never executed: return qint64(-1);
0
543 d->baseReadLineDataCalled = false; -
544 qint64 readBytes = readLineData(data + readSoFar, maxSize - readSoFar); -
545 -
546 -
547 -
548 -
549 -
550 -
551 -
552 if (readBytes < 0) {
evaluated: readBytes < 0
TRUEFALSE
yes
Evaluation Count:355
yes
Evaluation Count:731
355-731
553 data[readSoFar] = '\0'; -
554 return readSoFar ? readSoFar : -1;
executed: return readSoFar ? readSoFar : -1;
Execution Count:355
355
555 } -
556 readSoFar += readBytes; -
557 if (!d->baseReadLineDataCalled && !sequential) {
partially evaluated: !d->baseReadLineDataCalled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:731
never evaluated: !sequential
0-731
558 d->pos += readBytes; -
559 -
560 -
561 d->devicePos = qint64(-1); -
562 }
never executed: }
0
563 data[readSoFar] = '\0'; -
564 -
565 if (d->openMode & Text) {
evaluated: d->openMode & Text
TRUEFALSE
yes
Evaluation Count:178
yes
Evaluation Count:553
178-553
566 if (readSoFar > 1 && data[readSoFar - 1] == '\n' && data[readSoFar - 2] == '\r') {
partially evaluated: readSoFar > 1
TRUEFALSE
yes
Evaluation Count:178
no
Evaluation Count:0
evaluated: data[readSoFar - 1] == '\n'
TRUEFALSE
yes
Evaluation Count:146
yes
Evaluation Count:32
partially evaluated: data[readSoFar - 2] == '\r'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:146
0-178
567 data[readSoFar - 2] = '\n'; -
568 data[readSoFar - 1] = '\0'; -
569 --readSoFar; -
570 }
never executed: }
0
571 }
executed: }
Execution Count:178
178
572 -
573 -
574 -
575 -
576 -
577 -
578 return readSoFar;
executed: return readSoFar;
Execution Count:731
731
579} -
580QByteArray QIODevice::readLine(qint64 maxSize) -
581{ -
582 QIODevicePrivate * const d = d_func(); -
583 QByteArray result; -
584 -
585 do { if (maxSize < 0) { QMessageLogger("io/qiodevice.cpp", 1180, __PRETTY_FUNCTION__).warning("QIODevice::""readLine"": Called with maxSize < 0"); return result; } } while (0);
partially evaluated: maxSize < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21432
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21432
never executed: return result;
executed: }
Execution Count:21432
0-21432
586 -
587 -
588 -
589 -
590 -
591 (void)d;; -
592 -
593 -
594 if (maxSize > 2147483647) {
partially evaluated: maxSize > 2147483647
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21432
0-21432
595 QMessageLogger("io/qiodevice.cpp", 1190, __PRETTY_FUNCTION__).warning("QIODevice::read: maxSize argument exceeds QByteArray size limit"); -
596 maxSize = 2147483647; -
597 }
never executed: }
0
598 -
599 result.resize(int(maxSize)); -
600 qint64 readBytes = 0; -
601 if (!result.size()) {
evaluated: !result.size()
TRUEFALSE
yes
Evaluation Count:21423
yes
Evaluation Count:9
9-21423
602 -
603 if (maxSize == 0)
partially evaluated: maxSize == 0
TRUEFALSE
yes
Evaluation Count:21423
no
Evaluation Count:0
0-21423
604 maxSize = 2147483647;
executed: maxSize = 2147483647;
Execution Count:21423
21423
605 -
606 -
607 result.resize(1); -
608 -
609 qint64 readResult; -
610 do { -
611 result.resize(int(qMin(maxSize, result.size() + static_cast<long long>(16384LL)))); -
612 readResult = readLine(result.data() + readBytes, result.size() - readBytes); -
613 if (readResult > 0 || readBytes == 0)
evaluated: readResult > 0
TRUEFALSE
yes
Evaluation Count:21406
yes
Evaluation Count:85
partially evaluated: readBytes == 0
TRUEFALSE
yes
Evaluation Count:85
no
Evaluation Count:0
0-21406
614 readBytes += readResult;
executed: readBytes += readResult;
Execution Count:21491
21491
615 } while (readResult == static_cast<long long>(16384LL)
executed: }
Execution Count:21491
evaluated: readResult == static_cast<long long>(16384LL)
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:21415
76-21491
616 && result[int(readBytes - 1)] != '\n');
evaluated: result[int(readBytes - 1)] != '\n'
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:8
8-68
617 } else
executed: }
Execution Count:21423
21423
618 readBytes = readLine(result.data(), result.size());
executed: readBytes = readLine(result.data(), result.size());
Execution Count:9
9
619 -
620 if (readBytes <= 0)
evaluated: readBytes <= 0
TRUEFALSE
yes
Evaluation Count:85
yes
Evaluation Count:21347
85-21347
621 result.clear();
executed: result.clear();
Execution Count:85
85
622 else -
623 result.resize(readBytes);
executed: result.resize(readBytes);
Execution Count:21347
21347
624 -
625 return result;
executed: return result;
Execution Count:21432
21432
626} -
627qint64 QIODevice::readLineData(char *data, qint64 maxSize) -
628{ -
629 QIODevicePrivate * const d = d_func(); -
630 qint64 readSoFar = 0; -
631 char c; -
632 int lastReadReturn = 0; -
633 d->baseReadLineDataCalled = true; -
634 -
635 while (readSoFar < maxSize && (lastReadReturn = read(&c, 1)) == 1) {
evaluated: readSoFar < maxSize
TRUEFALSE
yes
Evaluation Count:837125
yes
Evaluation Count:87
evaluated: (lastReadReturn = read(&c, 1)) == 1
TRUEFALSE
yes
Evaluation Count:836792
yes
Evaluation Count:333
87-837125
636 *data++ = c; -
637 ++readSoFar; -
638 if (c == '\n')
evaluated: c == '\n'
TRUEFALSE
yes
Evaluation Count:658
yes
Evaluation Count:836134
658-836134
639 break;
executed: break;
Execution Count:658
658
640 }
executed: }
Execution Count:836134
836134
641 -
642 -
643 -
644 -
645 -
646 if (lastReadReturn != 1 && readSoFar == 0)
evaluated: lastReadReturn != 1
TRUEFALSE
yes
Evaluation Count:350
yes
Evaluation Count:728
evaluated: readSoFar == 0
TRUEFALSE
yes
Evaluation Count:349
yes
Evaluation Count:1
1-728
647 return isSequential() ? lastReadReturn : -1;
executed: return isSequential() ? lastReadReturn : -1;
Execution Count:349
349
648 return readSoFar;
executed: return readSoFar;
Execution Count:729
729
649} -
650bool QIODevice::canReadLine() const -
651{ -
652 return d_func()->buffer.canReadLine();
executed: return d_func()->buffer.canReadLine();
Execution Count:586
586
653} -
654qint64 QIODevice::write(const char *data, qint64 maxSize) -
655{ -
656 QIODevicePrivate * const d = d_func(); -
657 do { if ((d->openMode & WriteOnly) == 0) { if (d->openMode == NotOpen) return qint64(-1); QMessageLogger("io/qiodevice.cpp", 1300, __PRETTY_FUNCTION__).warning("QIODevice::""write"": ReadOnly device"); return qint64(-1); } } while (0);
executed: return qint64(-1);
Execution Count:2
executed: return qint64(-1);
Execution Count:1
executed: }
Execution Count:1577757
evaluated: (d->openMode & WriteOnly) == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1577757
evaluated: d->openMode == NotOpen
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1577757
0-1577757
658 do { if (maxSize < 0) { QMessageLogger("io/qiodevice.cpp", 1301, __PRETTY_FUNCTION__).warning("QIODevice::""write"": Called with maxSize < 0"); return qint64(-1); } } while (0);
never executed: return qint64(-1);
executed: }
Execution Count:1577757
partially evaluated: maxSize < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1577757
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1577757
0-1577757
659 -
660 const bool sequential = d->isSequential(); -
661 -
662 if (d->pos != d->devicePos && !sequential && !seek(d->pos))
evaluated: d->pos != d->devicePos
TRUEFALSE
yes
Evaluation Count:12956
yes
Evaluation Count:1564801
evaluated: !sequential
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:12910
partially evaluated: !seek(d->pos)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-1564801
663 return qint64(-1);
never executed: return qint64(-1);
0
664 qint64 written = writeData(data, maxSize); -
665 if (written > 0) {
evaluated: written > 0
TRUEFALSE
yes
Evaluation Count:1575555
yes
Evaluation Count:2202
2202-1575555
666 if (!sequential) {
evaluated: !sequential
TRUEFALSE
yes
Evaluation Count:274402
yes
Evaluation Count:1301153
274402-1301153
667 d->pos += written; -
668 d->devicePos += written; -
669 }
executed: }
Execution Count:274402
274402
670 if (!d->buffer.isEmpty() && !sequential)
evaluated: !d->buffer.isEmpty()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1575544
evaluated: !sequential
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:9
2-1575544
671 d->buffer.skip(written);
executed: d->buffer.skip(written);
Execution Count:2
2
672 }
executed: }
Execution Count:1575555
1575555
673 return written;
executed: return written;
Execution Count:1577757
1577757
674} -
675qint64 QIODevice::write(const char *data) -
676{ -
677 return write(data, qstrlen(data));
executed: return write(data, qstrlen(data));
Execution Count:2913
2913
678} -
679void QIODevice::ungetChar(char c) -
680{ -
681 QIODevicePrivate * const d = d_func(); -
682 do { if ((d->openMode & ReadOnly) == 0) { if (d->openMode == NotOpen) return ; QMessageLogger("io/qiodevice.cpp", 1414, __PRETTY_FUNCTION__).warning("QIODevice::""read"": WriteOnly device"); return ; } } while (0);
never executed: return ;
never executed: return ;
executed: }
Execution Count:36147
partially evaluated: (d->openMode & ReadOnly) == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36147
never evaluated: d->openMode == NotOpen
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36147
0-36147
683 -
684 -
685 -
686 -
687 -
688 d->buffer.ungetChar(c); -
689 if (!d->isSequential())
evaluated: !d->isSequential()
TRUEFALSE
yes
Evaluation Count:35697
yes
Evaluation Count:450
450-35697
690 --d->pos;
executed: --d->pos;
Execution Count:35697
35697
691}
executed: }
Execution Count:36147
36147
692bool QIODevice::putChar(char c) -
693{ -
694 return d_func()->putCharHelper(c);
executed: return d_func()->putCharHelper(c);
Execution Count:18740
18740
695} -
696 -
697 -
698 -
699 -
700bool QIODevicePrivate::putCharHelper(char c) -
701{ -
702 return q_func()->write(&c, 1) == 1;
executed: return q_func()->write(&c, 1) == 1;
Execution Count:17436
17436
703} -
704 -
705 -
706 -
707 -
708qint64 QIODevicePrivate::peek(char *data, qint64 maxSize) -
709{ -
710 qint64 readBytes = q_func()->read(data, maxSize); -
711 if (readBytes <= 0)
evaluated: readBytes <= 0
TRUEFALSE
yes
Evaluation Count:680
yes
Evaluation Count:4506
680-4506
712 return readBytes;
executed: return readBytes;
Execution Count:680
680
713 -
714 buffer.ungetBlock(data, readBytes); -
715 *pPos -= readBytes; -
716 return readBytes;
executed: return readBytes;
Execution Count:4506
4506
717} -
718 -
719 -
720 -
721 -
722QByteArray QIODevicePrivate::peek(qint64 maxSize) -
723{ -
724 QByteArray result = q_func()->read(maxSize); -
725 -
726 if (result.isEmpty())
evaluated: result.isEmpty()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:533
7-533
727 return result;
executed: return result;
Execution Count:7
7
728 -
729 buffer.ungetBlock(result.constData(), result.size()); -
730 *pPos -= result.size(); -
731 return result;
executed: return result;
Execution Count:533
533
732} -
733bool QIODevice::getChar(char *c) -
734{ -
735 -
736 char ch; -
737 return (1 == read(c ? c : &ch, 1));
executed: return (1 == read(c ? c : &ch, 1));
Execution Count:1466285
1466285
738} -
739qint64 QIODevice::peek(char *data, qint64 maxSize) -
740{ -
741 return d_func()->peek(data, maxSize);
executed: return d_func()->peek(data, maxSize);
Execution Count:6634
6634
742} -
743QByteArray QIODevice::peek(qint64 maxSize) -
744{ -
745 return d_func()->peek(maxSize);
executed: return d_func()->peek(maxSize);
Execution Count:724
724
746} -
747bool QIODevice::waitForReadyRead(int msecs) -
748{ -
749 (void)msecs;; -
750 return false;
executed: return false;
Execution Count:325
325
751} -
752bool QIODevice::waitForBytesWritten(int msecs) -
753{ -
754 (void)msecs;; -
755 return false;
never executed: return false;
0
756} -
757 -
758 -
759 -
760 -
761 -
762 -
763 -
764void QIODevice::setErrorString(const QString &str) -
765{ -
766 d_func()->errorString = str; -
767}
executed: }
Execution Count:1693
1693
768 -
769 -
770 -
771 -
772 -
773 -
774 -
775QString QIODevice::errorString() const -
776{ -
777 const QIODevicePrivate * const d = d_func(); -
778 if (d->errorString.isEmpty()) {
evaluated: d->errorString.isEmpty()
TRUEFALSE
yes
Evaluation Count:3061
yes
Evaluation Count:388
388-3061
779 -
780 -
781 -
782 return tr("Unknown error");
executed: return tr("Unknown error");
Execution Count:3061
3061
783 -
784 } -
785 return d->errorString;
executed: return d->errorString;
Execution Count:388
388
786} -
787QDebug operator<<(QDebug debug, QIODevice::OpenMode modes) -
788{ -
789 debug << "OpenMode("; -
790 QStringList modeList; -
791 if (modes == QIODevice::NotOpen) {
never evaluated: modes == QIODevice::NotOpen
0
792 modeList << QLatin1String("NotOpen"); -
793 } else {
never executed: }
0
794 if (modes & QIODevice::ReadOnly)
never evaluated: modes & QIODevice::ReadOnly
0
795 modeList << QLatin1String("ReadOnly");
never executed: modeList << QLatin1String("ReadOnly");
0
796 if (modes & QIODevice::WriteOnly)
never evaluated: modes & QIODevice::WriteOnly
0
797 modeList << QLatin1String("WriteOnly");
never executed: modeList << QLatin1String("WriteOnly");
0
798 if (modes & QIODevice::Append)
never evaluated: modes & QIODevice::Append
0
799 modeList << QLatin1String("Append");
never executed: modeList << QLatin1String("Append");
0
800 if (modes & QIODevice::Truncate)
never evaluated: modes & QIODevice::Truncate
0
801 modeList << QLatin1String("Truncate");
never executed: modeList << QLatin1String("Truncate");
0
802 if (modes & QIODevice::Text)
never evaluated: modes & QIODevice::Text
0
803 modeList << QLatin1String("Text");
never executed: modeList << QLatin1String("Text");
0
804 if (modes & QIODevice::Unbuffered)
never evaluated: modes & QIODevice::Unbuffered
0
805 modeList << QLatin1String("Unbuffered");
never executed: modeList << QLatin1String("Unbuffered");
0
806 }
never executed: }
0
807 qSort(modeList); -
808 debug << modeList.join(QLatin1Char('|')); -
809 debug << ')'; -
810 return debug;
never executed: return debug;
0
811} -
812 -
813 -
814 -
815 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial