| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | QNonContiguousByteDevice::QNonContiguousByteDevice() : QObject((QObject*)0), resetDisabled(false) | - |
| 4 | { | - |
| 5 | } executed: }Execution Count:425 | 425 |
| 6 | | - |
| 7 | QNonContiguousByteDevice::~QNonContiguousByteDevice() | - |
| 8 | { | - |
| 9 | } | - |
| 10 | | - |
| 11 | void QNonContiguousByteDevice::disableReset() | - |
| 12 | { | - |
| 13 | resetDisabled = true; | - |
| 14 | } executed: }Execution Count:2 | 2 |
| 15 | | - |
| 16 | | - |
| 17 | QNonContiguousByteDeviceBufferImpl::QNonContiguousByteDeviceBufferImpl(QBuffer *b) : QNonContiguousByteDevice() | - |
| 18 | { | - |
| 19 | buffer = b; | - |
| 20 | byteArray = QByteArray::fromRawData(buffer->buffer().constData() + buffer->pos(), buffer->size() - buffer->pos()); | - |
| 21 | arrayImpl = new QNonContiguousByteDeviceByteArrayImpl(&byteArray); | - |
| 22 | arrayImpl->setParent(this); | - |
| 23 | connect(arrayImpl, "2""readyRead()", "2""readyRead()"); | - |
| 24 | connect(arrayImpl, "2""readProgress(qint64,qint64)", "2""readProgress(qint64,qint64)"); | - |
| 25 | } executed: }Execution Count:58 | 58 |
| 26 | | - |
| 27 | QNonContiguousByteDeviceBufferImpl::~QNonContiguousByteDeviceBufferImpl() | - |
| 28 | { | - |
| 29 | } | - |
| 30 | | - |
| 31 | const char* QNonContiguousByteDeviceBufferImpl::readPointer(qint64 maximumLength, qint64 &len) | - |
| 32 | { | - |
| 33 | return arrayImpl->readPointer(maximumLength, len); executed: return arrayImpl->readPointer(maximumLength, len);Execution Count:1013 | 1013 |
| 34 | } | - |
| 35 | | - |
| 36 | bool QNonContiguousByteDeviceBufferImpl::advanceReadPointer(qint64 amount) | - |
| 37 | { | - |
| 38 | return arrayImpl->advanceReadPointer(amount); executed: return arrayImpl->advanceReadPointer(amount);Execution Count:992 | 992 |
| 39 | } | - |
| 40 | | - |
| 41 | bool QNonContiguousByteDeviceBufferImpl::atEnd() | - |
| 42 | { | - |
| 43 | return arrayImpl->atEnd(); executed: return arrayImpl->atEnd();Execution Count:753 | 753 |
| 44 | } | - |
| 45 | | - |
| 46 | bool QNonContiguousByteDeviceBufferImpl::reset() | - |
| 47 | { | - |
| 48 | if (resetDisabled) partially evaluated: resetDisabled| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 49 | return false; never executed: return false; | 0 |
| 50 | return arrayImpl->reset(); executed: return arrayImpl->reset();Execution Count:4 | 4 |
| 51 | } | - |
| 52 | | - |
| 53 | qint64 QNonContiguousByteDeviceBufferImpl::size() | - |
| 54 | { | - |
| 55 | return arrayImpl->size(); executed: return arrayImpl->size();Execution Count:802 | 802 |
| 56 | } | - |
| 57 | | - |
| 58 | QNonContiguousByteDeviceByteArrayImpl::QNonContiguousByteDeviceByteArrayImpl(QByteArray *ba) : QNonContiguousByteDevice(), currentPosition(0) | - |
| 59 | { | - |
| 60 | byteArray = ba; | - |
| 61 | } executed: }Execution Count:58 | 58 |
| 62 | | - |
| 63 | QNonContiguousByteDeviceByteArrayImpl::~QNonContiguousByteDeviceByteArrayImpl() | - |
| 64 | { | - |
| 65 | } | - |
| 66 | | - |
| 67 | const char* QNonContiguousByteDeviceByteArrayImpl::readPointer(qint64 maximumLength, qint64 &len) | - |
| 68 | { | - |
| 69 | if (atEnd()) { evaluated: atEnd()| yes Evaluation Count:20 | yes Evaluation Count:993 |
| 20-993 |
| 70 | len = -1; | - |
| 71 | return 0; executed: return 0;Execution Count:20 | 20 |
| 72 | } | - |
| 73 | | - |
| 74 | if (maximumLength != -1) evaluated: maximumLength != -1| yes Evaluation Count:987 | yes Evaluation Count:6 |
| 6-987 |
| 75 | len = qMin(maximumLength, size() - currentPosition); executed: len = qMin(maximumLength, size() - currentPosition);Execution Count:987 | 987 |
| 76 | else | - |
| 77 | len = size() - currentPosition; executed: len = size() - currentPosition;Execution Count:6 | 6 |
| 78 | | - |
| 79 | return byteArray->constData() + currentPosition; executed: return byteArray->constData() + currentPosition;Execution Count:993 | 993 |
| 80 | } | - |
| 81 | | - |
| 82 | bool QNonContiguousByteDeviceByteArrayImpl::advanceReadPointer(qint64 amount) | - |
| 83 | { | - |
| 84 | currentPosition += amount; | - |
| 85 | readProgress(currentPosition, size()); | - |
| 86 | return true; executed: return true;Execution Count:992 | 992 |
| 87 | } | - |
| 88 | | - |
| 89 | bool QNonContiguousByteDeviceByteArrayImpl::atEnd() | - |
| 90 | { | - |
| 91 | return currentPosition >= size(); executed: return currentPosition >= size();Execution Count:1766 | 1766 |
| 92 | } | - |
| 93 | | - |
| 94 | bool QNonContiguousByteDeviceByteArrayImpl::reset() | - |
| 95 | { | - |
| 96 | if (resetDisabled) partially evaluated: resetDisabled| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 97 | return false; never executed: return false; | 0 |
| 98 | | - |
| 99 | currentPosition = 0; | - |
| 100 | return true; executed: return true;Execution Count:4 | 4 |
| 101 | } | - |
| 102 | | - |
| 103 | qint64 QNonContiguousByteDeviceByteArrayImpl::size() | - |
| 104 | { | - |
| 105 | return byteArray->size(); executed: return byteArray->size();Execution Count:4553 | 4553 |
| 106 | } | - |
| 107 | | - |
| 108 | QNonContiguousByteDeviceRingBufferImpl::QNonContiguousByteDeviceRingBufferImpl(QSharedPointer<QRingBuffer> rb) | - |
| 109 | : QNonContiguousByteDevice(), currentPosition(0) | - |
| 110 | { | - |
| 111 | ringBuffer = rb; | - |
| 112 | } executed: }Execution Count:101 | 101 |
| 113 | | - |
| 114 | QNonContiguousByteDeviceRingBufferImpl::~QNonContiguousByteDeviceRingBufferImpl() | - |
| 115 | { | - |
| 116 | } | - |
| 117 | | - |
| 118 | const char* QNonContiguousByteDeviceRingBufferImpl::readPointer(qint64 maximumLength, qint64 &len) | - |
| 119 | { | - |
| 120 | if (atEnd()) { partially evaluated: atEnd()| no Evaluation Count:0 | yes Evaluation Count:954 |
| 0-954 |
| 121 | len = -1; | - |
| 122 | return 0; never executed: return 0; | 0 |
| 123 | } | - |
| 124 | | - |
| 125 | const char *returnValue = ringBuffer->readPointerAtPosition(currentPosition, len); | - |
| 126 | | - |
| 127 | if (maximumLength != -1) partially evaluated: maximumLength != -1| yes Evaluation Count:954 | no Evaluation Count:0 |
| 0-954 |
| 128 | len = qMin(len, maximumLength); executed: len = qMin(len, maximumLength);Execution Count:954 | 954 |
| 129 | | - |
| 130 | return returnValue; executed: return returnValue;Execution Count:954 | 954 |
| 131 | } | - |
| 132 | | - |
| 133 | bool QNonContiguousByteDeviceRingBufferImpl::advanceReadPointer(qint64 amount) | - |
| 134 | { | - |
| 135 | currentPosition += amount; | - |
| 136 | readProgress(currentPosition, size()); | - |
| 137 | return true; executed: return true;Execution Count:954 | 954 |
| 138 | } | - |
| 139 | | - |
| 140 | bool QNonContiguousByteDeviceRingBufferImpl::atEnd() | - |
| 141 | { | - |
| 142 | return currentPosition >= size(); executed: return currentPosition >= size();Execution Count:1252 | 1252 |
| 143 | } | - |
| 144 | | - |
| 145 | bool QNonContiguousByteDeviceRingBufferImpl::reset() | - |
| 146 | { | - |
| 147 | if (resetDisabled) partially evaluated: resetDisabled| no Evaluation Count:0 | yes Evaluation Count:126 |
| 0-126 |
| 148 | return false; never executed: return false; | 0 |
| 149 | | - |
| 150 | currentPosition = 0; | - |
| 151 | return true; executed: return true;Execution Count:126 | 126 |
| 152 | } | - |
| 153 | | - |
| 154 | qint64 QNonContiguousByteDeviceRingBufferImpl::size() | - |
| 155 | { | - |
| 156 | return ringBuffer->size(); executed: return ringBuffer->size();Execution Count:2586 | 2586 |
| 157 | } | - |
| 158 | | - |
| 159 | QNonContiguousByteDeviceIoDeviceImpl::QNonContiguousByteDeviceIoDeviceImpl(QIODevice *d) | - |
| 160 | : QNonContiguousByteDevice(), | - |
| 161 | currentReadBuffer(0), currentReadBufferSize(16*1024), | - |
| 162 | currentReadBufferAmount(0), currentReadBufferPosition(0), totalAdvancements(0), | - |
| 163 | eof(false) | - |
| 164 | { | - |
| 165 | device = d; | - |
| 166 | initialPosition = d->pos(); | - |
| 167 | connect(device, "2""readyRead()", this, "2""readyRead()", Qt::QueuedConnection); | - |
| 168 | connect(device, "2""readChannelFinished()", this, "2""readyRead()", Qt::QueuedConnection); | - |
| 169 | } executed: }Execution Count:70 | 70 |
| 170 | | - |
| 171 | QNonContiguousByteDeviceIoDeviceImpl::~QNonContiguousByteDeviceIoDeviceImpl() | - |
| 172 | { | - |
| 173 | delete currentReadBuffer; | - |
| 174 | } executed: }Execution Count:70 | 70 |
| 175 | | - |
| 176 | const char* QNonContiguousByteDeviceIoDeviceImpl::readPointer(qint64 maximumLength, qint64 &len) | - |
| 177 | { | - |
| 178 | if (eof == true) { evaluated: eof == true| yes Evaluation Count:3 | yes Evaluation Count:1658 |
| 3-1658 |
| 179 | len = -1; | - |
| 180 | return 0; executed: return 0;Execution Count:3 | 3 |
| 181 | } | - |
| 182 | | - |
| 183 | if (currentReadBuffer == 0) evaluated: currentReadBuffer == 0| yes Evaluation Count:68 | yes Evaluation Count:1590 |
| 68-1590 |
| 184 | currentReadBuffer = new QByteArray(currentReadBufferSize, '\0'); executed: currentReadBuffer = new QByteArray(currentReadBufferSize, '\0');Execution Count:68 | 68 |
| 185 | | - |
| 186 | if (maximumLength == -1) evaluated: maximumLength == -1| yes Evaluation Count:718 | yes Evaluation Count:940 |
| 718-940 |
| 187 | maximumLength = currentReadBufferSize; executed: maximumLength = currentReadBufferSize;Execution Count:718 | 718 |
| 188 | | - |
| 189 | if (currentReadBufferAmount - currentReadBufferPosition > 0) { partially evaluated: currentReadBufferAmount - currentReadBufferPosition > 0| no Evaluation Count:0 | yes Evaluation Count:1658 |
| 0-1658 |
| 190 | len = currentReadBufferAmount - currentReadBufferPosition; | - |
| 191 | return currentReadBuffer->data() + currentReadBufferPosition; never executed: return currentReadBuffer->data() + currentReadBufferPosition; | 0 |
| 192 | } | - |
| 193 | | - |
| 194 | qint64 haveRead = device->read(currentReadBuffer->data(), qMin(maximumLength, currentReadBufferSize)); | - |
| 195 | | - |
| 196 | if ((haveRead == -1) || (haveRead == 0 && device->atEnd() && !device->isSequential())) { evaluated: (haveRead == -1)| yes Evaluation Count:28 | yes Evaluation Count:1630 |
evaluated: haveRead == 0| yes Evaluation Count:119 | yes Evaluation Count:1511 |
evaluated: device->atEnd()| yes Evaluation Count:117 | yes Evaluation Count:2 |
evaluated: !device->isSequential()| yes Evaluation Count:8 | yes Evaluation Count:109 |
| 2-1630 |
| 197 | eof = true; | - |
| 198 | len = -1; | - |
| 199 | | - |
| 200 | if (size() == -1) evaluated: size() == -1| yes Evaluation Count:28 | yes Evaluation Count:8 |
| 8-28 |
| 201 | readProgress(totalAdvancements, totalAdvancements); executed: readProgress(totalAdvancements, totalAdvancements);Execution Count:28 | 28 |
| 202 | return 0; executed: return 0;Execution Count:36 | 36 |
| 203 | } | - |
| 204 | | - |
| 205 | currentReadBufferAmount = haveRead; | - |
| 206 | currentReadBufferPosition = 0; | - |
| 207 | | - |
| 208 | len = haveRead; | - |
| 209 | return currentReadBuffer->data(); executed: return currentReadBuffer->data();Execution Count:1622 | 1622 |
| 210 | } | - |
| 211 | | - |
| 212 | bool QNonContiguousByteDeviceIoDeviceImpl::advanceReadPointer(qint64 amount) | - |
| 213 | { | - |
| 214 | totalAdvancements += amount; | - |
| 215 | | - |
| 216 | | - |
| 217 | currentReadBufferPosition += amount; | - |
| 218 | | - |
| 219 | if (size() == -1) evaluated: size() == -1| yes Evaluation Count:573 | yes Evaluation Count:940 |
| 573-940 |
| 220 | readProgress(totalAdvancements, totalAdvancements); executed: readProgress(totalAdvancements, totalAdvancements);Execution Count:573 | 573 |
| 221 | else | - |
| 222 | readProgress(totalAdvancements, size()); executed: readProgress(totalAdvancements, size());Execution Count:940 | 940 |
| 223 | | - |
| 224 | | - |
| 225 | if (currentReadBufferPosition > currentReadBufferAmount) { partially evaluated: currentReadBufferPosition > currentReadBufferAmount| no Evaluation Count:0 | yes Evaluation Count:1513 |
| 0-1513 |
| 226 | qint64 i = currentReadBufferPosition - currentReadBufferAmount; | - |
| 227 | while (i > 0) { | 0 |
| 228 | if (device->getChar(0) == false) { never evaluated: device->getChar(0) == false | 0 |
| 229 | readProgress(totalAdvancements - i, size()); | - |
| 230 | return false; never executed: return false; | 0 |
| 231 | } | - |
| 232 | i--; | - |
| 233 | } | 0 |
| 234 | | - |
| 235 | currentReadBufferPosition = 0; | - |
| 236 | currentReadBufferAmount = 0; | - |
| 237 | } | 0 |
| 238 | | - |
| 239 | | - |
| 240 | return true; executed: return true;Execution Count:1513 | 1513 |
| 241 | } | - |
| 242 | | - |
| 243 | bool QNonContiguousByteDeviceIoDeviceImpl::atEnd() | - |
| 244 | { | - |
| 245 | return eof == true; executed: return eof == true;Execution Count:963 | 963 |
| 246 | } | - |
| 247 | | - |
| 248 | bool QNonContiguousByteDeviceIoDeviceImpl::reset() | - |
| 249 | { | - |
| 250 | if (resetDisabled) evaluated: resetDisabled| yes Evaluation Count:1 | yes Evaluation Count:6 |
| 1-6 |
| 251 | return false; executed: return false;Execution Count:1 | 1 |
| 252 | | - |
| 253 | if (device->seek(initialPosition)) { partially evaluated: device->seek(initialPosition)| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 254 | eof = false; | - |
| 255 | return true; executed: return true;Execution Count:6 | 6 |
| 256 | } | - |
| 257 | | - |
| 258 | return false; never executed: return false; | 0 |
| 259 | } | - |
| 260 | | - |
| 261 | qint64 QNonContiguousByteDeviceIoDeviceImpl::size() | - |
| 262 | { | - |
| 263 | | - |
| 264 | | - |
| 265 | if (device->isSequential()) evaluated: device->isSequential()| yes Evaluation Count:603 | yes Evaluation Count:2877 |
| 603-2877 |
| 266 | return -1; executed: return -1;Execution Count:603 | 603 |
| 267 | | - |
| 268 | return device->size() - initialPosition; executed: return device->size() - initialPosition;Execution Count:2877 | 2877 |
| 269 | } | - |
| 270 | | - |
| 271 | QByteDeviceWrappingIoDevice::QByteDeviceWrappingIoDevice(QNonContiguousByteDevice *bd) : QIODevice((QObject*)0) | - |
| 272 | { | - |
| 273 | byteDevice = bd; | - |
| 274 | connect(bd, "2""readyRead()", "2""readyRead()"); | - |
| 275 | | - |
| 276 | open(ReadOnly); | - |
| 277 | } executed: }Execution Count:11 | 11 |
| 278 | | - |
| 279 | QByteDeviceWrappingIoDevice::~QByteDeviceWrappingIoDevice() | - |
| 280 | { | - |
| 281 | | - |
| 282 | } | - |
| 283 | | - |
| 284 | bool QByteDeviceWrappingIoDevice::isSequential() const | - |
| 285 | { | - |
| 286 | return (byteDevice->size() == -1); executed: return (byteDevice->size() == -1);Execution Count:55 | 55 |
| 287 | } | - |
| 288 | | - |
| 289 | bool QByteDeviceWrappingIoDevice::atEnd() const | - |
| 290 | { | - |
| 291 | return byteDevice->atEnd(); never executed: return byteDevice->atEnd(); | 0 |
| 292 | } | - |
| 293 | | - |
| 294 | bool QByteDeviceWrappingIoDevice::reset() | - |
| 295 | { | - |
| 296 | return byteDevice->reset(); never executed: return byteDevice->reset(); | 0 |
| 297 | } | - |
| 298 | | - |
| 299 | qint64 QByteDeviceWrappingIoDevice::size() const | - |
| 300 | { | - |
| 301 | if (isSequential()) partially evaluated: isSequential()| no Evaluation Count:0 | yes Evaluation Count:22 |
| 0-22 |
| 302 | return 0; never executed: return 0; | 0 |
| 303 | | - |
| 304 | return byteDevice->size(); executed: return byteDevice->size();Execution Count:22 | 22 |
| 305 | } | - |
| 306 | | - |
| 307 | | - |
| 308 | qint64 QByteDeviceWrappingIoDevice::readData( char * data, qint64 maxSize) | - |
| 309 | { | - |
| 310 | qint64 len; | - |
| 311 | const char *readPointer = byteDevice->readPointer(maxSize, len); | - |
| 312 | if (len == -1) evaluated: len == -1| yes Evaluation Count:20 | yes Evaluation Count:285 |
| 20-285 |
| 313 | return -1; executed: return -1;Execution Count:20 | 20 |
| 314 | | - |
| 315 | memcpy(data, readPointer, len); | - |
| 316 | byteDevice->advanceReadPointer(len); | - |
| 317 | return len; executed: return len;Execution Count:285 | 285 |
| 318 | } | - |
| 319 | | - |
| 320 | qint64 QByteDeviceWrappingIoDevice::writeData( const char* data, qint64 maxSize) | - |
| 321 | { | - |
| 322 | (void)data;; | - |
| 323 | (void)maxSize;; | - |
| 324 | return -1; never executed: return -1; | 0 |
| 325 | } | - |
| 326 | QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *device) | - |
| 327 | { | - |
| 328 | | - |
| 329 | if (QBuffer* buffer = qobject_cast<QBuffer*>(device)) { evaluated: QBuffer* buffer = qobject_cast<QBuffer*>(device)| yes Evaluation Count:58 | yes Evaluation Count:70 |
| 58-70 |
| 330 | return new QNonContiguousByteDeviceBufferImpl(buffer); executed: return new QNonContiguousByteDeviceBufferImpl(buffer);Execution Count:58 | 58 |
| 331 | } | - |
| 332 | | - |
| 333 | | - |
| 334 | | - |
| 335 | | - |
| 336 | | - |
| 337 | return new QNonContiguousByteDeviceIoDeviceImpl(device); executed: return new QNonContiguousByteDeviceIoDeviceImpl(device);Execution Count:70 | 70 |
| 338 | } | - |
| 339 | QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer<QRingBuffer> ringBuffer) | - |
| 340 | { | - |
| 341 | return new QNonContiguousByteDeviceRingBufferImpl(ringBuffer); executed: return new QNonContiguousByteDeviceRingBufferImpl(ringBuffer);Execution Count:101 | 101 |
| 342 | } | - |
| 343 | QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray) | - |
| 344 | { | - |
| 345 | return new QNonContiguousByteDeviceByteArrayImpl(byteArray); never executed: return new QNonContiguousByteDeviceByteArrayImpl(byteArray); | 0 |
| 346 | } | - |
| 347 | QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice) | - |
| 348 | { | - |
| 349 | | - |
| 350 | | - |
| 351 | | - |
| 352 | | - |
| 353 | | - |
| 354 | return new QByteDeviceWrappingIoDevice(byteDevice); executed: return new QByteDeviceWrappingIoDevice(byteDevice);Execution Count:11 | 11 |
| 355 | } | - |
| 356 | | - |
| 357 | | - |
| 358 | | - |
| | |