summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qbytearray.cpp6
-rw-r--r--src/corelib/tools/qbytearray.h12
-rw-r--r--src/corelib/tools/qcryptographichash.h2
-rw-r--r--src/corelib/tools/qlocale.h1
-rw-r--r--src/corelib/tools/qlocale_p.h2
-rw-r--r--src/corelib/tools/qlocale_unix.cpp2
-rw-r--r--src/corelib/tools/qpair.h16
-rw-r--r--src/corelib/tools/qscopedvaluerollback.h2
-rw-r--r--src/corelib/tools/qstring.cpp46
-rw-r--r--src/corelib/tools/qstring.h16
-rw-r--r--src/corelib/tools/qstringbuilder.h16
-rw-r--r--src/corelib/tools/qstringmatcher.h2
12 files changed, 75 insertions, 48 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 445fe5cd81..b6719c9536 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -343,7 +343,7 @@ int qstrcmp(const QByteArray &str1, const QByteArray &str2)
{
int l1 = str1.length();
int l2 = str2.length();
- int ret = memcmp(str1, str2, qMin(l1, l2));
+ int ret = memcmp(str1.constData(), str2.constData(), qMin(l1, l2));
if (ret != 0)
return ret;
@@ -995,6 +995,8 @@ QByteArray &QByteArray::operator=(const char *str)
/*! \fn QByteArray::operator const char *() const
\fn QByteArray::operator const void *() const
+ \obsolete Use constData() instead.
+
Returns a pointer to the data stored in the byte array. The
pointer can be used to access the bytes that compose the array.
The data is '\\0'-terminated. The pointer remains valid as long
@@ -2751,7 +2753,7 @@ QDataStream &operator<<(QDataStream &out, const QByteArray &ba)
out << (quint32)0xffffffff;
return out;
}
- return out.writeBytes(ba, ba.size());
+ return out.writeBytes(ba.constData(), ba.size());
}
/*! \relates QByteArray
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 8202097da5..09c43988fd 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -207,8 +207,10 @@ public:
void squeeze();
#ifndef QT_NO_CAST_FROM_BYTEARRAY
- operator const char *() const;
- operator const void *() const;
+#if QT_DEPRECATED_SINCE(5, 0)
+ QT_DEPRECATED operator const char *() const { return constData(); }
+ QT_DEPRECATED operator const void *() const { return constData(); }
+#endif
#endif
char *data();
const char *data() const;
@@ -415,12 +417,6 @@ inline char QByteArray::operator[](uint i) const
inline bool QByteArray::isEmpty() const
{ return d->size == 0; }
-#ifndef QT_NO_CAST_FROM_BYTEARRAY
-inline QByteArray::operator const char *() const
-{ return d->data(); }
-inline QByteArray::operator const void *() const
-{ return d->data(); }
-#endif
inline char *QByteArray::data()
{ detach(); return d->data(); }
inline const char *QByteArray::data() const
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index 2bfc03373a..6ebe389faf 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -65,7 +65,7 @@ public:
Sha512
};
- QCryptographicHash(Algorithm method);
+ explicit QCryptographicHash(Algorithm method);
~QCryptographicHash();
void reset();
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index c029f627b2..2ecd934100 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -42,7 +42,6 @@
#ifndef QLOCALE_H
#define QLOCALE_H
-#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
#include <QtCore/qobjectdefs.h>
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index c6902ca206..ad7c9706c4 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -55,7 +55,7 @@
#include "QtCore/qstring.h"
#include "QtCore/qvarlengtharray.h"
-#include "QtCore/qmetatype.h"
+#include "QtCore/qvariant.h"
#include "qlocale.h"
diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp
index 6ace96f771..f2876912b4 100644
--- a/src/corelib/tools/qlocale_unix.cpp
+++ b/src/corelib/tools/qlocale_unix.cpp
@@ -98,7 +98,7 @@ QLocale QSystemLocale::fallbackLocale() const
lang = qgetenv("LC_NUMERIC");
if (lang.isEmpty())
lang = qgetenv("LANG");
- return QLocale(QLatin1String(lang));
+ return QLocale(QString::fromLatin1(lang));
}
QVariant QSystemLocale::query(QueryType type, QVariant in) const
diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h
index 5df33a4e9d..4dc28f2d26 100644
--- a/src/corelib/tools/qpair.h
+++ b/src/corelib/tools/qpair.h
@@ -63,6 +63,22 @@ struct QPair
T2 second;
};
+// mark QPair<T1,T2> as complex/movable/primitive depending on the
+// typeinfos of the constituents:
+template<class T1, class T2>
+class QTypeInfo< QPair<T1, T2> >
+{
+public:
+ enum {
+ isComplex = QTypeInfo<T1>::isComplex || QTypeInfo<T2>::isComplex,
+ isStatic = QTypeInfo<T1>::isStatic || QTypeInfo<T2>::isStatic,
+ isLarge = sizeof(QPair<T1, T2>) > sizeof(void*),
+ isPointer = false,
+ isDummy = false,
+ sizeOf = sizeof(QPair<T1, T2>)
+ };
+};
+
template <class T1, class T2>
Q_INLINE_TEMPLATE bool operator==(const QPair<T1, T2> &p1, const QPair<T1, T2> &p2)
{ return p1.first == p2.first && p1.second == p2.second; }
diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h
index 23d2d9eda0..d53cabd315 100644
--- a/src/corelib/tools/qscopedvaluerollback.h
+++ b/src/corelib/tools/qscopedvaluerollback.h
@@ -51,7 +51,7 @@ template <typename T>
class QScopedValueRollback
{
public:
- QScopedValueRollback(T &var) :
+ explicit QScopedValueRollback(T &var) :
varRef(var)
{
oldValue = varRef;
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 45ccfb8aea..083abcbaad 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -2132,7 +2132,8 @@ QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivi
/*!
- Returns true if string \a other is equal to this string; otherwise
+ \relates QString
+ Returns true if string \a s1 is equal to string \a s2; otherwise
returns false.
The comparison is based exclusively on the numeric Unicode values of
@@ -2140,12 +2141,12 @@ QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivi
expect. Consider sorting user-interface strings with
localeAwareCompare().
*/
-bool QString::operator==(const QString &other) const
+bool operator==(const QString &s1, const QString &s2)
{
- if (d->size != other.d->size)
+ if (s1.d->size != s2.d->size)
return false;
- return qMemEquals(d->data(), other.d->data(), d->size);
+ return qMemEquals(s1.d->data(), s2.d->data(), s1.d->size);
}
/*!
@@ -2200,17 +2201,18 @@ bool QString::operator==(const QLatin1String &other) const
*/
/*!
- Returns true if this string is lexically less than string \a
- other; otherwise returns false.
+ \relates QString
+ Returns true if string \a s1 is lexically less than string
+ \a s2; otherwise returns false.
The comparison is based exclusively on the numeric Unicode values
of the characters and is very fast, but is not what a human would
expect. Consider sorting user-interface strings using the
QString::localeAwareCompare() function.
*/
-bool QString::operator<(const QString &other) const
+bool operator<(const QString &s1, const QString &s2)
{
- return ucstrcmp(constData(), length(), other.constData(), other.length()) < 0;
+ return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0;
}
/*!
@@ -2261,10 +2263,11 @@ bool QString::operator<(const QLatin1String &other) const
go through QObject::tr(), for example.
*/
-/*! \fn bool QString::operator<=(const QString &other) const
+/*! \fn bool operator<=(const QString &s1, const QString &s2)
+ \relates QString
- Returns true if this string is lexically less than or equal to
- string \a other; otherwise returns false.
+ Returns true if string \a s1 is lexically less than or equal to
+ string \a s2; otherwise returns false.
The comparison is based exclusively on the numeric Unicode values
of the characters and is very fast, but is not what a human would
@@ -2304,10 +2307,11 @@ bool QString::operator<(const QLatin1String &other) const
go through QObject::tr(), for example.
*/
-/*! \fn bool QString::operator>(const QString &other) const
+/*! \fn bool operator>(const QString &s1, const QString &s2)
+ \relates QString
- Returns true if this string is lexically greater than string \a
- other; otherwise returns false.
+ Returns true if string \a s1 is lexically greater than string \a
+ s2; otherwise returns false.
The comparison is based exclusively on the numeric Unicode values
of the characters and is very fast, but is not what a human would
@@ -2363,10 +2367,11 @@ bool QString::operator>(const QLatin1String &other) const
for example.
*/
-/*! \fn bool QString::operator>=(const QString &other) const
+/*! \fn bool operator>=(const QString &s1, const QString &s2)
+ \relates QString
- Returns true if this string is lexically greater than or equal to
- string \a other; otherwise returns false.
+ Returns true if string \a s1 is lexically greater than or equal to
+ string \a s2; otherwise returns false.
The comparison is based exclusively on the numeric Unicode values
of the characters and is very fast, but is not what a human would
@@ -2406,9 +2411,10 @@ bool QString::operator>(const QLatin1String &other) const
for example.
*/
-/*! \fn bool QString::operator!=(const QString &other) const
+/*! \fn bool operator!=(const QString &s1, const QString &s2)
+ \relates QString
- Returns true if this string is not equal to string \a other;
+ Returns true if string \a s1 is not equal to string \a s2;
otherwise returns false.
The comparison is based exclusively on the numeric Unicode values
@@ -4727,7 +4733,7 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
} // else fall through
# endif
// declared in <string.h>
- int delta = strcoll(toLocal8Bit_helper(data1, length1), toLocal8Bit_helper(data2, length2));
+ int delta = strcoll(toLocal8Bit_helper(data1, length1).constData(), toLocal8Bit_helper(data2, length2).constData());
if (delta == 0)
delta = ucstrcmp(data1, length1, data2, length2);
return delta;
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index b1ade85a30..6fc86fc04b 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -417,6 +417,10 @@ public:
{
return fromLocal8Bit_helper(str, (str && size == -1) ? int(strlen(str)) : size);
}
+ static inline QString fromAscii(const QByteArray &str) { return fromAscii(str.data(), str.size()); }
+ static inline QString fromLatin1(const QByteArray &str) { return fromLatin1(str.data(), str.size()); }
+ static inline QString fromUtf8(const QByteArray &str) { return fromUtf8(str.data(), str.size()); }
+ static inline QString fromLocal8Bit(const QByteArray &str) { return fromLocal8Bit(str.data(), str.size()); }
static QString fromUtf16(const ushort *, int size = -1);
static QString fromUcs4(const uint *, int size = -1);
static QString fromRawData(const QChar *, int size);
@@ -482,12 +486,12 @@ public:
static QString number(qulonglong, int base=10);
static QString number(double, char f='g', int prec=6);
- bool operator==(const QString &s) const;
- bool operator<(const QString &s) const;
- inline bool operator>(const QString &s) const { return s < *this; }
- inline bool operator!=(const QString &s) const { return !operator==(s); }
- inline bool operator<=(const QString &s) const { return !operator>(s); }
- inline bool operator>=(const QString &s) const { return !operator<(s); }
+ friend Q_CORE_EXPORT bool operator==(const QString &s1, const QString &s2);
+ friend Q_CORE_EXPORT bool operator<(const QString &s1, const QString &s2);
+ friend inline bool operator>(const QString &s1, const QString &s2) { return s2 < s1; }
+ friend inline bool operator!=(const QString &s1, const QString &s2) { return !(s1 == s2); }
+ friend inline bool operator<=(const QString &s1, const QString &s2) { return !(s1 > s2); }
+ friend inline bool operator>=(const QString &s1, const QString &s2) { return !(s1 < s2); }
bool operator==(const QLatin1String &s) const;
bool operator<(const QLatin1String &s) const;
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 4c963185ad..e34425be7e 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -45,12 +45,6 @@
#include <QtCore/qstring.h>
#include <QtCore/qbytearray.h>
-#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL)
-# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
-# include <QtCore/qmap.h>
-# endif
-#endif
-
#include <string.h>
QT_BEGIN_HEADER
@@ -173,6 +167,16 @@ template <> struct QConcatenable<QChar> : private QAbstractConcatenable
{ *out++ = c; }
};
+template <> struct QConcatenable<QChar::SpecialCharacter> : private QAbstractConcatenable
+{
+ typedef QChar::SpecialCharacter type;
+ typedef QString ConvertTo;
+ enum { ExactSize = true };
+ static int size(const QChar::SpecialCharacter) { return 1; }
+ static inline void appendTo(const QChar::SpecialCharacter c, QChar *&out)
+ { *out++ = c; }
+};
+
template <> struct QConcatenable<QCharRef> : private QAbstractConcatenable
{
typedef QCharRef type;
diff --git a/src/corelib/tools/qstringmatcher.h b/src/corelib/tools/qstringmatcher.h
index a9b2a7c371..3f614f732c 100644
--- a/src/corelib/tools/qstringmatcher.h
+++ b/src/corelib/tools/qstringmatcher.h
@@ -55,7 +55,7 @@ class Q_CORE_EXPORT QStringMatcher
{
public:
QStringMatcher();
- QStringMatcher(const QString &pattern,
+ explicit QStringMatcher(const QString &pattern,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
QStringMatcher(const QChar *uc, int len,
Qt::CaseSensitivity cs = Qt::CaseSensitive);