summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-01-08 15:13:28 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2010-01-08 15:14:07 (GMT)
commitf0d2a0d7a9ed0500a1423bbf1362b234525f8be7 (patch)
treec6247568431f5a8f9fc12fe145921bc9851398e4
parentfdac6df6d46e6d4f00763365de5a4437ad06ba39 (diff)
downloadQt-f0d2a0d7a9ed0500a1423bbf1362b234525f8be7.zip
Qt-f0d2a0d7a9ed0500a1423bbf1362b234525f8be7.tar.gz
Qt-f0d2a0d7a9ed0500a1423bbf1362b234525f8be7.tar.bz2
Reverted two commits that were pushed to the wrong branch.
Revert "Use the new QTextCodec api in the QXmlStreamWriter." This reverts commit fdac6df6d46e6d4f00763365de5a4437ad06ba39. Revert "Added new functions to QTextCodec that accept ConversionFlags." This reverts commit 7fb78e7f60ea72e9e471d6cbc4403d490581df17.
-rw-r--r--src/corelib/codecs/qtextcodec.cpp49
-rw-r--r--src/corelib/codecs/qtextcodec.h16
-rw-r--r--src/corelib/xml/qxmlstream.cpp7
3 files changed, 13 insertions, 59 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 86845c7..698ca9e 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1163,19 +1163,6 @@ QTextDecoder* QTextCodec::makeDecoder() const
return new QTextDecoder(this);
}
-/*!
- Creates a QTextDecoder with a specified \a flags to decode chunks
- of \c{char *} data to create chunks of Unicode data.
-
- The caller is responsible for deleting the returned object.
-
- \since 4.7
-*/
-QTextDecoder* QTextCodec::makeDecoder(QTextCodec::ConversionFlags flags) const
-{
- return new QTextDecoder(this, flags);
-}
-
/*!
Creates a QTextEncoder which stores enough state to encode chunks
@@ -1189,19 +1176,6 @@ QTextEncoder* QTextCodec::makeEncoder() const
}
/*!
- Creates a QTextEncoder with a specified \a flags to encode chunks
- of Unicode data as \c{char *} data.
-
- The caller is responsible for deleting the returned object.
-
- \since 4.7
-*/
-QTextEncoder* QTextCodec::makeEncoder(QTextCodec::ConversionFlags flags) const
-{
- return new QTextEncoder(this, flags);
-}
-
-/*!
\fn QByteArray QTextCodec::fromUnicode(const QChar *input, int number,
ConverterState *state) const
@@ -1342,17 +1316,6 @@ QString QTextCodec::toUnicode(const char *chars) const
*/
/*!
- Constructs a text encoder for the given \a codec and conversion \a flags.
-
- \since 4.7
-*/
-QTextEncoder::QTextEncoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags)
- : c(codec), state()
-{
- state.flags = flags;
-}
-
-/*!
Destroys the encoder.
*/
QTextEncoder::~QTextEncoder()
@@ -1429,18 +1392,6 @@ QByteArray QTextEncoder::fromUnicode(const QString& uc, int& lenInOut)
*/
/*!
- Constructs a text decoder for the given \a codec and conversion \a flags.
-
- \since 4.7
-*/
-
-QTextDecoder::QTextDecoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags)
- : c(codec), state()
-{
- state.flags = flags;
-}
-
-/*!
Destroys the decoder.
*/
QTextDecoder::~QTextDecoder()
diff --git a/src/corelib/codecs/qtextcodec.h b/src/corelib/codecs/qtextcodec.h
index e37527d..a099dd9 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -85,6 +85,9 @@ public:
static QTextCodec *codecForUtfText(const QByteArray &ba);
static QTextCodec *codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec);
+ QTextDecoder* makeDecoder() const;
+ QTextEncoder* makeEncoder() const;
+
bool canEncode(QChar) const;
bool canEncode(const QString&) const;
@@ -117,12 +120,6 @@ public:
QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = 0) const
{ return convertFromUnicode(in, length, state); }
- // ### Qt 5: merge these functions.
- QTextDecoder* makeDecoder() const;
- QTextDecoder* makeDecoder(ConversionFlags flags) const;
- QTextEncoder* makeEncoder() const;
- QTextEncoder* makeEncoder(ConversionFlags flags) const;
-
virtual QByteArray name() const = 0;
virtual QList<QByteArray> aliases() const;
virtual int mibEnum() const = 0;
@@ -160,7 +157,6 @@ class Q_CORE_EXPORT QTextEncoder {
Q_DISABLE_COPY(QTextEncoder)
public:
explicit QTextEncoder(const QTextCodec *codec) : c(codec), state() {}
- QTextEncoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags);
~QTextEncoder();
QByteArray fromUnicode(const QString& str);
QByteArray fromUnicode(const QChar *uc, int len);
@@ -171,13 +167,17 @@ public:
private:
const QTextCodec *c;
QTextCodec::ConverterState state;
+
+ friend class QXmlStreamWriter;
+ friend class QXmlStreamWriterPrivate;
+ friend class QCoreXmlStreamWriter;
+ friend class QCoreXmlStreamWriterPrivate;
};
class Q_CORE_EXPORT QTextDecoder {
Q_DISABLE_COPY(QTextDecoder)
public:
explicit QTextDecoder(const QTextCodec *codec) : c(codec), state() {}
- QTextDecoder(const QTextCodec *codec, QTextCodec::ConversionFlags flags);
~QTextDecoder();
QString toUnicode(const char* chars, int len);
QString toUnicode(const QByteArray &ba);
diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp
index 1bf00b8..5717ca2 100644
--- a/src/corelib/xml/qxmlstream.cpp
+++ b/src/corelib/xml/qxmlstream.cpp
@@ -3003,7 +3003,8 @@ QXmlStreamWriterPrivate::QXmlStreamWriterPrivate(QXmlStreamWriter *q)
deleteDevice = false;
#ifndef QT_NO_TEXTCODEC
codec = QTextCodec::codecForMib(106); // utf8
- encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8
+ encoder = codec->makeEncoder();
+ encoder->state.flags |= QTextCodec::IgnoreHeader; // no byte order mark for utf8
#endif
inStartElement = inEmptyElement = false;
wroteSomething = false;
@@ -3277,7 +3278,9 @@ void QXmlStreamWriter::setCodec(QTextCodec *codec)
if (codec) {
d->codec = codec;
delete d->encoder;
- d->encoder = codec->makeEncoder(QTextCodec::IgnoreHeader); // no byte order mark for utf8
+ d->encoder = codec->makeEncoder();
+ if (codec->mibEnum() == 106)
+ d->encoder->state.flags |= QTextCodec::IgnoreHeader; // no byte order mark for utf8
}
}