io/qnoncontiguousbytedevice.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qnoncontiguousbytedevice_p.h" -
43#include <qbuffer.h> -
44#include <qdebug.h> -
45#include <qfile.h> -
46 -
47QT_BEGIN_NAMESPACE -
48 -
49/*! -
50 \class QNonContiguousByteDevice -
51 \inmodule QtCore -
52 \brief A QNonContiguousByteDevice is a representation of a -
53 file, array or buffer that allows access with a read pointer. -
54 \since 4.6 -
55 -
56 The goal of this class is to have a data representation that -
57 allows us to avoid doing a memcpy as we have to do with QIODevice. -
58 -
59 \sa QNonContiguousByteDeviceFactory -
60 -
61 \internal -
62*/ -
63/*! -
64 \fn virtual const char* QNonContiguousByteDevice::readPointer(qint64 maximumLength, qint64 &len) -
65 -
66 Return a byte pointer for at most \a maximumLength bytes of that device. -
67 if \a maximumLength is -1, the caller does not care about the length and -
68 the device may return what it desires to. -
69 The actual number of bytes the pointer is valid for is returned in -
70 the \a len variable. -
71 \a len will be -1 if EOF or an error occurs. -
72 If it was really EOF can then afterwards be checked with atEnd() -
73 Returns 0 if it is not possible to read at that position. -
74 -
75 \sa atEnd() -
76 -
77 \internal -
78*/ -
79/*! -
80 \fn virtual bool QNonContiguousByteDevice::advanceReadPointer(qint64 amount) -
81 -
82 will advance the internal read pointer by \a amount bytes. -
83 The old readPointer is invalid after this call. -
84 -
85 \sa readPointer() -
86 -
87 \internal -
88*/ -
89/*! -
90 \fn virtual bool QNonContiguousByteDevice::atEnd() -
91 -
92 Returns true if everything has been read and the read -
93 pointer cannot be advanced anymore. -
94 -
95 \sa readPointer(), advanceReadPointer(), reset() -
96 -
97 \internal -
98*/ -
99/*! -
100 \fn virtual bool QNonContiguousByteDevice::reset() -
101 -
102 Moves the internal read pointer back to the beginning. -
103 Returns false if this was not possible. -
104 -
105 \sa atEnd(), disableReset() -
106 -
107 \internal -
108*/ -
109/*! -
110 \fn void QNonContiguousByteDevice::disableReset() -
111 -
112 Disable the reset() call, e.g. it will always -
113 do nothing and return false. -
114 -
115 \sa reset() -
116 -
117 \internal -
118*/ -
119/*! -
120 \fn virtual qint64 QNonContiguousByteDevice::size() -
121 -
122 Returns the size of the complete device or -1 if unknown. -
123 May also return less/more than what can be actually read with readPointer() -
124 -
125 \internal -
126*/ -
127/*! -
128 \fn void QNonContiguousByteDevice::readyRead() -
129 -
130 Emitted when there is data available -
131 -
132 \internal -
133*/ -
134/*! -
135 \fn void QNonContiguousByteDevice::readProgress(qint64 current, qint64 total) -
136 -
137 Emitted when data has been "read" by advancing the read pointer -
138 -
139 \internal -
140*/ -
141 -
142QNonContiguousByteDevice::QNonContiguousByteDevice() : QObject((QObject*)0), resetDisabled(false) -
143{ -
144}
executed: }
Execution Count:425
425
145 -
146QNonContiguousByteDevice::~QNonContiguousByteDevice() -
147{ -
148} -
149 -
150void QNonContiguousByteDevice::disableReset() -
151{ -
152 resetDisabled = true;
executed (the execution status of this line is deduced): resetDisabled = true;
-
153}
executed: }
Execution Count:2
2
154 -
155// FIXME we should scrap this whole implementation and instead change the ByteArrayImpl to be able to cope with sub-arrays? -
156QNonContiguousByteDeviceBufferImpl::QNonContiguousByteDeviceBufferImpl(QBuffer *b) : QNonContiguousByteDevice() -
157{ -
158 buffer = b;
executed (the execution status of this line is deduced): buffer = b;
-
159 byteArray = QByteArray::fromRawData(buffer->buffer().constData() + buffer->pos(), buffer->size() - buffer->pos());
executed (the execution status of this line is deduced): byteArray = QByteArray::fromRawData(buffer->buffer().constData() + buffer->pos(), buffer->size() - buffer->pos());
-
160 arrayImpl = new QNonContiguousByteDeviceByteArrayImpl(&byteArray);
executed (the execution status of this line is deduced): arrayImpl = new QNonContiguousByteDeviceByteArrayImpl(&byteArray);
-
161 arrayImpl->setParent(this);
executed (the execution status of this line is deduced): arrayImpl->setParent(this);
-
162 connect(arrayImpl, SIGNAL(readyRead()), SIGNAL(readyRead()));
executed (the execution status of this line is deduced): connect(arrayImpl, "2""readyRead()", "2""readyRead()");
-
163 connect(arrayImpl, SIGNAL(readProgress(qint64,qint64)), SIGNAL(readProgress(qint64,qint64)));
executed (the execution status of this line is deduced): connect(arrayImpl, "2""readProgress(qint64,qint64)", "2""readProgress(qint64,qint64)");
-
164}
executed: }
Execution Count:58
58
165 -
166QNonContiguousByteDeviceBufferImpl::~QNonContiguousByteDeviceBufferImpl() -
167{ -
168} -
169 -
170const char* QNonContiguousByteDeviceBufferImpl::readPointer(qint64 maximumLength, qint64 &len) -
171{ -
172 return arrayImpl->readPointer(maximumLength, len);
executed: return arrayImpl->readPointer(maximumLength, len);
Execution Count:1013
1013
173} -
174 -
175bool QNonContiguousByteDeviceBufferImpl::advanceReadPointer(qint64 amount) -
176{ -
177 return arrayImpl->advanceReadPointer(amount);
executed: return arrayImpl->advanceReadPointer(amount);
Execution Count:992
992
178} -
179 -
180bool QNonContiguousByteDeviceBufferImpl::atEnd() -
181{ -
182 return arrayImpl->atEnd();
executed: return arrayImpl->atEnd();
Execution Count:753
753
183} -
184 -
185bool QNonContiguousByteDeviceBufferImpl::reset() -
186{ -
187 if (resetDisabled)
partially evaluated: resetDisabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
188 return false;
never executed: return false;
0
189 return arrayImpl->reset();
executed: return arrayImpl->reset();
Execution Count:4
4
190} -
191 -
192qint64 QNonContiguousByteDeviceBufferImpl::size() -
193{ -
194 return arrayImpl->size();
executed: return arrayImpl->size();
Execution Count:802
802
195} -
196 -
197QNonContiguousByteDeviceByteArrayImpl::QNonContiguousByteDeviceByteArrayImpl(QByteArray *ba) : QNonContiguousByteDevice(), currentPosition(0) -
198{ -
199 byteArray = ba;
executed (the execution status of this line is deduced): byteArray = ba;
-
200}
executed: }
Execution Count:58
58
201 -
202QNonContiguousByteDeviceByteArrayImpl::~QNonContiguousByteDeviceByteArrayImpl() -
203{ -
204} -
205 -
206const char* QNonContiguousByteDeviceByteArrayImpl::readPointer(qint64 maximumLength, qint64 &len) -
207{ -
208 if (atEnd()) {
evaluated: atEnd()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:993
20-993
209 len = -1;
executed (the execution status of this line is deduced): len = -1;
-
210 return 0;
executed: return 0;
Execution Count:20
20
211 } -
212 -
213 if (maximumLength != -1)
evaluated: maximumLength != -1
TRUEFALSE
yes
Evaluation Count:987
yes
Evaluation Count:6
6-987
214 len = qMin(maximumLength, size() - currentPosition);
executed: len = qMin(maximumLength, size() - currentPosition);
Execution Count:987
987
215 else -
216 len = size() - currentPosition;
executed: len = size() - currentPosition;
Execution Count:6
6
217 -
218 return byteArray->constData() + currentPosition;
executed: return byteArray->constData() + currentPosition;
Execution Count:993
993
219} -
220 -
221bool QNonContiguousByteDeviceByteArrayImpl::advanceReadPointer(qint64 amount) -
222{ -
223 currentPosition += amount;
executed (the execution status of this line is deduced): currentPosition += amount;
-
224 emit readProgress(currentPosition, size());
executed (the execution status of this line is deduced): readProgress(currentPosition, size());
-
225 return true;
executed: return true;
Execution Count:992
992
226} -
227 -
228bool QNonContiguousByteDeviceByteArrayImpl::atEnd() -
229{ -
230 return currentPosition >= size();
executed: return currentPosition >= size();
Execution Count:1766
1766
231} -
232 -
233bool QNonContiguousByteDeviceByteArrayImpl::reset() -
234{ -
235 if (resetDisabled)
partially evaluated: resetDisabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
236 return false;
never executed: return false;
0
237 -
238 currentPosition = 0;
executed (the execution status of this line is deduced): currentPosition = 0;
-
239 return true;
executed: return true;
Execution Count:4
4
240} -
241 -
242qint64 QNonContiguousByteDeviceByteArrayImpl::size() -
243{ -
244 return byteArray->size();
executed: return byteArray->size();
Execution Count:4553
4553
245} -
246 -
247QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb) -
248 : QNonContiguousByteDevice(), currentPosition(0) -
249{ -
250 ringBuffer = rb;
executed (the execution status of this line is deduced): ringBuffer = rb;
-
251}
executed: }
Execution Count:101
101
252 -
253QNonContiguousByteDeviceRingBufferImpl::~QNonContiguousByteDeviceRingBufferImpl() -
254{ -
255} -
256 -
257const char* QNonContiguousByteDeviceRingBufferImpl::readPointer(qint64 maximumLength, qint64 &len) -
258{ -
259 if (atEnd()) {
partially evaluated: atEnd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:954
0-954
260 len = -1;
never executed (the execution status of this line is deduced): len = -1;
-
261 return 0;
never executed: return 0;
0
262 } -
263 -
264 const char *returnValue = ringBuffer->readPointerAtPosition(currentPosition, len);
executed (the execution status of this line is deduced): const char *returnValue = ringBuffer->readPointerAtPosition(currentPosition, len);
-
265 -
266 if (maximumLength != -1)
partially evaluated: maximumLength != -1
TRUEFALSE
yes
Evaluation Count:954
no
Evaluation Count:0
0-954
267 len = qMin(len, maximumLength);
executed: len = qMin(len, maximumLength);
Execution Count:954
954
268 -
269 return returnValue;
executed: return returnValue;
Execution Count:954
954
270} -
271 -
272bool QNonContiguousByteDeviceRingBufferImpl::advanceReadPointer(qint64 amount) -
273{ -
274 currentPosition += amount;
executed (the execution status of this line is deduced): currentPosition += amount;
-
275 emit readProgress(currentPosition, size());
executed (the execution status of this line is deduced): readProgress(currentPosition, size());
-
276 return true;
executed: return true;
Execution Count:954
954
277} -
278 -
279bool QNonContiguousByteDeviceRingBufferImpl::atEnd() -
280{ -
281 return currentPosition >= size();
executed: return currentPosition >= size();
Execution Count:1252
1252
282} -
283 -
284bool QNonContiguousByteDeviceRingBufferImpl::reset() -
285{ -
286 if (resetDisabled)
partially evaluated: resetDisabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:126
0-126
287 return false;
never executed: return false;
0
288 -
289 currentPosition = 0;
executed (the execution status of this line is deduced): currentPosition = 0;
-
290 return true;
executed: return true;
Execution Count:126
126
291} -
292 -
293qint64 QNonContiguousByteDeviceRingBufferImpl::size() -
294{ -
295 return ringBuffer->size();
executed: return ringBuffer->size();
Execution Count:2586
2586
296} -
297 -
298QNonContiguousByteDeviceIoDeviceImpl::QNonContiguousByteDeviceIoDeviceImpl(QIODevice *d) -
299 : QNonContiguousByteDevice(), -
300 currentReadBuffer(0), currentReadBufferSize(16*1024), -
301 currentReadBufferAmount(0), currentReadBufferPosition(0), totalAdvancements(0), -
302 eof(false) -
303{ -
304 device = d;
executed (the execution status of this line is deduced): device = d;
-
305 initialPosition = d->pos();
executed (the execution status of this line is deduced): initialPosition = d->pos();
-
306 connect(device, SIGNAL(readyRead()), this, SIGNAL(readyRead()), Qt::QueuedConnection);
executed (the execution status of this line is deduced): connect(device, "2""readyRead()", this, "2""readyRead()", Qt::QueuedConnection);
-
307 connect(device, SIGNAL(readChannelFinished()), this, SIGNAL(readyRead()), Qt::QueuedConnection);
executed (the execution status of this line is deduced): connect(device, "2""readChannelFinished()", this, "2""readyRead()", Qt::QueuedConnection);
-
308}
executed: }
Execution Count:70
70
309 -
310QNonContiguousByteDeviceIoDeviceImpl::~QNonContiguousByteDeviceIoDeviceImpl() -
311{ -
312 delete currentReadBuffer;
executed (the execution status of this line is deduced): delete currentReadBuffer;
-
313}
executed: }
Execution Count:70
70
314 -
315const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLength, qint64 &len) -
316{ -
317 if (eof == true) {
evaluated: eof == true
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1658
3-1658
318 len = -1;
executed (the execution status of this line is deduced): len = -1;
-
319 return 0;
executed: return 0;
Execution Count:3
3
320 } -
321 -
322 if (currentReadBuffer == 0)
evaluated: currentReadBuffer == 0
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:1590
68-1590
323 currentReadBuffer = new QByteArray(currentReadBufferSize, '\0'); // lazy alloc
executed: currentReadBuffer = new QByteArray(currentReadBufferSize, '\0');
Execution Count:68
68
324 -
325 if (maximumLength == -1)
evaluated: maximumLength == -1
TRUEFALSE
yes
Evaluation Count:718
yes
Evaluation Count:940
718-940
326 maximumLength = currentReadBufferSize;
executed: maximumLength = currentReadBufferSize;
Execution Count:718
718
327 -
328 if (currentReadBufferAmount - currentReadBufferPosition > 0) {
partially evaluated: currentReadBufferAmount - currentReadBufferPosition > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1658
0-1658
329 len = currentReadBufferAmount - currentReadBufferPosition;
never executed (the execution status of this line is deduced): len = currentReadBufferAmount - currentReadBufferPosition;
-
330 return currentReadBuffer->data() + currentReadBufferPosition;
never executed: return currentReadBuffer->data() + currentReadBufferPosition;
0
331 } -
332 -
333 qint64 haveRead = device->read(currentReadBuffer->data(), qMin(maximumLength, currentReadBufferSize));
executed (the execution status of this line is deduced): qint64 haveRead = device->read(currentReadBuffer->data(), qMin(maximumLength, currentReadBufferSize));
-
334 -
335 if ((haveRead == -1) || (haveRead == 0 && device->atEnd() && !device->isSequential())) {
evaluated: (haveRead == -1)
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:1630
evaluated: haveRead == 0
TRUEFALSE
yes
Evaluation Count:119
yes
Evaluation Count:1511
evaluated: device->atEnd()
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:2
evaluated: !device->isSequential()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:109
2-1630
336 eof = true;
executed (the execution status of this line is deduced): eof = true;
-
337 len = -1;
executed (the execution status of this line is deduced): len = -1;
-
338 // size was unknown before, emit a readProgress with the final size -
339 if (size() == -1)
evaluated: size() == -1
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:8
8-28
340 emit readProgress(totalAdvancements, totalAdvancements);
executed: readProgress(totalAdvancements, totalAdvancements);
Execution Count:28
28
341 return 0;
executed: return 0;
Execution Count:36
36
342 } -
343 -
344 currentReadBufferAmount = haveRead;
executed (the execution status of this line is deduced): currentReadBufferAmount = haveRead;
-
345 currentReadBufferPosition = 0;
executed (the execution status of this line is deduced): currentReadBufferPosition = 0;
-
346 -
347 len = haveRead;
executed (the execution status of this line is deduced): len = haveRead;
-
348 return currentReadBuffer->data();
executed: return currentReadBuffer->data();
Execution Count:1622
1622
349} -
350 -
351bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount) -
352{ -
353 totalAdvancements += amount;
executed (the execution status of this line is deduced): totalAdvancements += amount;
-
354 -
355 // normal advancement -
356 currentReadBufferPosition += amount;
executed (the execution status of this line is deduced): currentReadBufferPosition += amount;
-
357 -
358 if (size() == -1)
evaluated: size() == -1
TRUEFALSE
yes
Evaluation Count:573
yes
Evaluation Count:940
573-940
359 emit readProgress(totalAdvancements, totalAdvancements);
executed: readProgress(totalAdvancements, totalAdvancements);
Execution Count:573
573
360 else -
361 emit readProgress(totalAdvancements, size());
executed: readProgress(totalAdvancements, size());
Execution Count:940
940
362 -
363 // advancing over that what has actually been read before -
364 if (currentReadBufferPosition > currentReadBufferAmount) {
partially evaluated: currentReadBufferPosition > currentReadBufferAmount
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1513
0-1513
365 qint64 i = currentReadBufferPosition - currentReadBufferAmount;
never executed (the execution status of this line is deduced): qint64 i = currentReadBufferPosition - currentReadBufferAmount;
-
366 while (i > 0) {
never evaluated: i > 0
0
367 if (device->getChar(0) == false) {
never evaluated: device->getChar(0) == false
0
368 emit readProgress(totalAdvancements - i, size());
never executed (the execution status of this line is deduced): readProgress(totalAdvancements - i, size());
-
369 return false; // ### FIXME handle eof
never executed: return false;
0
370 } -
371 i--;
never executed (the execution status of this line is deduced): i--;
-
372 }
never executed: }
0
373 -
374 currentReadBufferPosition = 0;
never executed (the execution status of this line is deduced): currentReadBufferPosition = 0;
-
375 currentReadBufferAmount = 0;
never executed (the execution status of this line is deduced): currentReadBufferAmount = 0;
-
376 }
never executed: }
0
377 -
378 -
379 return true;
executed: return true;
Execution Count:1513
1513
380} -
381 -
382bool QNonContiguousByteDeviceIoDeviceImpl::atEnd() -
383{ -
384 return eof == true;
executed: return eof == true;
Execution Count:963
963
385} -
386 -
387bool QNonContiguousByteDeviceIoDeviceImpl::reset() -
388{ -
389 if (resetDisabled)
evaluated: resetDisabled
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
390 return false;
executed: return false;
Execution Count:1
1
391 -
392 if (device->seek(initialPosition)) {
partially evaluated: device->seek(initialPosition)
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
393 eof = false; // assume eof is false, it will be true after a read has been attempted
executed (the execution status of this line is deduced): eof = false;
-
394 return true;
executed: return true;
Execution Count:6
6
395 } -
396 -
397 return false;
never executed: return false;
0
398} -
399 -
400qint64 QNonContiguousByteDeviceIoDeviceImpl::size() -
401{ -
402 // note that this is different from the size() implementation of QIODevice! -
403 -
404 if (device->isSequential())
evaluated: device->isSequential()
TRUEFALSE
yes
Evaluation Count:603
yes
Evaluation Count:2877
603-2877
405 return -1;
executed: return -1;
Execution Count:603
603
406 -
407 return device->size() - initialPosition;
executed: return device->size() - initialPosition;
Execution Count:2877
2877
408} -
409 -
410QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd) : QIODevice((QObject*)0) -
411{ -
412 byteDevice = bd;
executed (the execution status of this line is deduced): byteDevice = bd;
-
413 connect(bd, SIGNAL(readyRead()), SIGNAL(readyRead()));
executed (the execution status of this line is deduced): connect(bd, "2""readyRead()", "2""readyRead()");
-
414 -
415 open(ReadOnly);
executed (the execution status of this line is deduced): open(ReadOnly);
-
416}
executed: }
Execution Count:11
11
417 -
418QByteDeviceWrappingIoDevice::~QByteDeviceWrappingIoDevice() -
419{ -
420 -
421} -
422 -
423bool QByteDeviceWrappingIoDevice::isSequential() const -
424{ -
425 return (byteDevice->size() == -1);
executed: return (byteDevice->size() == -1);
Execution Count:55
55
426} -
427 -
428bool QByteDeviceWrappingIoDevice::atEnd() const -
429{ -
430 return byteDevice->atEnd();
never executed: return byteDevice->atEnd();
0
431} -
432 -
433bool QByteDeviceWrappingIoDevice::reset() -
434{ -
435 return byteDevice->reset();
never executed: return byteDevice->reset();
0
436} -
437 -
438qint64 QByteDeviceWrappingIoDevice::size() const -
439{ -
440 if (isSequential())
partially evaluated: isSequential()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:22
0-22
441 return 0;
never executed: return 0;
0
442 -
443 return byteDevice->size();
executed: return byteDevice->size();
Execution Count:22
22
444} -
445 -
446 -
447qint64 QByteDeviceWrappingIoDevice::readData( char * data, qint64 maxSize) -
448{ -
449 qint64 len;
executed (the execution status of this line is deduced): qint64 len;
-
450 const char *readPointer = byteDevice->readPointer(maxSize, len);
executed (the execution status of this line is deduced): const char *readPointer = byteDevice->readPointer(maxSize, len);
-
451 if (len == -1)
evaluated: len == -1
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:285
20-285
452 return -1;
executed: return -1;
Execution Count:20
20
453 -
454 memcpy(data, readPointer, len);
executed (the execution status of this line is deduced): memcpy(data, readPointer, len);
-
455 byteDevice->advanceReadPointer(len);
executed (the execution status of this line is deduced): byteDevice->advanceReadPointer(len);
-
456 return len;
executed: return len;
Execution Count:285
285
457} -
458 -
459qint64 QByteDeviceWrappingIoDevice::writeData( const char* data, qint64 maxSize) -
460{ -
461 Q_UNUSED(data);
never executed (the execution status of this line is deduced): (void)data;;
-
462 Q_UNUSED(maxSize);
never executed (the execution status of this line is deduced): (void)maxSize;;
-
463 return -1;
never executed: return -1;
0
464} -
465 -
466/*! -
467 \class QNonContiguousByteDeviceFactory -
468 \inmodule QtCore -
469 \since 4.6 -
470 -
471 Creates a QNonContiguousByteDevice out of a QIODevice, -
472 QByteArray etc. -
473 -
474 \sa QNonContiguousByteDevice -
475 -
476 \internal -
477*/ -
478 -
479/*! -
480 \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *device) -
481 -
482 Create a QNonContiguousByteDevice out of a QIODevice. -
483 For QFile, QBuffer and all other QIoDevice, sequential or not. -
484 -
485 \internal -
486*/ -
487QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *device) -
488{ -
489 // shortcut if it is a QBuffer -
490 if (QBuffer* buffer = qobject_cast<QBuffer*>(device)) {
evaluated: QBuffer* buffer = qobject_cast<QBuffer*>(device)
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:70
58-70
491 return new QNonContiguousByteDeviceBufferImpl(buffer);
executed: return new QNonContiguousByteDeviceBufferImpl(buffer);
Execution Count:58
58
492 } -
493 -
494 // ### FIXME special case if device is a QFile that supports map() -
495 // then we can actually deal with the file without using read/peek -
496 -
497 // generic QIODevice -
498 return new QNonContiguousByteDeviceIoDeviceImpl(device); // FIXME
executed: return new QNonContiguousByteDeviceIoDeviceImpl(device);
Execution Count:70
70
499} -
500 -
501/*! -
502 \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer<QRingBuffer> ringBuffer) -
503 -
504 Create a QNonContiguousByteDevice out of a QRingBuffer. -
505 -
506 \internal -
507*/ -
508QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer<QRingBuffer> ringBuffer) -
509{ -
510 return new QNonContiguousByteDeviceRingBufferImpl(ringBuffer);
executed: return new QNonContiguousByteDeviceRingBufferImpl(ringBuffer);
Execution Count:101
101
511} -
512 -
513/*! -
514 \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray) -
515 -
516 Create a QNonContiguousByteDevice out of a QByteArray. -
517 -
518 \internal -
519*/ -
520QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray) -
521{ -
522 return new QNonContiguousByteDeviceByteArrayImpl(byteArray);
never executed: return new QNonContiguousByteDeviceByteArrayImpl(byteArray);
0
523} -
524 -
525/*! -
526 \fn static QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice) -
527 -
528 Wrap the \a byteDevice (possibly again) into a QIODevice. -
529 -
530 \internal -
531*/ -
532QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice) -
533{ -
534 // ### FIXME if it already has been based on QIoDevice, we could that one out again -
535 // and save some calling -
536 -
537 // needed for FTP backend -
538 -
539 return new QByteDeviceWrappingIoDevice(byteDevice);
executed: return new QByteDeviceWrappingIoDevice(byteDevice);
Execution Count:11
11
540} -
541 -
542QT_END_NAMESPACE -
543 -
544 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial