From 0678d7c43c1658d2d2ec984be5844054031649a2 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Sat, 11 Feb 2012 07:02:13 +0100 Subject: Add QMetaType::type(QByteArray) function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QMetaType::type(const char *) requires that the string argument is 0-terminated. This new overload makes it possible to query the type of a string with an explicit length. In particular, QByteArrays constructed by QByteArray::fromRawData(), for example from a substring of a normalized method signature (the "int" part of "mySlot(int"), can now be queried without making a copy of the string. Also, Qt5 meta-objects represent type names as QByteArray literals, which can be fed directly to this new QMetaType::type() overload (no need to call strlen). Change-Id: I60d35aa6bdc0f77e0997f98b0e30e12fd3d5e100 Reviewed-by: Jędrzej Nowacki Reviewed-by: Thiago Macieira --- src/corelib/kernel/qmetatype.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/corelib/kernel/qmetatype.h') diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 08b2fb083a..947bf77796 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -472,6 +472,11 @@ public: static int registerTypedef(const char *typeName, int aliasId); static int registerNormalizedTypedef(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, int aliasId); static int type(const char *typeName); +#ifndef Q_QDOC + static int type(const QT_PREPEND_NAMESPACE(QByteArray) &typeName); +#else + static int type(const QByteArray &typeName); +#endif static const char *typeName(int type); static int sizeOf(int type); static TypeFlags typeFlags(int type); -- cgit v1.2.3