QCborStreamReader: rename toType(Type&) -> appendToType(Type&)
Rename the toType() overloads taking an out-parameter to appendToType(), because that gives a better understanding of the usecase. Found in 6.7 API review Amends 8af346c1f66f813c3c8fe4d8b892ecfbe96eacfb and 1d9137e13f9eb3f183c967e9e911c5b260f93dc0. Change-Id: Ic1a462e9507123a59e6086bfb48b8b61ab79abb8 Reviewed-by: Juha Vuolle <juha.vuolle@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit ff034ebbfa7c1cc47cdcc15bc854972cd960db1a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
12bf8fd618
commit
e35f20485d
@ -1462,8 +1462,7 @@ bool QCborStreamReaderPrivate::readFullString(ReadStringChunk params)
|
||||
\sa readString(), readStringChunk(), isString(), toByteArray()
|
||||
*/
|
||||
/*!
|
||||
\fn QCborStreamReader::toString(QString &dst)
|
||||
\overload
|
||||
\fn QCborStreamReader::appendToString(QString &dst)
|
||||
\since 6.7
|
||||
|
||||
Decodes the current text string and appends to \a dst. If the string is
|
||||
@ -1476,9 +1475,9 @@ bool QCborStreamReaderPrivate::readFullString(ReadStringChunk params)
|
||||
|
||||
\include qcborstreamreader.cpp note-not-restartable
|
||||
|
||||
\sa readString(), readStringChunk(), isString(), toByteArray()
|
||||
\sa readString(), readStringChunk(), isString(), appendToByteArray()
|
||||
*/
|
||||
bool QCborStreamReader::_toString_helper(QString &dst)
|
||||
bool QCborStreamReader::_appendToString_helper(QString &dst)
|
||||
{
|
||||
bool ok = d->readFullString(&dst);
|
||||
if (ok)
|
||||
@ -1503,8 +1502,7 @@ bool QCborStreamReader::_toString_helper(QString &dst)
|
||||
\sa readString(), readStringChunk(), isString(), toByteArray()
|
||||
*/
|
||||
/*!
|
||||
\fn QCborStreamReader::toUtf8String(QByteArray &dst)
|
||||
\overload
|
||||
\fn QCborStreamReader::appendToUtf8String(QByteArray &dst)
|
||||
\since 6.7
|
||||
|
||||
Decodes the current text string and appends to \a dst. If the string is
|
||||
@ -1517,9 +1515,9 @@ bool QCborStreamReader::_toString_helper(QString &dst)
|
||||
|
||||
\include qcborstreamreader.cpp note-not-restartable
|
||||
|
||||
\sa readString(), readStringChunk(), isString(), toByteArray()
|
||||
\sa readString(), readStringChunk(), isString(), appendToByteArray()
|
||||
*/
|
||||
bool QCborStreamReader::_toUtf8String_helper(QByteArray &dst)
|
||||
bool QCborStreamReader::_appendToUtf8String_helper(QByteArray &dst)
|
||||
{
|
||||
using P = QCborStreamReaderPrivate::ReadStringChunk;
|
||||
bool ok = d->readFullString({ &dst, P::Utf8String });
|
||||
@ -1546,8 +1544,7 @@ bool QCborStreamReader::_toUtf8String_helper(QByteArray &dst)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QCborStreamReader::toByteArray(QByteArray &dst)
|
||||
\overload
|
||||
\fn QCborStreamReader::appendToByteArray(QByteArray &dst)
|
||||
\since 6.7
|
||||
|
||||
Decodes the current byte string and appends to \a dst. If the string is
|
||||
@ -1560,9 +1557,9 @@ bool QCborStreamReader::_toUtf8String_helper(QByteArray &dst)
|
||||
|
||||
\include qcborstreamreader.cpp note-not-restartable
|
||||
|
||||
\sa readByteArray(), readStringChunk(), isByteArray(), toString()
|
||||
\sa readByteArray(), readStringChunk(), isByteArray(), appendToString()
|
||||
*/
|
||||
bool QCborStreamReader::_toByteArray_helper(QByteArray &dst)
|
||||
bool QCborStreamReader::_appendToByteArray_helper(QByteArray &dst)
|
||||
{
|
||||
bool ok = d->readFullString(&dst);
|
||||
if (ok)
|
||||
|
@ -120,9 +120,9 @@ public:
|
||||
bool enterContainer() { Q_ASSERT(isContainer()); return _enterContainer_helper(); }
|
||||
bool leaveContainer();
|
||||
|
||||
bool toString(QString &dst) { Q_ASSERT(isString()); return _toString_helper(dst); }
|
||||
bool toUtf8String(QByteArray &dst) { Q_ASSERT(isString()); return _toUtf8String_helper(dst); }
|
||||
bool toByteArray(QByteArray &dst) { Q_ASSERT(isByteArray()); return _toByteArray_helper(dst); }
|
||||
bool appendToString(QString &dst) { Q_ASSERT(isString()); return _appendToString_helper(dst); }
|
||||
bool appendToUtf8String(QByteArray &dst){ Q_ASSERT(isString()); return _appendToUtf8String_helper(dst); }
|
||||
bool appendToByteArray(QByteArray &dst) { Q_ASSERT(isByteArray()); return _appendToByteArray_helper(dst); }
|
||||
StringResult<QString> readString() { Q_ASSERT(isString()); return _readString_helper(); }
|
||||
StringResult<QByteArray> readUtf8String() { Q_ASSERT(isString()); return _readUtf8String_helper(); }
|
||||
StringResult<QByteArray> readByteArray(){ Q_ASSERT(isByteArray()); return _readByteArray_helper(); }
|
||||
@ -149,21 +149,21 @@ public:
|
||||
QString toString()
|
||||
{
|
||||
QString dst;
|
||||
if (!toString(dst))
|
||||
if (!appendToString(dst))
|
||||
dst.clear();
|
||||
return dst;
|
||||
}
|
||||
QByteArray toUtf8String()
|
||||
{
|
||||
QByteArray dst;
|
||||
if (!toUtf8String(dst))
|
||||
if (!appendToUtf8String(dst))
|
||||
dst.clear();
|
||||
return dst;
|
||||
}
|
||||
QByteArray toByteArray()
|
||||
{
|
||||
QByteArray dst;
|
||||
if (!toByteArray(dst))
|
||||
if (!appendToByteArray(dst))
|
||||
dst.clear();
|
||||
return dst;
|
||||
}
|
||||
@ -175,9 +175,9 @@ private:
|
||||
StringResult<QByteArray> _readUtf8String_helper();
|
||||
StringResult<QByteArray> _readByteArray_helper();
|
||||
qsizetype _currentStringChunkSize() const;
|
||||
bool _toString_helper(QString &);
|
||||
bool _toUtf8String_helper(QByteArray &);
|
||||
bool _toByteArray_helper(QByteArray &);
|
||||
bool _appendToString_helper(QString &);
|
||||
bool _appendToUtf8String_helper(QByteArray &);
|
||||
bool _appendToByteArray_helper(QByteArray &);
|
||||
|
||||
template <typename FP> FP _toFloatingPoint() const noexcept
|
||||
{
|
||||
|
@ -699,12 +699,12 @@ void tst_QCborStreamReader::strings()
|
||||
if (reader.isByteArray()) {
|
||||
QByteArray prefix("some prefix");
|
||||
QByteArray ba = prefix;
|
||||
QVERIFY(reader.toByteArray(ba));
|
||||
QVERIFY(reader.appendToByteArray(ba));
|
||||
QCOMPARE(ba, prefix + fullString);
|
||||
} else {
|
||||
QString prefix("some prefix");
|
||||
QString str = prefix;
|
||||
QVERIFY(reader.toString(str));
|
||||
QVERIFY(reader.appendToString(str));
|
||||
QCOMPARE(str, prefix + QString::fromUtf8(fullString));
|
||||
}
|
||||
|
||||
@ -714,7 +714,7 @@ void tst_QCborStreamReader::strings()
|
||||
if (reader.isString()) {
|
||||
QByteArray prefix("some prefix");
|
||||
QByteArray utf8 = prefix;
|
||||
QVERIFY(reader.toUtf8String(utf8));
|
||||
QVERIFY(reader.appendToUtf8String(utf8));
|
||||
QCOMPARE(utf8, prefix + fullString);
|
||||
|
||||
reader.reset();
|
||||
@ -954,12 +954,12 @@ void tst_QCborStreamReader::validation()
|
||||
if (reader.isString()) {
|
||||
QString prefix = "some prefix";
|
||||
QString str = prefix;
|
||||
QVERIFY(!reader.toString(str));
|
||||
QVERIFY(!reader.appendToString(str));
|
||||
QVERIFY(str.startsWith(prefix)); // but may have decoded some
|
||||
} else if (reader.isByteArray()) {
|
||||
QByteArray prefix = "some prefix";
|
||||
QByteArray ba = prefix;
|
||||
QVERIFY(!reader.toByteArray(ba));
|
||||
QVERIFY(!reader.appendToByteArray(ba));
|
||||
QVERIFY(ba.startsWith(prefix)); // but may have decoded some
|
||||
}
|
||||
QCOMPARE(reader.lastError(), error);
|
||||
@ -977,7 +977,7 @@ void tst_QCborStreamReader::validation()
|
||||
if (reader.isString()) {
|
||||
QByteArray prefix = "some prefix";
|
||||
QByteArray ba = prefix;
|
||||
QVERIFY(!reader.toUtf8String(ba));
|
||||
QVERIFY(!reader.appendToUtf8String(ba));
|
||||
QVERIFY(ba.startsWith(prefix)); // but may have decoded some
|
||||
QCOMPARE(reader.lastError(), error);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user