QMessageAuthenticationCode: port to QByteArrayView [2/3]: addData()

The class is not used frequently enough to warrant the overhead of a
Q_WEAK_ QByteArray overload to fix the SiC Type A for users that pass
objects that implicitly convert to QByteArray. QCryptographicHash also
doesn't have it.

Also mark addData() noexcept. Now that it takes a view instead of
an owning container, it only calls other noexcept functions.

Make the new overload carry actual documentation instead of just
\overload.

ChangeLog will be on patch [3/3].

Task-number: QTBUG-111676
Task-number: QTBUG-111688
Change-Id: Ie6447bf54d7d442b1a76761bc0f28f868c08ef09
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2023-03-02 19:05:16 +01:00
parent 93cb61e305
commit 6a6e9337c7
3 changed files with 15 additions and 2 deletions

View File

@ -497,6 +497,11 @@ void QMessageAuthenticationCode::setKey(const QByteArray &key)
setKey(qToByteArrayViewIgnoringNull(key)); setKey(qToByteArrayViewIgnoringNull(key));
} }
void QMessageAuthenticationCode::addData(const QByteArray &data)
{
addData(qToByteArrayViewIgnoringNull(data));
}
#include "qstring.h" #include "qstring.h"
qsizetype QString::toUcs4_helper(const ushort *uc, qsizetype length, uint *out) qsizetype QString::toUcs4_helper(const ushort *uc, qsizetype length, uint *out)

View File

@ -1355,6 +1355,7 @@ void QMessageAuthenticationCode::setKey(QByteArrayView key) noexcept
} }
/*! /*!
\overload
Adds the first \a length chars of \a data to the message. Adds the first \a length chars of \a data to the message.
*/ */
void QMessageAuthenticationCode::addData(const char *data, qsizetype length) void QMessageAuthenticationCode::addData(const char *data, qsizetype length)
@ -1363,9 +1364,13 @@ void QMessageAuthenticationCode::addData(const char *data, qsizetype length)
} }
/*! /*!
\overload addData() Adds \a data to the message.
\include qcryptographichash.cpp {qba-to-qbav-6.6}
\sa resultView(), result()
*/ */
void QMessageAuthenticationCode::addData(const QByteArray &data) void QMessageAuthenticationCode::addData(QByteArrayView data) noexcept
{ {
d->messageHash.addData(data); d->messageHash.addData(data);
} }

View File

@ -39,7 +39,10 @@ public:
void setKey(QByteArrayView key) noexcept; void setKey(QByteArrayView key) noexcept;
void addData(const char *data, qsizetype length); void addData(const char *data, qsizetype length);
#if QT_CORE_REMOVED_SINCE(6, 6)
void addData(const QByteArray &data); void addData(const QByteArray &data);
#endif
void addData(QByteArrayView data) noexcept;
bool addData(QIODevice *device); bool addData(QIODevice *device);
QByteArrayView resultView() const noexcept; QByteArrayView resultView() const noexcept;