diff options
author | Liang Qi <liang.qi@qt.io> | 2018-10-02 12:59:24 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-11-07 13:19:54 +0000 |
commit | 825f98815683faea06144ab0262129b0367798ee (patch) | |
tree | 48b10de0d86c6312d07700eb4e690dbd87ab8db0 /src/corelib | |
parent | b5d249f9538bf3dc44f11879c2244deb5a37bf97 (diff) | |
download | qtbase-825f98815683faea06144ab0262129b0367798ee.tar.gz |
Modernize the "textcodec" feature
Also clean up QTextCodec usage in qmake build and some includes
of qtextcodec.h.
Change-Id: I0475b82690024054add4e85a8724c8ea3adcf62a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'src/corelib')
31 files changed, 138 insertions, 142 deletions
diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri index d86d446c72..f1bbde1d69 100644 --- a/src/corelib/codecs/codecs.pri +++ b/src/corelib/codecs/codecs.pri @@ -1,62 +1,68 @@ # Qt core library codecs module HEADERS += \ - codecs/qlatincodec_p.h \ - codecs/qsimplecodec_p.h \ codecs/qtextcodec_p.h \ - codecs/qtextcodec.h \ codecs/qutfcodec_p.h SOURCES += \ - codecs/qlatincodec.cpp \ - codecs/qsimplecodec.cpp \ - codecs/qtextcodec.cpp \ codecs/qutfcodec.cpp -qtConfig(codecs) { +qtConfig(textcodec) { HEADERS += \ - codecs/qisciicodec_p.h \ - codecs/qtsciicodec_p.h + codecs/qlatincodec_p.h \ + codecs/qsimplecodec_p.h \ + codecs/qtextcodec.h SOURCES += \ - codecs/qisciicodec.cpp \ - codecs/qtsciicodec.cpp -} + codecs/qlatincodec.cpp \ + codecs/qsimplecodec.cpp \ + codecs/qtextcodec.cpp -qtConfig(icu) { - HEADERS += \ - codecs/qicucodec_p.h - SOURCES += \ - codecs/qicucodec.cpp -} else { - qtConfig(big_codecs) { + qtConfig(codecs) { HEADERS += \ - codecs/qgb18030codec_p.h \ - codecs/qeucjpcodec_p.h \ - codecs/qjiscodec_p.h \ - codecs/qsjiscodec_p.h \ - codecs/qeuckrcodec_p.h \ - codecs/qbig5codec_p.h + codecs/qisciicodec_p.h \ + codecs/qtsciicodec_p.h SOURCES += \ - codecs/qgb18030codec.cpp \ - codecs/qjpunicode.cpp \ - codecs/qeucjpcodec.cpp \ - codecs/qjiscodec.cpp \ - codecs/qsjiscodec.cpp \ - codecs/qeuckrcodec.cpp \ - codecs/qbig5codec.cpp + codecs/qisciicodec.cpp \ + codecs/qtsciicodec.cpp } - qtConfig(iconv) { - HEADERS += codecs/qiconvcodec_p.h - SOURCES += codecs/qiconvcodec.cpp - qtConfig(gnu-libiconv): \ - QMAKE_USE_PRIVATE += iconv - } + qtConfig(icu) { + HEADERS += \ + codecs/qicucodec_p.h + SOURCES += \ + codecs/qicucodec.cpp + } else { + qtConfig(big_codecs) { + HEADERS += \ + codecs/qgb18030codec_p.h \ + codecs/qeucjpcodec_p.h \ + codecs/qjiscodec_p.h \ + codecs/qsjiscodec_p.h \ + codecs/qeuckrcodec_p.h \ + codecs/qbig5codec_p.h + + SOURCES += \ + codecs/qgb18030codec.cpp \ + codecs/qjpunicode.cpp \ + codecs/qeucjpcodec.cpp \ + codecs/qjiscodec.cpp \ + codecs/qsjiscodec.cpp \ + codecs/qeuckrcodec.cpp \ + codecs/qbig5codec.cpp + } + + qtConfig(iconv) { + HEADERS += codecs/qiconvcodec_p.h + SOURCES += codecs/qiconvcodec.cpp + qtConfig(gnu-libiconv): \ + QMAKE_USE_PRIVATE += iconv + } - win32 { - SOURCES += codecs/qwindowscodec.cpp - HEADERS += codecs/qwindowscodec_p.h + win32 { + SOURCES += codecs/qwindowscodec.cpp + HEADERS += codecs/qwindowscodec_p.h + } } } diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 330eb7c038..9c39727946 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -39,8 +39,6 @@ #include <QtCore/private/qglobal_p.h> -QT_REQUIRE_CONFIG(iconv); - #include "qiconvcodec_p.h" #include "qtextcodec_p.h" #include <qdebug.h> diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp index 06a6d95e82..101c3a3278 100644 --- a/src/corelib/codecs/qicucodec.cpp +++ b/src/corelib/codecs/qicucodec.cpp @@ -39,8 +39,6 @@ #include "qicucodec_p.h" -#ifndef QT_NO_TEXTCODEC - #include "qtextcodec_p.h" #include "qutfcodec_p.h" #include "qlatincodec_p.h" @@ -698,5 +696,3 @@ int QIcuCodec::mibEnum() const } QT_END_NAMESPACE - -#endif // QT_NO_TEXTCODEC diff --git a/src/corelib/codecs/qicucodec_p.h b/src/corelib/codecs/qicucodec_p.h index 0c2dbe17d6..1cbe4d4e7a 100644 --- a/src/corelib/codecs/qicucodec_p.h +++ b/src/corelib/codecs/qicucodec_p.h @@ -59,9 +59,9 @@ extern "C" { typedef struct UConverter UConverter; } -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(textcodec); -#ifndef QT_NO_TEXTCODEC +QT_BEGIN_NAMESPACE class QIcuCodec : public QTextCodec { @@ -90,8 +90,6 @@ private: const char *m_name; }; -#endif // QT_NO_TEXTCODEC - QT_END_NAMESPACE #endif diff --git a/src/corelib/codecs/qlatincodec.cpp b/src/corelib/codecs/qlatincodec.cpp index cfbd481f1e..1b53d26ef4 100644 --- a/src/corelib/codecs/qlatincodec.cpp +++ b/src/corelib/codecs/qlatincodec.cpp @@ -40,8 +40,6 @@ #include "qlatincodec_p.h" #include "qlist.h" -#ifndef QT_NO_TEXTCODEC - QT_BEGIN_NAMESPACE QLatin1Codec::~QLatin1Codec() @@ -238,5 +236,3 @@ int QLatin15Codec::mibEnum() const } QT_END_NAMESPACE - -#endif // QT_NO_TEXTCODEC diff --git a/src/corelib/codecs/qlatincodec_p.h b/src/corelib/codecs/qlatincodec_p.h index 3e258e5ae1..26f9e596a9 100644 --- a/src/corelib/codecs/qlatincodec_p.h +++ b/src/corelib/codecs/qlatincodec_p.h @@ -54,9 +54,9 @@ #include <QtCore/private/qglobal_p.h> #include "QtCore/qtextcodec.h" -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(textcodec); -#ifndef QT_NO_TEXTCODEC +QT_BEGIN_NAMESPACE class QLatin1Codec : public QTextCodec { @@ -86,8 +86,6 @@ public: int mibEnum() const override; }; -#endif // QT_NO_TEXTCODEC - QT_END_NAMESPACE #endif // QLATINCODEC_P_H diff --git a/src/corelib/codecs/qsimplecodec.cpp b/src/corelib/codecs/qsimplecodec.cpp index beb0a08f62..9ab545d783 100644 --- a/src/corelib/codecs/qsimplecodec.cpp +++ b/src/corelib/codecs/qsimplecodec.cpp @@ -40,8 +40,6 @@ #include "qsimplecodec_p.h" #include "qlist.h" -#ifndef QT_NO_TEXTCODEC - QT_BEGIN_NAMESPACE #define LAST_MIB 2004 @@ -724,5 +722,3 @@ int QSimpleTextCodec::mibEnum() const } QT_END_NAMESPACE - -#endif // QT_NO_TEXTCODEC diff --git a/src/corelib/codecs/qsimplecodec_p.h b/src/corelib/codecs/qsimplecodec_p.h index 188c3f3cb4..a4b2a45e6b 100644 --- a/src/corelib/codecs/qsimplecodec_p.h +++ b/src/corelib/codecs/qsimplecodec_p.h @@ -54,9 +54,9 @@ #include <QtCore/private/qglobal_p.h> #include "QtCore/qtextcodec.h" -QT_BEGIN_NAMESPACE +QT_REQUIRE_CONFIG(textcodec); -#ifndef QT_NO_TEXTCODEC +QT_BEGIN_NAMESPACE template <typename T> class QAtomicPointer; @@ -79,8 +79,6 @@ private: mutable QAtomicPointer<QByteArray> reverseMap; }; -#endif // QT_NO_TEXTCODEC - QT_END_NAMESPACE #endif // QSIMPLECODEC_P_H diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 790921610a..1ec443cd73 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -38,11 +38,10 @@ ****************************************************************************/ #include "qplatformdefs.h" + #include "qtextcodec.h" #include "qtextcodec_p.h" -#ifndef QT_NO_TEXTCODEC - #include "qbytearraymatcher.h" #include "qlist.h" #include "qfile.h" @@ -1221,5 +1220,3 @@ bool QTextDecoder::hasFailure() const } QT_END_NAMESPACE - -#endif // QT_NO_TEXTCODEC diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h index 8153bebac8..c0261b7aa2 100644 --- a/src/corelib/codecs/qtextcodec.h +++ b/src/corelib/codecs/qtextcodec.h @@ -43,10 +43,9 @@ #include <QtCore/qstring.h> #include <QtCore/qlist.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(textcodec); -#ifndef QT_NO_TEXTCODEC +QT_BEGIN_NAMESPACE class QTextCodec; class QIODevice; @@ -167,8 +166,6 @@ private: QTextCodec::ConverterState state; }; -#endif // QT_NO_TEXTCODEC - QT_END_NAMESPACE #endif // QTEXTCODEC_H diff --git a/src/corelib/codecs/qtextcodec_p.h b/src/corelib/codecs/qtextcodec_p.h index f3c2d090c9..6e19d1d30e 100644 --- a/src/corelib/codecs/qtextcodec_p.h +++ b/src/corelib/codecs/qtextcodec_p.h @@ -52,12 +52,13 @@ // #include <QtCore/private/qglobal_p.h> -#include "qtextcodec.h" #include <string.h> QT_BEGIN_NAMESPACE -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) + +#include "qtextcodec.h" #if defined(Q_OS_MAC) || defined(Q_OS_ANDROID) || defined(Q_OS_QNX) #define QT_LOCALE_IS_UTF8 @@ -82,7 +83,7 @@ struct QTextCodecUnalignedPointer bool qTextCodecNameMatch(const char *a, const char *b); -#else +#else // without textcodec: class QTextCodec { @@ -109,7 +110,7 @@ public: }; }; -#endif //QT_NO_TEXTCODEC +#endif // textcodec QT_END_NAMESPACE diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp index ce1b092a54..0dffdd723e 100644 --- a/src/corelib/codecs/qutfcodec.cpp +++ b/src/corelib/codecs/qutfcodec.cpp @@ -922,7 +922,7 @@ QString QUtf32::convertToUnicode(const char *chars, int len, QTextCodec::Convert } -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QUtf8Codec::~QUtf8Codec() { @@ -1076,6 +1076,6 @@ QList<QByteArray> QUtf32LECodec::aliases() const return list; } -#endif //QT_NO_TEXTCODEC +#endif // textcodec QT_END_NAMESPACE diff --git a/src/corelib/codecs/qutfcodec_p.h b/src/corelib/codecs/qutfcodec_p.h index 659a229dae..d7743753af 100644 --- a/src/corelib/codecs/qutfcodec_p.h +++ b/src/corelib/codecs/qutfcodec_p.h @@ -52,7 +52,13 @@ // We mean it. // +#include <QtCore/qstring.h> +#include <QtCore/qlist.h> + +#if QT_CONFIG(textcodec) #include "QtCore/qtextcodec.h" +#endif + #include "private/qtextcodec_p.h" QT_BEGIN_NAMESPACE @@ -311,7 +317,7 @@ struct QUtf32 static QByteArray convertFromUnicode(const QChar *, int, QTextCodec::ConverterState *, DataEndianness = DetectEndianness); }; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) class QUtf8Codec : public QTextCodec { public: @@ -391,7 +397,7 @@ public: }; -#endif // QT_NO_TEXTCODEC +#endif // textcodec QT_END_NAMESPACE diff --git a/src/corelib/codecs/qwindowscodec_p.h b/src/corelib/codecs/qwindowscodec_p.h index 2fd3c35378..1ca6d5567e 100644 --- a/src/corelib/codecs/qwindowscodec_p.h +++ b/src/corelib/codecs/qwindowscodec_p.h @@ -53,6 +53,8 @@ #include <QtCore/private/qglobal_p.h> #include "qtextcodec.h" +QT_REQUIRE_CONFIG(textcodec); + QT_BEGIN_NAMESPACE class QWindowsLocalCodec: public QTextCodec diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index da66e3bcd3..229b4d17a1 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -127,7 +127,6 @@ #define QT_NO_COMPRESS #define QT_JSON_READONLY #define QT_NO_STANDARDPATHS -#define QT_NO_TEXTCODEC #define QT_FEATURE_textcodec -1 #else #define QT_FEATURE_codecs -1 diff --git a/src/corelib/global/qt_pch.h b/src/corelib/global/qt_pch.h index b3b526342d..76e46374c3 100644 --- a/src/corelib/global/qt_pch.h +++ b/src/corelib/global/qt_pch.h @@ -66,5 +66,7 @@ #include <qregexp.h> #include <qstring.h> #include <qstringlist.h> +#if QT_CONFIG(textcodec) #include <qtextcodec.h> #endif +#endif diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 4b1b9888d8..580fe6caf3 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -54,7 +54,7 @@ #include "qstandardpaths.h" #include <qdatastream.h> -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) # include "qtextcodec.h" #endif @@ -677,7 +677,7 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result, if (ch <= 0x1F || (ch >= 0x7F && !useCodec)) { result += "\\x" + QByteArray::number(ch, 16); escapeNextIfDigit = true; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) } else if (useCodec) { // slow result += codec->fromUnicode(&unicode[i], 1); @@ -830,7 +830,7 @@ StNormal: ++j; } -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) Q_UNUSED(codec) #else if (codec) { @@ -1668,7 +1668,7 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, int sectionPosition = 0; bool ok = true; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) // detect utf8 BOM const uchar *dd = (const uchar *)data.constData(); if (data.size() >= 3 && dd[0] == 0xef && dd[1] == 0xbb && dd[2] == 0xbf) { @@ -2824,7 +2824,7 @@ QString QSettings::applicationName() const return d->applicationName; } -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) /*! \since 4.5 @@ -2877,7 +2877,7 @@ QTextCodec *QSettings::iniCodec() const return d->iniCodec; } -#endif // QT_NO_TEXTCODEC +#endif // textcodec /*! Returns a status code indicating the first error that was met by diff --git a/src/corelib/io/qsettings.h b/src/corelib/io/qsettings.h index d78edd23a2..ccfec787a6 100644 --- a/src/corelib/io/qsettings.h +++ b/src/corelib/io/qsettings.h @@ -178,7 +178,7 @@ public: QString organizationName() const; QString applicationName() const; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) void setIniCodec(QTextCodec *codec); void setIniCodec(const char *codecName); QTextCodec *iniCodec() const; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 4e32f90964..0ea969ece5 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -55,7 +55,6 @@ #include <qmutex.h> #include <private/qloggingregistry_p.h> #include <qstandardpaths.h> -#include <qtextcodec.h> #ifndef QT_NO_QOBJECT #include <qthread.h> #include <qthreadpool.h> diff --git a/src/corelib/kernel/qcoreglobaldata.cpp b/src/corelib/kernel/qcoreglobaldata.cpp index e2087b9e64..c3ca2f74e4 100644 --- a/src/corelib/kernel/qcoreglobaldata.cpp +++ b/src/corelib/kernel/qcoreglobaldata.cpp @@ -38,7 +38,9 @@ ****************************************************************************/ #include "qcoreglobaldata_p.h" +#if QT_CONFIG(textcodec) #include "qtextcodec.h" +#endif QT_BEGIN_NAMESPACE diff --git a/src/corelib/kernel/qcoreglobaldata_p.h b/src/corelib/kernel/qcoreglobaldata_p.h index c3c2f7b4a4..fda6b52b6e 100644 --- a/src/corelib/kernel/qcoreglobaldata_p.h +++ b/src/corelib/kernel/qcoreglobaldata_p.h @@ -57,7 +57,9 @@ #include "QtCore/qreadwritelock.h" #include "QtCore/qhash.h" #include "QtCore/qbytearray.h" +#if QT_CONFIG(textcodec) #include "QtCore/qtextcodec.h" +#endif #include "QtCore/qmutex.h" QT_BEGIN_NAMESPACE diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp index 73307e925a..c8ad1bc43f 100644 --- a/src/corelib/kernel/qmimedata.cpp +++ b/src/corelib/kernel/qmimedata.cpp @@ -42,7 +42,9 @@ #include "private/qobject_p.h" #include "qurl.h" #include "qstringlist.h" +#if QT_CONFIG(textcodec) #include "qtextcodec.h" +#endif QT_BEGIN_NAMESPACE @@ -150,7 +152,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty if (data.type() == QVariant::ByteArray) { // see if we can convert to the requested type switch(type) { -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) case QVariant::String: { const QByteArray ba = data.toByteArray(); QTextCodec *codec = QTextCodec::codecForName("utf-8"); @@ -158,7 +160,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty codec = QTextCodec::codecForHtml(ba, codec); return codec->toUnicode(ba); } -#endif // QT_NO_TEXTCODEC +#endif // textcodec case QVariant::Color: { QVariant newData = data; newData.convert(QVariant::Color); diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp index ee3cb4efcb..c0a9854d8b 100644 --- a/src/corelib/serialization/qtextstream.cpp +++ b/src/corelib/serialization/qtextstream.cpp @@ -326,7 +326,7 @@ QT_BEGIN_NAMESPACE */ QTextStreamPrivate::QTextStreamPrivate(QTextStream *q_ptr) : -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) readConverterSavedState(0), #endif readConverterSavedStateOffset(0), @@ -347,12 +347,12 @@ QTextStreamPrivate::~QTextStreamPrivate() #endif delete device; } -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) delete readConverterSavedState; #endif } -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) static void resetCodecConverterStateHelper(QTextCodec::ConverterState *state) { state->~ConverterState(); @@ -401,7 +401,7 @@ void QTextStreamPrivate::reset() readBufferStartDevicePos = 0; lastTokenSize = 0; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) codec = QTextCodec::codecForLocale(); resetCodecConverterStateHelper(&readConverterState); resetCodecConverterStateHelper(&writeConverterState); @@ -461,7 +461,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) if (bytesRead <= 0) return false; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) // codec auto detection, explicitly defaults to locale encoding if the // codec has been set to 0. if (!codec || autoDetectUnicode) { @@ -485,7 +485,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes) #endif int oldReadBufferSize = readBuffer.size(); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) // convert to unicode readBuffer += Q_LIKELY(codec) ? codec->toUnicode(buf, bytesRead, &readConverterState) : QString::fromLatin1(buf, bytesRead); @@ -567,7 +567,7 @@ void QTextStreamPrivate::flushWriteBuffer() } #endif -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if (!codec) codec = QTextCodec::codecForLocale(); #if defined (QTEXTSTREAM_DEBUG) @@ -786,7 +786,7 @@ inline void QTextStreamPrivate::consume(int size) */ inline void QTextStreamPrivate::saveConverterState(qint64 newPos) { -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if (readConverterState.d) { // converter cannot be copied, so don't save anything // don't update readBufferStartDevicePos either @@ -807,7 +807,7 @@ inline void QTextStreamPrivate::saveConverterState(qint64 newPos) */ inline void QTextStreamPrivate::restoreToSavedConverterState() { -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if (readConverterSavedState) { // we have a saved state // that means the converter can be copied @@ -1202,7 +1202,7 @@ bool QTextStream::seek(qint64 pos) return false; d->resetReadBuffer(); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) // Reset the codec converter states. resetCodecConverterStateHelper(&d->readConverterState); resetCodecConverterStateHelper(&d->writeConverterState); @@ -1253,7 +1253,7 @@ qint64 QTextStream::pos() const QTextStreamPrivate *thatd = const_cast<QTextStreamPrivate *>(d); thatd->readBuffer.clear(); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) thatd->restoreToSavedConverterState(); if (d->readBufferStartDevicePos == 0) thatd->autoDetectUnicode = true; @@ -3021,7 +3021,7 @@ QTextStream &ws(QTextStream &stream) Equivalent to QTextStream::setRealNumberPrecision(\a precision). */ -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) /*! \relates QTextStream diff --git a/src/corelib/serialization/qtextstream.h b/src/corelib/serialization/qtextstream.h index ee0b09419d..5c766abc3e 100644 --- a/src/corelib/serialization/qtextstream.h +++ b/src/corelib/serialization/qtextstream.h @@ -98,7 +98,7 @@ public: explicit QTextStream(const QByteArray &array, QIODevice::OpenMode openMode = QIODevice::ReadOnly); virtual ~QTextStream(); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) void setCodec(QTextCodec *codec); void setCodec(const char *codecName); QTextCodec *codec() const; diff --git a/src/corelib/serialization/qtextstream_p.h b/src/corelib/serialization/qtextstream_p.h index a642beddc4..172824d27d 100644 --- a/src/corelib/serialization/qtextstream_p.h +++ b/src/corelib/serialization/qtextstream_p.h @@ -54,7 +54,7 @@ #include <QtCore/private/qglobal_p.h> #include "qtextstream.h" -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) #include "qtextcodec.h" #endif @@ -118,7 +118,7 @@ public: int stringOffset; QIODevice::OpenMode stringOpenMode; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) // codec QTextCodec *codec; QTextCodec::ConverterState readConverterState; @@ -141,7 +141,7 @@ public: int lastTokenSize; bool deleteDevice; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) bool autoDetectUnicode; #endif diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index f18c4cc8e7..77a195a7e5 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -45,7 +45,9 @@ #include <qdebug.h> #include <qfile.h> #include <stdio.h> +#if QT_CONFIG(textcodec) #include <qtextcodec.h> +#endif #include <qstack.h> #include <qbuffer.h> #ifndef QT_BOOTSTRAPPED @@ -420,7 +422,7 @@ QXmlStreamReader::QXmlStreamReader(const QString &data) : d_ptr(new QXmlStreamReaderPrivate(this)) { Q_D(QXmlStreamReader); -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) d->dataBuffer = data.toLatin1(); #else d->dataBuffer = d->codec->fromUnicode(data); @@ -515,7 +517,7 @@ void QXmlStreamReader::addData(const QString &data) { Q_D(QXmlStreamReader); d->lockEncoding = true; -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) addData(data.toLatin1()); #else addData(d->codec->fromUnicode(data)); @@ -792,7 +794,7 @@ QXmlStreamReaderPrivate::QXmlStreamReaderPrivate(QXmlStreamReader *q) { device = 0; deleteDevice = false; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) decoder = 0; #endif stack_size = 64; @@ -838,7 +840,7 @@ void QXmlStreamReaderPrivate::init() lineNumber = lastLineStart = characterOffset = 0; readBufferPos = 0; nbytesread = 0; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) codec = QTextCodec::codecForMib(106); // utf8 delete decoder; decoder = 0; @@ -903,7 +905,7 @@ inline void QXmlStreamReaderPrivate::reallocateStack() QXmlStreamReaderPrivate::~QXmlStreamReaderPrivate() { -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) delete decoder; #endif free(sym_stack); @@ -1482,7 +1484,7 @@ uint QXmlStreamReaderPrivate::getChar_helper() characterOffset += readBufferPos; readBufferPos = 0; readBuffer.resize(0); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if (decoder) #endif nbytesread = 0; @@ -1503,7 +1505,7 @@ uint QXmlStreamReaderPrivate::getChar_helper() return StreamEOF; } -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if (!decoder) { if (nbytesread < 4) { // the 4 is to cover 0xef 0xbb 0xbf plus // one extra for the utf8 codec @@ -1545,7 +1547,7 @@ uint QXmlStreamReaderPrivate::getChar_helper() } #else readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread); -#endif // QT_NO_TEXTCODEC +#endif // textcodec readBuffer.reserve(1); // keep capacity when calling resize() next time @@ -1816,7 +1818,7 @@ void QXmlStreamReaderPrivate::startDocument() if (!QXmlUtils::isEncName(value)) err = QXmlStream::tr("%1 is an invalid encoding name.").arg(value); else { -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) readBuffer = QString::fromLatin1(rawReadBuffer.data(), nbytesread); #else QTextCodec *const newCodec = QTextCodec::codecForName(value.toLatin1()); @@ -1828,7 +1830,7 @@ void QXmlStreamReaderPrivate::startDocument() decoder = codec->makeDecoder(); decoder->toUnicode(&readBuffer, rawReadBuffer.data(), nbytesread); } -#endif // QT_NO_TEXTCODEC +#endif // textcodec } } else if (prefix.isEmpty() && key == QLatin1String("standalone")) { hasStandalone = true; @@ -2966,7 +2968,7 @@ public: ~QXmlStreamWriterPrivate() { if (deleteDevice) delete device; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) delete encoder; #endif } @@ -2993,7 +2995,7 @@ public: NamespaceDeclaration emptyNamespace; int lastNamespaceDeclaration; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec *codec; QTextEncoder *encoder; #endif @@ -3015,7 +3017,7 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) device = 0; stringDevice = 0; deleteDevice = false; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) codec = QTextCodec::codecForMib(106); // utf8 encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8 #endif @@ -3032,7 +3034,7 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q) void QXmlStreamWriterPrivate::checkIfASCIICompatibleCodec() { -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) Q_ASSERT(encoder); // test ASCII-compatibility using the letter 'a' QChar letterA = QLatin1Char('a'); @@ -3052,7 +3054,7 @@ void QXmlStreamWriterPrivate::write(const QStringRef &s) if (device) { if (hasIoError) return; -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) QByteArray bytes = s.toLatin1(); #else QByteArray bytes = encoder->fromUnicode(s.constData(), s.size()); @@ -3075,7 +3077,7 @@ void QXmlStreamWriterPrivate::write(const QString &s) if (device) { if (hasIoError) return; -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) QByteArray bytes = s.toLatin1(); #else QByteArray bytes = encoder->fromUnicode(s); @@ -3324,7 +3326,7 @@ QIODevice *QXmlStreamWriter::device() const } -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) /*! Sets the codec for this stream to \a codec. The codec is used for encoding any data that is written. By default, QXmlStreamWriter @@ -3382,7 +3384,7 @@ QTextCodec *QXmlStreamWriter::codec() const Q_D(const QXmlStreamWriter); return d->codec; } -#endif // QT_NO_TEXTCODEC +#endif // textcodec /*! \property QXmlStreamWriter::autoFormatting @@ -3847,7 +3849,7 @@ void QXmlStreamWriter::writeStartDocument(const QString &version) d->write(version); if (d->device) { // stringDevice does not get any encoding d->write("\" encoding=\""); -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) d->write("iso-8859-1"); #else const QByteArray name = d->codec->name(); @@ -3871,7 +3873,7 @@ void QXmlStreamWriter::writeStartDocument(const QString &version, bool standalon d->write(version); if (d->device) { // stringDevice does not get any encoding d->write("\" encoding=\""); -#ifdef QT_NO_TEXTCODEC +#if !QT_CONFIG(textcodec) d->write("iso-8859-1"); #else const QByteArray name = d->codec->name(); diff --git a/src/corelib/serialization/qxmlstream.g b/src/corelib/serialization/qxmlstream.g index fd69a6e4af..10bfcd491c 100644 --- a/src/corelib/serialization/qxmlstream.g +++ b/src/corelib/serialization/qxmlstream.g @@ -291,7 +291,7 @@ public: QIODevice *device; bool deleteDevice; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec *codec; QTextDecoder *decoder; #endif @@ -584,7 +584,7 @@ bool QXmlStreamReaderPrivate::parse() lockEncoding = true; documentVersion.clear(); documentEncoding.clear(); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if (decoder && decoder->hasFailure()) { raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content.")); readBuffer.clear(); diff --git a/src/corelib/serialization/qxmlstream.h b/src/corelib/serialization/qxmlstream.h index 2350d12dd6..d30c6bc01f 100644 --- a/src/corelib/serialization/qxmlstream.h +++ b/src/corelib/serialization/qxmlstream.h @@ -478,7 +478,7 @@ public: void setDevice(QIODevice *device); QIODevice *device() const; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) void setCodec(QTextCodec *codec); void setCodec(const char *codecName); QTextCodec *codec() const; diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h index f8b1ede943..61f501f81b 100644 --- a/src/corelib/serialization/qxmlstream_p.h +++ b/src/corelib/serialization/qxmlstream_p.h @@ -788,7 +788,7 @@ public: QIODevice *device; bool deleteDevice; -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec *codec; QTextDecoder *decoder; #endif @@ -1081,7 +1081,7 @@ bool QXmlStreamReaderPrivate::parse() lockEncoding = true; documentVersion.clear(); documentEncoding.clear(); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) if (decoder && decoder->hasFailure()) { raiseWellFormedError(QXmlStream::tr("Encountered incorrectly encoded content.")); readBuffer.clear(); diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 82a065efc0..0a8b2b4238 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -44,7 +44,7 @@ #include "qregularexpression.h" #endif #include "qunicodetables_p.h" -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) #include <qtextcodec.h> #endif #include <private/qutfcodec_p.h> @@ -5057,11 +5057,11 @@ static QByteArray qt_convert_to_local_8bit(QStringView string) { if (string.isNull()) return QByteArray(); -#ifndef QT_NO_TEXTCODEC +#if QT_CONFIG(textcodec) QTextCodec *localeCodec = QTextCodec::codecForLocale(); if (localeCodec) return localeCodec->fromUnicode(string); -#endif // QT_NO_TEXTCODEC +#endif // textcodec return qt_convert_to_latin1(string); } @@ -5255,13 +5255,13 @@ QString QString::fromLocal8Bit_helper(const char *str, int size) QStringDataPtr empty = { Data::allocate(0) }; return QString(empty); } -#if !defined(QT_NO_TEXTCODEC) +#if QT_CONFIG(textcodec) if (size < 0) size = qstrlen(str); QTextCodec *codec = QTextCodec::codecForLocale(); if (codec) return codec->toUnicode(str, size); -#endif // !QT_NO_TEXTCODEC +#endif // textcodec return fromLatin1(str, size); } diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp index 73748e55a3..081d7136a7 100644 --- a/src/corelib/tools/qstringbuilder.cpp +++ b/src/corelib/tools/qstringbuilder.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qstringbuilder.h" -#include <QtCore/qtextcodec.h> #include <private/qutfcodec_p.h> QT_BEGIN_NAMESPACE |