diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qtextstream.cpp | 30 | ||||
-rw-r--r-- | src/corelib/io/qtextstream_p.h | 2 |
2 files changed, 30 insertions, 2 deletions
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index 4002ce8694..ab2bf98d15 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -835,6 +835,21 @@ inline void QTextStreamPrivate::write(const QString &data) /*! \internal */ +inline void QTextStreamPrivate::write(QChar ch) +{ + if (string) { + // ### What about seek()?? + string->append(ch); + } else { + writeBuffer += ch; + if (writeBuffer.size() > QTEXTSTREAM_BUFFERSIZE) + flushWriteBuffer(); + } +} + +/*! + \internal +*/ inline bool QTextStreamPrivate::getChar(QChar *ch) { if ((string && stringOffset == string->size()) @@ -873,6 +888,17 @@ inline void QTextStreamPrivate::ungetChar(QChar ch) /*! \internal */ +inline void QTextStreamPrivate::putChar(QChar ch) +{ + if (params.fieldWidth > 0) + putString(QString(ch)); + else + write(ch); +} + +/*! + \internal +*/ inline void QTextStreamPrivate::putString(const QString &s, bool number) { QString tmp = s; @@ -2240,7 +2266,7 @@ QTextStream &QTextStream::operator<<(QChar c) { Q_D(QTextStream); CHECK_VALID_STREAM(*this); - d->putString(QString(c)); + d->putChar(c); return *this; } @@ -2253,7 +2279,7 @@ QTextStream &QTextStream::operator<<(char c) { Q_D(QTextStream); CHECK_VALID_STREAM(*this); - d->putString(QString(QChar::fromLatin1(c))); + d->putChar(QChar::fromLatin1(c)); return *this; } diff --git a/src/corelib/io/qtextstream_p.h b/src/corelib/io/qtextstream_p.h index ac6529e195..ea431a4620 100644 --- a/src/corelib/io/qtextstream_p.h +++ b/src/corelib/io/qtextstream_p.h @@ -174,7 +174,9 @@ public: bool getReal(double *f); inline void write(const QString &data); + inline void write(QChar ch); inline void putString(const QString &ch, bool number = false); + inline void putChar(QChar ch); void putNumber(qulonglong number, bool negative); // buffers |