summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstringbuilder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/tools/qstringbuilder.h')
-rw-r--r--src/corelib/tools/qstringbuilder.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index 5c6d990314..e9ca2245ba 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -187,6 +187,18 @@ template <> struct QConcatenable<char> : private QAbstractConcatenable
{ *out++ = c; }
};
+#if defined(Q_COMPILER_UNICODE_STRINGS)
+template <> struct QConcatenable<char16_t> : private QAbstractConcatenable
+{
+ typedef char16_t type;
+ typedef QString ConvertTo;
+ enum { ExactSize = true };
+ static Q_DECL_CONSTEXPR int size(char16_t) { return 1; }
+ static inline void appendTo(char16_t c, QChar *&out)
+ { *out++ = c; }
+};
+#endif
+
template <> struct QConcatenable<QLatin1Char>
{
typedef QLatin1Char type;
@@ -325,6 +337,46 @@ template <> struct QConcatenable<char *> : QConcatenable<const char*>
typedef char *type;
};
+#if defined(Q_COMPILER_UNICODE_STRINGS)
+template <int N> struct QConcatenable<const char16_t[N]> : private QAbstractConcatenable
+{
+ using type = const char16_t[N];
+ using ConvertTo = QString;
+ enum { ExactSize = true };
+ static int size(const char16_t[N]) { return N - 1; }
+ static void appendTo(const char16_t a[N], QChar *&out)
+ {
+ memcpy(out, a, (N - 1) * sizeof(char16_t));
+ out += N - 1;
+ }
+};
+
+template <int N> struct QConcatenable<char16_t[N]> : QConcatenable<const char16_t[N]>
+{
+ using type = char16_t[N];
+};
+
+template <> struct QConcatenable<const char16_t *> : private QAbstractConcatenable
+{
+ using type = const char16_t *;
+ using ConvertTo = QString;
+ enum { ExactSize = true };
+ static int size(const char16_t *a) { return QStringView(a).length(); };
+ static inline void QT_ASCII_CAST_WARN appendTo(const char16_t *a, QChar *&out)
+ {
+ if (!a)
+ return;
+ while (*a)
+ *out++ = *a++;
+ }
+};
+
+template <> struct QConcatenable<char16_t *> : QConcatenable<const char16_t*>
+{
+ typedef char16_t *type;
+};
+#endif // UNICODE_STRINGS
+
template <> struct QConcatenable<QByteArray> : private QAbstractConcatenable
{
typedef QByteArray type;