summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-01-13 11:31:12 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-01-13 11:33:37 (GMT)
commit737161bbec97e738d0e91cc86bd4e4033be07b97 (patch)
treefe20e691e7176c13e82c6ad946252be4f1e8419d
parentb38da980696e69b61d2f5411ad2f2c36453ed089 (diff)
downloadQt-737161bbec97e738d0e91cc86bd4e4033be07b97.zip
Qt-737161bbec97e738d0e91cc86bd4e4033be07b97.tar.gz
Qt-737161bbec97e738d0e91cc86bd4e4033be07b97.tar.bz2
Add an overload of qRegisterMetaTypeStreamOperators without the type name
Reviewed-by: Bradley T. Hughes
-rw-r--r--src/corelib/kernel/qmetatype.cpp7
-rw-r--r--src/corelib/kernel/qmetatype.h20
2 files changed, 27 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index b1ce608..ac15e49 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -361,7 +361,14 @@ void QMetaType::registerStreamOperators(const char *typeName, SaveOperator saveO
int idx = type(typeName);
if (!idx)
return;
+ registerStreamOperators(idx, saveOp, loadOp);
+}
+/*! \internal
+*/
+void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp,
+ LoadOperator loadOp)
+{
QVector<QCustomTypeInfo> *ct = customTypes();
if (!ct)
return;
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 0277200..115411c 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -108,6 +108,8 @@ public:
typedef void (*LoadOperator)(QDataStream &, void *);
static void registerStreamOperators(const char *typeName, SaveOperator saveOp,
LoadOperator loadOp);
+ static void registerStreamOperators(int type, SaveOperator saveOp,
+ LoadOperator loadOp);
#endif
static int registerType(const char *typeName, Destructor destructor,
Constructor constructor);
@@ -224,6 +226,24 @@ inline int qRegisterMetaType(
#endif
}
+#ifndef QT_NO_DATASTREAM
+template <typename T>
+inline int qRegisterMetaTypeStreamOperators()
+{
+ typedef void(*SavePtr)(QDataStream &, const T *);
+ typedef void(*LoadPtr)(QDataStream &, T *);
+ SavePtr sptr = qMetaTypeSaveHelper<T>;
+ LoadPtr lptr = qMetaTypeLoadHelper<T>;
+
+ register int id = qMetaTypeId<T>();
+ QMetaType::registerStreamOperators(id,
+ reinterpret_cast<QMetaType::SaveOperator>(sptr),
+ reinterpret_cast<QMetaType::LoadOperator>(lptr));
+
+ return id;
+}
+#endif
+
#define Q_DECLARE_METATYPE(TYPE) \
QT_BEGIN_NAMESPACE \
template <> \