summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/codecs/qtextcodec.cpp49
-rw-r--r--src/corelib/codecs/qtextcodec.h11
2 files changed, 57 insertions, 3 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 5d62095..65152ca 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -1163,6 +1163,19 @@ 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
@@ -1176,6 +1189,19 @@ 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
@@ -1316,6 +1342,17 @@ 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()
@@ -1392,6 +1429,18 @@ 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 6170272..91bccda 100644
--- a/src/corelib/codecs/qtextcodec.h
+++ b/src/corelib/codecs/qtextcodec.h
@@ -85,9 +85,6 @@ 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;
@@ -120,6 +117,12 @@ 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;
@@ -157,6 +160,7 @@ 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);
@@ -173,6 +177,7 @@ 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);