summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qiodevice.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2020-08-06 18:57:43 +0300
committerAlex Trotsenko <alex1973tr@gmail.com>2020-08-11 17:21:45 +0300
commit8f53d66e3e412911f4648e88e3e753043fcbfad8 (patch)
treea14e015a4517f0d99a137cbf3e1ad0106ce665ed /src/corelib/io/qiodevice.cpp
parenta99cee1c7b095a552c04c2aa832574a6f0f44720 (diff)
Introduce QIODevice::skipData()
QIODevice::skip() called a virtual QIODevicePrivate::skip() to implement an efficient skipping on I/O devices for the internal subclasses. The user subclasses cannot inherit QIODevicePrivate, so this functionality was not externally accessible. This patch replaces QIODevicePrivate::skip() with a virtual protected QIODevice::skipData(). While the basic implementation simply discards the data by reading into a dummy buffer, users can reimplement this function to improve the performance in their subclasses. [ChangeLog][QtCore][QIODevice] Added virtual protected skipData(). Now, subclasses can implement device-specific skipping of data. Change-Id: I9522f7f7ab9d03ac06e972a525f8ec2fa909a617 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/io/qiodevice.cpp')
-rw-r--r--src/corelib/io/qiodevice.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 9def33ad9f..21718fede2 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1915,7 +1915,7 @@ QByteArray QIODevice::peek(qint64 maxSize)
For random-access devices, skip() can be used to seek forward from the
current position. Negative \a maxSize values are not allowed.
- \sa peek(), seek(), read()
+ \sa skipData(), peek(), seek(), read()
*/
qint64 QIODevice::skip(qint64 maxSize)
{
@@ -1968,7 +1968,7 @@ qint64 QIODevice::skip(qint64 maxSize)
}
}
- const qint64 skipResult = d->skip(maxSize);
+ const qint64 skipResult = skipData(maxSize);
if (skippedSoFar == 0)
return skipResult;
@@ -2008,14 +2008,23 @@ qint64 QIODevicePrivate::skipByReading(qint64 maxSize)
}
/*!
- \internal
+ \since 6.0
+
+ Skips up to \a maxSize bytes from the device. Returns the number of bytes
+ actually skipped, or -1 on error.
+
+ This function is called by QIODevice. Consider reimplementing it
+ when creating a subclass of QIODevice.
+
+ The base implementation discards the data by reading into a dummy buffer.
+ This is slow, but works for all types of devices. Subclasses can
+ reimplement this function to improve on that.
+
+ \sa skip(), peek(), seek(), read()
*/
-qint64 QIODevicePrivate::skip(qint64 maxSize)
+qint64 QIODevice::skipData(qint64 maxSize)
{
- // Base implementation discards the data by reading into the dummy buffer.
- // It's slow, but this works for all types of devices. Subclasses can
- // reimplement this function to improve on that.
- return skipByReading(maxSize);
+ return d_func()->skipByReading(maxSize);
}
/*!