summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago@kde.org>2011-07-21 16:33:40 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-21 22:36:39 +0200
commita6d87b51141e362f39e323bf329491d27565b137 (patch)
tree500fdffca67f048c220ac79c32672e831f17a38d /src/corelib
parent26a996b2ebc2ff80a087bd21c558601101a7a015 (diff)
Add unit tests to QStringLiteral and QByteArrayLiteral with operator %
This requires a fix for QByteArrayLiteral to work too. Change-Id: I3c2a50ad431d5b0c014a341e675fa54e7b206e70 Merge-request: 27 Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com> Reviewed-on: http://codereview.qt.nokia.com/1967 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qstringbuilder.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 6d998b62aa..63c487ef56 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -364,6 +364,27 @@ template <> struct QConcatenable<QByteArray> : private QAbstractConcatenable
}
};
+template <int N> struct QConcatenable<QConstByteArrayDataPtr<N> > : private QAbstractConcatenable
+{
+ typedef QConstByteArrayDataPtr<N> type;
+ typedef QByteArray ConvertTo;
+ enum { ExactSize = false };
+ static int size(const type &) { return N; }
+#ifndef QT_NO_CAST_FROM_ASCII
+ static inline QT_ASCII_CAST_WARN void appendTo(const type &a, QChar *&out)
+ {
+ // adding 1 because convertFromAscii expects the size including the null-termination
+ QAbstractConcatenable::convertFromAscii(a.ptr->data, N + 1, out);
+ }
+#endif
+ static inline void appendTo(const type &ba, char *&out)
+ {
+ const char *a = ba.ptr->data;
+ while (*a)
+ *out++ = *a++;
+ }
+};
+
namespace QtStringBuilder {
template <typename A, typename B> struct ConvertToTypeHelper
{ typedef A ConvertTo; };