diff options
Diffstat (limited to 'src/corelib/serialization/qdatastream.cpp')
-rw-r--r-- | src/corelib/serialization/qdatastream.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index 02c1d1c573..b3330d6cea 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -98,6 +98,10 @@ QT_BEGIN_NAMESPACE ensures that you get integers of the size you want and insulates you from compiler and platform differences. + Enumerations can be serialized through QDataStream without the + need of manually defining streaming operators. Enum classes are + serialized using the declared size. + To take one example, a \c{char *} string is written as a 32-bit integer equal to the length of the string including the '\\0' byte, followed by all the characters of the string including the @@ -273,7 +277,7 @@ QT_BEGIN_NAMESPACE QDataStream::QDataStream() { - dev = 0; + dev = nullptr; owndev = false; byteorder = BigEndian; ver = Qt_DefaultCompiledVersion; @@ -429,7 +433,7 @@ bool QDataStream::atEnd() const */ QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const { - return d == 0 ? QDataStream::DoublePrecision : d->floatingPointPrecision; + return d ? d->floatingPointPrecision : QDataStream::DoublePrecision; } /*! @@ -454,7 +458,7 @@ QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const */ void QDataStream::setFloatingPointPrecision(QDataStream::FloatingPointPrecision precision) { - if (d == 0) + if (!d) d.reset(new QDataStreamPrivate()); d->floatingPointPrecision = precision; } @@ -561,6 +565,7 @@ void QDataStream::setByteOrder(ByteOrder bo) \value Qt_5_11 Same as Qt_5_6 \value Qt_5_12 Version 18 (Qt 5.12) \value Qt_5_13 Version 19 (Qt 5.13) + \value Qt_5_14 Same as Qt_5_13 \omitvalue Qt_DefaultCompiledVersion \sa setVersion(), version() @@ -634,7 +639,7 @@ void QDataStream::startTransaction() { CHECK_STREAM_PRECOND(Q_VOID) - if (d == 0) + if (!d) d.reset(new QDataStreamPrivate()); if (++d->transactionDepth == 1) { @@ -1038,7 +1043,7 @@ QDataStream &QDataStream::operator>>(char *&s) QDataStream &QDataStream::readBytes(char *&s, uint &l) { - s = 0; + s = nullptr; l = 0; CHECK_STREAM_PRECOND(*this) @@ -1049,8 +1054,8 @@ QDataStream &QDataStream::readBytes(char *&s, uint &l) const quint32 Step = 1024 * 1024; quint32 allocated = 0; - char *prevBuf = 0; - char *curBuf = 0; + char *prevBuf = nullptr; + char *curBuf = nullptr; do { int blockSize = qMin(Step, len - allocated); |