summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/snippets/qstring/stringbuilder.cpp7
-rw-r--r--src/corelib/tools/qbytearray.h13
-rw-r--r--src/corelib/tools/qstring.cpp10
-rw-r--r--src/corelib/tools/qstring.h8
-rw-r--r--src/corelib/tools/qstringbuilder.h4
-rw-r--r--src/qbase.pri2
-rw-r--r--tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp3
-rw-r--r--tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp3
-rw-r--r--tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp3
-rw-r--r--tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp3
10 files changed, 21 insertions, 35 deletions
diff --git a/doc/src/snippets/qstring/stringbuilder.cpp b/doc/src/snippets/qstring/stringbuilder.cpp
index 8ff1dd8..b8acbc1 100644
--- a/doc/src/snippets/qstring/stringbuilder.cpp
+++ b/doc/src/snippets/qstring/stringbuilder.cpp
@@ -49,14 +49,9 @@
//! [0]
//! [3]
- #define QT_USE_FAST_CONCATENATION
+ DEFINES *= QT_USE_QSTRINGBUILDER
//! [3]
-//! [4]
- #define QT_USE_FAST_CONCATENATION
- #define QT_USE_FAST_OPERATOR_PLUS
-//! [4]
-
//! [5]
#include <QStringBuilder>
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 0627b4e..df58d95 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -57,9 +57,10 @@
# ifdef QT_USE_FAST_OPERATOR_PLUS
# undef QT_USE_FAST_OPERATOR_PLUS
# endif
-# ifdef QT_USE_FAST_CONCATENATION
-# undef QT_USE_FAST_CONCATENATION
+# ifdef QT_USE_QSTRINGBUILDER
+# undef QT_USE_QSTRINGBUILDER
# endif
+
#endif
@@ -559,8 +560,7 @@ inline bool operator>=(const QByteArray &a1, const char *a2)
{ return qstrcmp(a1, a2) >= 0; }
inline bool operator>=(const char *a1, const QByteArray &a2)
{ return qstrcmp(a1, a2) >= 0; }
-#ifndef QT_USE_FAST_OPERATOR_PLUS
-# ifndef QT_USE_FAST_CONCATENATION
+#if !defined(QT_USE_QSTRINGBUILDER)
inline const QByteArray operator+(const QByteArray &a1, const QByteArray &a2)
{ return QByteArray(a1) += a2; }
inline const QByteArray operator+(const QByteArray &a1, const char *a2)
@@ -571,8 +571,7 @@ inline const QByteArray operator+(const char *a1, const QByteArray &a2)
{ return QByteArray(a1) += a2; }
inline const QByteArray operator+(char a1, const QByteArray &a2)
{ return QByteArray(&a1, 1) += a2; }
-# endif // QT_USE_FAST_CONCATENATION
-#endif // QT_USE_FAST_OPERATOR_PLUS
+#endif // QT_USE_QSTRINGBUILDER
inline QBool QByteArray::contains(const char *c) const
{ return QBool(indexOf(c) != -1); }
inline QByteArray &QByteArray::replace(char before, const char *c)
@@ -615,7 +614,7 @@ QT_END_NAMESPACE
QT_END_HEADER
-#ifdef QT_USE_FAST_CONCATENATION
+#ifdef QT_USE_QSTRINGBUILDER
#include <QtCore/qstring.h>
#endif
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 5493ba9..3b3f715 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -777,16 +777,12 @@ const QString::Null QString::null = { };
\snippet doc/src/snippets/qstring/stringbuilder.cpp 5
- A more global approach is to include this define:
+ A more global approach which is the most convenient but
+ not entirely source compatible, is to this define in your
+ .pro file:
\snippet doc/src/snippets/qstring/stringbuilder.cpp 3
- and use \c{'%'} instead of \c{'+'} for string concatenation
- everywhere. The third approach, which is the most convenient but
- not entirely source compatible, is to include two defines:
-
- \snippet doc/src/snippets/qstring/stringbuilder.cpp 4
-
and the \c{'+'} will automatically be performed as the
\c{QStringBuilder} \c{'%'} everywhere.
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 6418a8c..7c4367e 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -1016,8 +1016,7 @@ inline int QByteArray::findRev(const QString &s, int from) const
# endif // QT3_SUPPORT
#endif // QT_NO_CAST_TO_ASCII
-#ifndef QT_USE_FAST_OPERATOR_PLUS
-# ifndef QT_USE_FAST_CONCATENATION
+#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
inline const QString operator+(const QString &s1, const QString &s2)
{ QString t(s1); t += s2; return t; }
inline const QString operator+(const QString &s1, QChar s2)
@@ -1038,8 +1037,7 @@ inline QT_ASCII_CAST_WARN const QString operator+(const QByteArray &ba, const QS
inline QT_ASCII_CAST_WARN const QString operator+(const QString &s, const QByteArray &ba)
{ QString t(s); t += QString::fromAscii(ba.constData(), qstrnlen(ba.constData(), ba.size())); return t; }
# endif // QT_NO_CAST_FROM_ASCII
-# endif // QT_USE_FAST_CONCATENATION
-#endif // QT_USE_FAST_OPERATOR_PLUS
+#endif // QT_USE_QSTRINGBUILDER
#ifndef QT_NO_STL
inline std::string QString::toStdString() const
@@ -1288,7 +1286,7 @@ QT_END_NAMESPACE
QT_END_HEADER
-#ifdef QT_USE_FAST_CONCATENATION
+#if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER)
#include <QtCore/qstringbuilder.h>
#endif
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 2d3475f..029aa0b 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -410,7 +410,9 @@ operator%(const A &a, const B &b)
return QStringBuilder<typename QConcatenable<A>::type, typename QConcatenable<B>::type>(a, b);
}
-#ifdef QT_USE_FAST_OPERATOR_PLUS
+// QT_USE_FAST_OPERATOR_PLUS was introduced in 4.7, QT_USE_QSTRINGBUILDER is to be used from 4.8 onwards
+// QT_USE_FAST_OPERATOR_PLUS does not remove the normal operator+ for QByteArray
+#if defined(QT_USE_FAST_OPERATOR_PLUS) || defined(QT_USE_QSTRINGBUILDER)
template <typename A, typename B>
QStringBuilder<typename QConcatenable<A>::type, typename QConcatenable<B>::type>
operator+(const A &a, const B &b)
diff --git a/src/qbase.pri b/src/qbase.pri
index ce69757..c4d081f 100644
--- a/src/qbase.pri
+++ b/src/qbase.pri
@@ -163,7 +163,7 @@ contains(QT_PRODUCT, OpenSource.*):DEFINES *= QT_OPENSOURCE
DEFINES *= QT_NO_CAST_TO_ASCII QT_ASCII_CAST_WARNINGS
contains(QT_CONFIG, qt3support):DEFINES *= QT3_SUPPORT
DEFINES *= QT_MOC_COMPAT #we don't need warnings from calling moc code in our generated code
-DEFINES *= QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION
+DEFINES *= QT_USE_QSTRINGBUILDER
TARGET = $$qtLibraryTarget($$TARGET$$QT_LIBINFIX) #do this towards the end
diff --git a/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp b/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp
index 36b6b80..463f200 100644
--- a/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp
+++ b/tests/auto/qstringbuilder1/tst_qstringbuilder1.cpp
@@ -44,8 +44,7 @@
// this is the "no harm done" version. Only operator% is active,
// with NO_CAST * defined
#define P %
-#undef QT_USE_FAST_OPERATOR_PLUS
-#undef QT_USE_FAST_CONCATENATION
+#undef QT_USE_QSTRINGBUILDER
#define QT_NO_CAST_FROM_ASCII
#define QT_NO_CAST_TO_ASCII
diff --git a/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp b/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp
index 88b1f73..bcf88cb 100644
--- a/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp
+++ b/tests/auto/qstringbuilder2/tst_qstringbuilder2.cpp
@@ -45,8 +45,7 @@
// based version
// with NO_CAST * defined
#define P +
-#define QT_USE_FAST_OPERATOR_PLUS
-#define QT_USE_FAST_CONCATENATION
+#define QT_USE_QSTRINGBUILDER
#define QT_NO_CAST_FROM_ASCII
#define QT_NO_CAST_TO_ASCII
diff --git a/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp b/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp
index afc3333..338fbf4 100644
--- a/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp
+++ b/tests/auto/qstringbuilder3/tst_qstringbuilder3.cpp
@@ -44,8 +44,7 @@
// this is the "no harm done" version. Only operator% is active,
// with NO_CAST * _not_ defined
#define P %
-#undef QT_USE_FAST_OPERATOR_PLUS
-#undef QT_USE_FAST_CONCATENATION
+#undef QT_USE_QSTRINGBUILDER
#undef QT_NO_CAST_FROM_ASCII
#undef QT_NO_CAST_TO_ASCII
diff --git a/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp b/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp
index ae4100a..d046e59 100644
--- a/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp
+++ b/tests/auto/qstringbuilder4/tst_qstringbuilder4.cpp
@@ -45,8 +45,7 @@
// based version
// with NO_CAST * _not_ defined
#define P +
-#define QT_USE_FAST_OPERATOR_PLUS
-#define QT_USE_FAST_CONCATENATION
+#define QT_USE_QSTRINGBUILDER
#undef QT_NO_CAST_FROM_ASCII
#undef QT_NO_CAST_TO_ASCII