diff options
| author | Tatiana Borisova <tatiana.borisova@qt.io> | 2025-06-13 17:05:37 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2025-06-17 08:03:56 +0000 |
| commit | 8fcc4596efc55c498be75ca9067f825e733624df (patch) | |
| tree | 14df8cc80092f8498e5d6813484337a11b6b2e0b /src/corelib/serialization/qdatastream.cpp | |
| parent | e3ffd53adc7a109f774529a4d7218b377f80b9b8 (diff) | |
QDataStream: add operator bool()
- Add operator bool() that checks whether the associated stream has
no error status. This operator makes it possible to use streams
and functions that return references to streams as loop conditions:
`while (stream >> data)`.
- Update existing testcases that use or can use the status of stream
operations.
[ChangeLog][QtCore][QDataStream] Added implicit conversion to bool,
returning `status() == Ok`.
Found in API-review (added for symmetry with QTextStream).
Pick-to: 6.10
Change-Id: I3eb8251f40eba1a8164e088fa10de670564f428e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/serialization/qdatastream.cpp')
| -rw-r--r-- | src/corelib/serialization/qdatastream.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/serialization/qdatastream.cpp b/src/corelib/serialization/qdatastream.cpp index 8377cba4ec8..1a1f66a372f 100644 --- a/src/corelib/serialization/qdatastream.cpp +++ b/src/corelib/serialization/qdatastream.cpp @@ -1412,6 +1412,13 @@ QDataStream &operator<<(QDataStream &out, QChar chr) } /*! + \fn QDataStream::operator bool() const + \since 6.10 + + Returns whether this stream has no errors (status() == \l{OK}). +*/ + +/*! Writes the length specifier \a len and the buffer \a s to the stream and returns a reference to the stream. |
