From a6d87b51141e362f39e323bf329491d27565b137 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 21 Jul 2011 16:33:40 +0200 Subject: 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 Reviewed-on: http://codereview.qt.nokia.com/1967 Reviewed-by: Qt Sanity Bot --- src/corelib/tools/qstringbuilder.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/corelib/tools/qstringbuilder.h') 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 : private QAbstractConcatenable } }; +template struct QConcatenable > : private QAbstractConcatenable +{ + typedef QConstByteArrayDataPtr 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 struct ConvertToTypeHelper { typedef A ConvertTo; }; -- cgit v1.2.3