Rename QTextStream::readLine(QString *, qint64) into readLineInto

As discussed on the development mailing list, the new overload is ambiguous
and breaks source compatibility. Therefore this function that is new in 5.5
shall be called readLineInto.

Change-Id: I2aecb8441af4edb72f16d0bc6dabf10cdabf32e2
Reviewed-by: Jan Kundrát <jkt@kde.org>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Simon Hausmann 2015-06-02 16:20:28 +02:00 committed by Jani Heikkinen
parent eea1094349
commit 21674735cc
3 changed files with 12 additions and 12 deletions

View File

@ -1591,7 +1591,7 @@ QString QTextStream::readLine(qint64 maxlen)
{
QString line;
readLine(&line, maxlen);
readLineInto(&line, maxlen);
return line;
}
@ -1620,7 +1620,7 @@ QString QTextStream::readLine(qint64 maxlen)
\sa readAll(), QIODevice::readLine()
*/
bool QTextStream::readLine(QString *line, qint64 maxlen)
bool QTextStream::readLineInto(QString *line, qint64 maxlen)
{
Q_D(QTextStream);
// keep in sync with CHECK_VALID_STREAM

View File

@ -124,7 +124,7 @@ public:
void skipWhiteSpace();
QString readLine(qint64 maxlen = 0);
bool readLine(QString *line, qint64 maxlen = 0);
bool readLineInto(QString *line, qint64 maxlen = 0);
QString readAll();
QString read(qint64 maxlen);

View File

@ -81,7 +81,7 @@ private slots:
void readLineMaxlen_data();
void readLineMaxlen();
void readLinesFromBufferCRCR();
void readLineOverload();
void readLineInto();
// all
void readAllFromDevice_data();
@ -612,22 +612,22 @@ protected:
}
};
void tst_QTextStream::readLineOverload()
void tst_QTextStream::readLineInto()
{
QByteArray data = "1\n2\n3";
QTextStream ts(&data);
QString line;
ts.readLine(&line);
ts.readLineInto(&line);
QCOMPARE(line, QStringLiteral("1"));
ts.readLine(Q_NULLPTR, 0); // read the second line, but don't store it
ts.readLineInto(Q_NULLPTR, 0); // read the second line, but don't store it
ts.readLine(&line);
ts.readLineInto(&line);
QCOMPARE(line, QStringLiteral("3"));
QVERIFY(!ts.readLine(&line));
QVERIFY(!ts.readLineInto(&line));
QVERIFY(line.isEmpty());
QFile file(m_rfc3261FilePath);
@ -637,7 +637,7 @@ void tst_QTextStream::readLineOverload()
line.reserve(1);
int maxLineCapacity = line.capacity();
while (ts.readLine(&line)) {
while (ts.readLineInto(&line)) {
QVERIFY(line.capacity() >= maxLineCapacity);
maxLineCapacity = line.capacity();
}
@ -647,7 +647,7 @@ void tst_QTextStream::readLineOverload()
QVERIFY(errorDevice.open(QIODevice::ReadOnly));
ts.setDevice(&errorDevice);
QVERIFY(!ts.readLine(&line));
QVERIFY(!ts.readLineInto(&line));
QVERIFY(line.isEmpty());
}
@ -1025,7 +1025,7 @@ void tst_QTextStream::performance()
QTextStream stream2(&file3);
QString line;
while (stream2.readLine(&line))
while (stream2.readLineInto(&line))
++nlines3;
elapsed[2] = stopWatch.elapsed();