From 35b5100302c9ff28a7ae286c6bca8de37683f270 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 6 Nov 2019 10:30:32 +0100 Subject: Remove redundant overloads in QByteArray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All of these were marked to be removed in Qt 6. Change-Id: Ifa7aa14abebafdfeda024dcbfa5ae1f7874f387f Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Timur Pocheptsov --- .../snippets/code/src_corelib_tools_qbytearray.cpp | 10 +-- src/corelib/text/qbytearray.cpp | 72 ++-------------------- src/corelib/text/qbytearray.h | 14 ++--- 3 files changed, 13 insertions(+), 83 deletions(-) diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp index 11ab50687d..b1dc392140 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qbytearray.cpp @@ -372,16 +372,13 @@ a = str.toFloat(&ok); // a == 0, ok == false //! [39] QByteArray text("Qt is great!"); text.toBase64(); // returns "UXQgaXMgZ3JlYXQh" -//! [39] -//! [39bis] QByteArray text("

Hello?

"); text.toBase64(QByteArray::Base64Encoding | QByteArray::OmitTrailingEquals); // returns "PHA+SGVsbG8/PC9wPg" text.toBase64(QByteArray::Base64Encoding); // returns "PHA+SGVsbG8/PC9wPg==" text.toBase64(QByteArray::Base64UrlEncoding); // returns "PHA-SGVsbG8_PC9wPg==" text.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); // returns "PHA-SGVsbG8_PC9wPg" -//! [39bis] - +//! [39] //! [40] QByteArray ba; @@ -422,13 +419,10 @@ QDataStream in(&data, QIODevice::ReadOnly); //! [44] QByteArray text = QByteArray::fromBase64("UXQgaXMgZ3JlYXQh"); text.data(); // returns "Qt is great!" -//! [44] -//! [44bis] QByteArray::fromBase64("PHA+SGVsbG8/PC9wPg==", QByteArray::Base64Encoding); // returns "

Hello?

" QByteArray::fromBase64("PHA-SGVsbG8_PC9wPg==", QByteArray::Base64UrlEncoding); // returns "

Hello?

