summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorhjk <qtc-committer@nokia.com>2009-06-05 09:39:54 (GMT)
committerhjk <qtc-committer@nokia.com>2009-06-05 11:15:39 (GMT)
commite6b3c48159f479d82740988a6104b9f5aee16a59 (patch)
tree344cb7b264cec741bf67064ee38cc9479746ed74 /src
parent84f381b98a9a100007a9d40a26e30f0bf705037b (diff)
downloadQt-e6b3c48159f479d82740988a6104b9f5aee16a59.zip
Qt-e6b3c48159f479d82740988a6104b9f5aee16a59.tar.gz
Qt-e6b3c48159f479d82740988a6104b9f5aee16a59.tar.bz2
Make QStringBuilder work out-of-the-box if QT_NO_CAST_FROM_ASCII is defined
So far, only operator% was working for concatenation in those circumnstances. Now, defining QT_USE_FAST_OPERATOR_PLUS and QT_USE_FAST_CONCATENATION is enough, so user code will work without any source changes. Reviewed-by: joao
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qstringbuilder.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 1e67b7d..7b16197 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -169,6 +169,30 @@ template <> struct QConcatenable<QStringRef>
}
};
+#ifndef QT_NO_CAST_FROM_ASCII
+template <int N> struct QConcatenable<char[N]>
+{
+ typedef char type[N];
+ static int size(const char *) { return N - 1; }
+ static inline void appendTo(const char *a, QChar *&out)
+ {
+ for (int i = 0; i < N - 1; ++i)
+ *out++ = QLatin1Char(a[i]);
+ }
+};
+
+template <> struct QConcatenable<const char *>
+{
+ typedef char const *type;
+ static int size(const char *a) { return qstrlen(a); }
+ static inline void appendTo(const char *a, QChar *&out)
+ {
+ while (*a)
+ *out++ = QLatin1Char(*a++);
+ }
+};
+#endif
+
template <typename A, typename B>
struct QConcatenable< QStringBuilder<A, B> >
{