diff options
| author | Kai Köhne <kai.koehne@qt.io> | 2024-12-05 15:46:10 +0100 |
|---|---|---|
| committer | Kai Köhne <kai.koehne@qt.io> | 2024-12-13 09:10:14 +0000 |
| commit | 334460407b7cde1cdab5cfe5abe00175893749c3 (patch) | |
| tree | ce3a9767c971edb8d6829dce00e8a2206c188260 /src/corelib/io/qbuffer.cpp | |
| parent | f84ce2ae42bd37f710f636a7d0951a8781120a71 (diff) | |
Doc: Improve QBuffer::open description
Explain the method, instead of just linking to the base method.
Call the argument 'mode' instead of 'flags', like it is done in
the base class.
Force the mentioned QIODeviceBase flags to be links. Use fully
qualified name for the first flag mentioned, but use the short form
for the rest to improve readability.
Pick-to: 6.8 6.9
Task-number: QTBUG-131484
Change-Id: I8e9668ffc095ec261e2be54a2dcf16a32e4cb441
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qbuffer.cpp')
| -rw-r--r-- | src/corelib/io/qbuffer.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp index 4e513bc7cf7..16abac48886 100644 --- a/src/corelib/io/qbuffer.cpp +++ b/src/corelib/io/qbuffer.cpp @@ -286,27 +286,32 @@ void QBuffer::setData(const char *data, qsizetype size) } /*! - \reimp + Opens the buffer using \a mode flags, returning \c true if successful; + otherwise returns \c false. + + The flags for \a mode must include \l QIODeviceBase::ReadOnly, + \l WriteOnly, or \l ReadWrite. If not, an error is printed and + the method fails. In any other case, it succeeds. - Unlike QFile, opening a QBuffer QIODevice::WriteOnly does not truncate it. - However, pos() is set to 0. Use QIODevice::Append or QIODevice::Truncate to - change either behavior. + Unlike \l QFile::open(), opening a QBuffer with \l WriteOnly + does not truncate it. However, \l pos() is set to \c{0}. + Use \l Append or \l Truncate to change either behavior. */ -bool QBuffer::open(OpenMode flags) +bool QBuffer::open(OpenMode mode) { Q_D(QBuffer); - if ((flags & (Append | Truncate)) != 0) - flags |= WriteOnly; - if ((flags & (ReadOnly | WriteOnly)) == 0) { + if ((mode & (Append | Truncate)) != 0) + mode |= WriteOnly; + if ((mode & (ReadOnly | WriteOnly)) == 0) { qWarning("QBuffer::open: Buffer access not specified"); return false; } - if ((flags & Truncate) == Truncate) + if ((mode & Truncate) == Truncate) d->buf->resize(0); - return QIODevice::open(flags | QIODevice::Unbuffered); + return QIODevice::open(mode | QIODevice::Unbuffered); } /*! |
