diff options
Diffstat (limited to 'src/corelib/io/qnoncontiguousbytedevice.cpp')
-rw-r--r-- | src/corelib/io/qnoncontiguousbytedevice.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp index b1e4dd7584..4c5fb38c67 100644 --- a/src/corelib/io/qnoncontiguousbytedevice.cpp +++ b/src/corelib/io/qnoncontiguousbytedevice.cpp @@ -506,6 +506,25 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QIODevice *dev } /*! + Create a QNonContiguousByteDevice out of a QIODevice, return it in a QSharedPointer. + For QFile, QBuffer and all other QIODevice, sequential or not. + + \internal +*/ +QSharedPointer<QNonContiguousByteDevice> QNonContiguousByteDeviceFactory::createShared(QIODevice *device) +{ + // shortcut if it is a QBuffer + if (QBuffer *buffer = qobject_cast<QBuffer*>(device)) + return QSharedPointer<QNonContiguousByteDeviceBufferImpl>::create(buffer); + + // ### FIXME special case if device is a QFile that supports map() + // then we can actually deal with the file without using read/peek + + // generic QIODevice + return QSharedPointer<QNonContiguousByteDeviceIoDeviceImpl>::create(device); // FIXME +} + +/*! \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer<QRingBuffer> ringBuffer) Create a QNonContiguousByteDevice out of a QRingBuffer. @@ -518,6 +537,16 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QSharedPointer } /*! + Create a QNonContiguousByteDevice out of a QRingBuffer, return it in a QSharedPointer. + + \internal +*/ +QSharedPointer<QNonContiguousByteDevice> QNonContiguousByteDeviceFactory::createShared(QSharedPointer<QRingBuffer> ringBuffer) +{ + return QSharedPointer<QNonContiguousByteDeviceRingBufferImpl>::create(qMove(ringBuffer)); +} + +/*! \fn static QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *byteArray) Create a QNonContiguousByteDevice out of a QByteArray. @@ -530,6 +559,16 @@ QNonContiguousByteDevice* QNonContiguousByteDeviceFactory::create(QByteArray *by } /*! + Create a QNonContiguousByteDevice out of a QByteArray. + + \internal +*/ +QSharedPointer<QNonContiguousByteDevice> QNonContiguousByteDeviceFactory::createShared(QByteArray *byteArray) +{ + return QSharedPointer<QNonContiguousByteDeviceByteArrayImpl>::create(byteArray); +} + +/*! \fn static QIODevice* QNonContiguousByteDeviceFactory::wrap(QNonContiguousByteDevice* byteDevice) Wrap the \a byteDevice (possibly again) into a QIODevice. |