" -//! [44bis] - +//! [44] //! [45] QByteArray text = QByteArray::fromHex("517420697320677265617421"); diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 444980e9c0..4a00c664c0 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -554,22 +554,6 @@ static const quint16 crc_tbl[16] = { 0xc60c, 0xd68d, 0xe70e, 0xf78f }; -/*! - \relates QByteArray - - Returns the CRC-16 checksum of the first \a len bytes of \a data. - - The checksum is independent of the byte order (endianness) and will be - calculated accorded to the algorithm published in ISO 3309 (Qt::ChecksumIso3309). - - \note This function is a 16-bit cache conserving (16 entry table) - implementation of the CRC-16-CCITT algorithm. -*/ -quint16 qChecksum(const char *data, uint len) -{ - return qChecksum(data, len, Qt::ChecksumIso3309); -} - /*! \relates QByteArray \since 5.9 @@ -578,6 +562,7 @@ quint16 qChecksum(const char *data, uint len) The checksum is independent of the byte order (endianness) and will be calculated accorded to the algorithm published in \a standard. + By default the algorithm published in ISO 3309 (Qt::ChecksumIso3309) is used. \note This function is a 16-bit cache conserving (16 entry table) implementation of the CRC-16-CCITT algorithm. @@ -4092,27 +4077,12 @@ float QByteArray::toFloat(bool *ok) const return QLocaleData::convertDoubleToFloat(toDouble(ok), ok); } -/*! - Returns a copy of the byte array, encoded as Base64. - - \snippet code/src_corelib_tools_qbytearray.cpp 39 - - The algorithm used to encode Base64-encoded data is defined in \l{RFC 4648}. - - \sa fromBase64() -*/ -QByteArray QByteArray::toBase64() const -{ - return toBase64(Base64Encoding); -} - /*! \since 5.2 - \overload Returns a copy of the byte array, encoded using the options \a options. - \snippet code/src_corelib_tools_qbytearray.cpp 39bis + \snippet code/src_corelib_tools_qbytearray.cpp 39 The algorithm used to encode Base64-encoded data is defined in \l{RFC 4648}. @@ -4513,27 +4483,8 @@ QByteArray &QByteArray::setRawData(const char *data, uint size) return *this; } -/*! - Returns a decoded copy of the Base64 array \a base64. Input is not checked - for validity; invalid characters in the input are skipped, enabling the - decoding process to continue with subsequent characters. - - For example: - - \snippet code/src_corelib_tools_qbytearray.cpp 44 - - The algorithm used to decode Base64-encoded data is defined in \l{RFC 4648}. - - \sa toBase64() -*/ -QByteArray QByteArray::fromBase64(const QByteArray &base64) -{ - return fromBase64(base64, Base64Encoding); -} - /*! \since 5.2 - \overload Returns a decoded copy of the Base64 array \a base64, using the alphabet defined by \a options. Input is not checked for validity; invalid @@ -4542,7 +4493,7 @@ QByteArray QByteArray::fromBase64(const QByteArray &base64) For example: - \snippet code/src_corelib_tools_qbytearray.cpp 44bis + \snippet code/src_corelib_tools_qbytearray.cpp 44 The algorithm used to decode Base64-encoded data is defined in \l{RFC 4648}. @@ -4627,21 +4578,7 @@ QByteArray QByteArray::fromHex(const QByteArray &hexEncoded) return res; } -/*! - Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and - the letters a-f. - - \sa fromHex() -*/ -QByteArray QByteArray::toHex() const -{ - return toHex('\0'); -} - -/*! \overload - \since 5.9 - - Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and +/*! Returns a hex encoded copy of the byte array. The hex encoding uses the numbers 0-9 and the letters a-f. If \a separator is not '\0', the separator character is inserted between the hex bytes. @@ -4649,6 +4586,7 @@ QByteArray QByteArray::toHex() const Example: \snippet code/src_corelib_tools_qbytearray.cpp 50 + \since 5.9 \sa fromHex() */ QByteArray QByteArray::toHex(char separator) const diff --git a/src/corelib/text/qbytearray.h b/src/corelib/text/qbytearray.h index 03d842e9bc..1376e26260 100644 --- a/src/corelib/text/qbytearray.h +++ b/src/corelib/text/qbytearray.h @@ -107,8 +107,8 @@ Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap); Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...); // qChecksum: Internet checksum -Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len); // ### Qt 6: Remove -Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len, Qt::ChecksumType standard); // ### Qt 6: Use Qt::ChecksumType standard = Qt::ChecksumIso3309 +Q_CORE_EXPORT quint16 qChecksum(const char *s, uint len, + Qt::ChecksumType standard = Qt::ChecksumIso3309); class QByteRef; class QString; @@ -355,10 +355,8 @@ public: qulonglong toULongLong(bool *ok = nullptr, int base = 10) const; float toFloat(bool *ok = nullptr) const; double toDouble(bool *ok = nullptr) const; - QByteArray toBase64(Base64Options options) const; - QByteArray toBase64() const; // ### Qt6 merge with previous - QByteArray toHex() const; - QByteArray toHex(char separator) const; // ### Qt6 merge with previous + QByteArray toBase64(Base64Options options = Base64Encoding) const; + QByteArray toHex(char separator = '\0') const; QByteArray toPercentEncoding(const QByteArray &exclude = QByteArray(), const QByteArray &include = QByteArray(), char percent = '%') const; @@ -379,8 +377,8 @@ public: Q_REQUIRED_RESULT static QByteArray number(qulonglong, int base = 10); Q_REQUIRED_RESULT static QByteArray number(double, char f = 'g', int prec = 6); Q_REQUIRED_RESULT static QByteArray fromRawData(const char *, int size); - Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64, Base64Options options); - Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64); // ### Qt6 merge with previous + Q_REQUIRED_RESULT static QByteArray fromBase64(const QByteArray &base64, + Base64Options options = Base64Encoding); Q_REQUIRED_RESULT static QByteArray fromHex(const QByteArray &hexEncoded); Q_REQUIRED_RESULT static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%'); -- cgit v1.2.3-59-g8ed1b