inline QDebug &operator<<(const char* t) { stream->ts << QString::fromAscii(t); return maybeSpace(); }
inline QDebug &operator<<(const QString & t) { stream->ts << '\"' << t << '\"'; return maybeSpace(); }
inline QDebug &operator<<(const QStringRef & t) { return operator<<(t.toString()); }
- inline QDebug &operator<<(const QLatin1String &t) { stream->ts << '\"' << t.latin1() << '\"'; return maybeSpace(); }
+ inline QDebug &operator<<(const QLatin1String &t) { stream->ts << '\"' << t << '\"'; return maybeSpace(); }
inline QDebug &operator<<(const QByteArray & t) { stream->ts << '\"' << t << '\"'; return maybeSpace(); }
inline QDebug &operator<<(const void * t) { stream->ts << t; return maybeSpace(); }
inline QDebug &operator<<(QTextStreamFunction f) {
/*!
\overload
+ Writes \a string to the stream, and returns a reference to the
+ QTextStream. The contents of \a string are converted with the
+ QString constructor that takes a QLatin1String as argument.
+*/
+QTextStream &QTextStream::operator<<(const QLatin1String &string)
+{
+ Q_D(QTextStream);
+ CHECK_VALID_STREAM(*this);
+ d->putString(QString(string));
+ return *this;
+}
+
+/*!
+ \overload
+
Writes \a array to the stream. The contents of \a array are
converted with QString::fromAscii().
*/
QTextStream &operator<<(float f);
QTextStream &operator<<(double f);
QTextStream &operator<<(const QString &s);
+ QTextStream &operator<<(const QLatin1String &s);
QTextStream &operator<<(const QByteArray &array);
QTextStream &operator<<(const char *c);
QTextStream &operator<<(const void *ptr);
void debugWithBool() const;
void veryLongWarningMessage() const;
void qDebugQStringRef() const;
+ void qDebugQLatin1String() const;
void defaultMessagehandler() const;
};
}
}
+void tst_QDebug::qDebugQLatin1String() const
+{
+ MessageHandlerSetter mhs(myMessageHandler);
+ { qDebug() << QLatin1String("foo") << QLatin1String("") << QLatin1String("barbaz", 3); }
+ QString file = __FILE__; int line = __LINE__ - 1; QString function = Q_FUNC_INFO;
+ QCOMPARE(s_msgType, QtDebugMsg);
+ QCOMPARE(QString::fromLatin1(s_msg), QString::fromLatin1("\"foo\" \"\" \"bar\" "));
+ QCOMPARE(QString::fromLatin1(s_file), file);
+ QCOMPARE(s_line, line);
+ QCOMPARE(QString::fromLatin1(s_function), function);
+}
+
void tst_QDebug::defaultMessagehandler() const
{
MessageHandlerSetter mhs(0);
// text write operators
void string_write_operator_ToDevice_data();
void string_write_operator_ToDevice();
+ void latin1String_write_operator_ToDevice();
// other
void skipWhiteSpace_data();
}
}
+void tst_QTextStream::latin1String_write_operator_ToDevice()
+{
+ QBuffer buf;
+ buf.open(QBuffer::WriteOnly);
+ QTextStream stream(&buf);
+ stream.setCodec(QTextCodec::codecForName("ISO-8859-1"));
+ stream.setAutoDetectUnicode(true);
+
+ stream << QLatin1String("No explicit length");
+ stream << QLatin1String("Explicit length - ignore this part", 15);
+ stream.flush();
+ QCOMPARE(buf.buffer().constData(), "No explicit lengthExplicit length");
+}
+
// ------------------------------------------------------------------------------
void tst_QTextStream::useCase1()
{