diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-04-23 16:39:13 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-07 05:06:26 +0200 |
commit | 592fe0a02609503670cc9238d1a4ad29e4e65185 (patch) | |
tree | a176f70a79f64e7216ffb2ef3b86018c29286e78 /src/corelib/tools/qstring.h | |
parent | a637a5ae29447980459865468e74cd1356d04da5 (diff) |
Change QString's default codec to be UTF-8
This is a crude change, not the most efficient way. I'll clean up and
make it prettier later on, when I've had the chance to optimise the
UTF-8 codec too.
Change-Id: I78e30e8d3bddf6ad0210c9c4cedb9a7ce63d1a7d
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qstring.h')
-rw-r--r-- | src/corelib/tools/qstring.h | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index bf2928346c..1ddaded7b3 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -80,6 +80,12 @@ template <typename T> class QVector; typedef QTypedArrayData<ushort> QStringData; +Q_CORE_EXPORT bool qStringComparisonHelper(const QString &s1, const char *s2); +Q_CORE_EXPORT bool qStringComparisonHelper(const QString &s1, const QByteArray &s2); +Q_CORE_EXPORT bool qStringComparisonHelper(const QStringRef &s1, const char *s2); +Q_CORE_EXPORT bool qStringComparisonHelper(const QStringRef &s1, const QByteArray &s2); + + #if defined(Q_COMPILER_UNICODE_STRINGS) #define QT_UNICODE_LITERAL_II(str) u"" str @@ -441,8 +447,7 @@ public: // note - this are all inline so we can benefit from strlen() compile time optimizations static inline QString fromAscii(const char *str, int size = -1) { - QStringDataPtr dataPtr = { fromAscii_helper(str, (str && size == -1) ? int(strlen(str)) : size) }; - return QString(dataPtr); + return fromUtf8(str, size); } static inline QString fromLatin1(const char *str, int size = -1) { @@ -669,8 +674,10 @@ private: friend class QTextCodec; friend class QStringRef; friend struct QAbstractConcatenable; - friend inline bool qStringComparisonHelper(const QString &s1, const char *s2); - friend inline bool qStringComparisonHelper(const QStringRef &s1, const char *s2); + friend bool qStringComparisonHelper(const QString &s1, const char *s2); + friend bool qStringComparisonHelper(const QString &s1, const QByteArray &s2); + friend bool qStringComparisonHelper(const QStringRef &s1, const char *s2); + friend bool qStringComparisonHelper(const QStringRef &s1, const QByteArray &s2); public: typedef Data * DataPtr; inline DataPtr &data_ptr() { return d; } @@ -734,7 +741,6 @@ private: // Qt 4.x compatibility typedef QLatin1String QLatin1Literal; - inline QString::QString(const QLatin1String &aLatin1) : d(fromLatin1_helper(aLatin1.latin1(), aLatin1.size())) { } inline int QString::length() const @@ -980,10 +986,6 @@ inline bool operator!=(QString::Null, const QString &s) { return !s.isNull(); } inline bool operator!=(const QString &s, QString::Null) { return !s.isNull(); } #ifndef QT_NO_CAST_FROM_ASCII -inline bool qStringComparisonHelper(const QString &s1, const char *s2) -{ - return (s1 == QLatin1String(s2)); -} inline bool QString::operator==(const char *s) const { return qStringComparisonHelper(*this, s); } inline bool QString::operator!=(const char *s) const @@ -1265,11 +1267,6 @@ inline bool operator<=(const QStringRef &s1, const QStringRef &s2) inline bool operator>=(const QStringRef &s1, const QStringRef &s2) { return !(s1 < s2); } -inline bool qStringComparisonHelper(const QStringRef &s1, const char *s2) -{ - return (s1 == QLatin1String(s2)); -} - inline QT_ASCII_CAST_WARN bool operator==(const char *s1, const QStringRef &s2) { return qStringComparisonHelper(s2, s1); } inline QT_ASCII_CAST_WARN bool operator==(const QStringRef &s1, const char *s2) |