--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/qthighway/xqservice/src/xqserviceipcmarshal.h Tue Aug 31 16:02:37 2010 +0300
@@ -0,0 +1,138 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License as published by
+* the Free Software Foundation, version 2.1 of the License.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public License
+* along with this program. If not,
+* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
+*
+* Description:
+*
+*/
+
+#ifndef XQSERVICEIPCMARSHAL_H
+#define XQSERVICEIPCMARSHAL_H
+
+#include <xqserviceglobal.h>
+
+#include <qvariant.h>
+#include <qmetatype.h>
+#include <qdatastream.h>
+#include <qatomic.h>
+#include <quuid.h>
+
+/// @cond
+/*!
+ Excluded from documentation.
+*/
+
+template <typename T>
+struct QMetaTypeRegister
+{
+ static int registerType() { return 1; }
+};
+
+/// @endcond
+
+#ifdef Q_CC_GNU
+# define _QATOMIC_ONCE() do {} while(0)
+#else
+# define _QATOMIC_ONCE() \
+ static QAtomicInt once; \
+ if ( once.fetchAndStoreOrdered(1) ) \
+ return 1
+#endif
+
+#define Q_DECLARE_USER_METATYPE_NO_OPERATORS(TYPE) \
+ Q_DECLARE_METATYPE(TYPE) \
+ template<> \
+ struct QMetaTypeRegister< TYPE > \
+ { \
+ static int registerType() \
+ { \
+ _QATOMIC_ONCE(); \
+ int id = qMetaTypeId( reinterpret_cast<TYPE *>(0) ); \
+ if ( id >= static_cast<int>(QMetaType::User) ) \
+ qRegisterMetaTypeStreamOperators< TYPE >( #TYPE ); \
+ return 1; \
+ } \
+ static int __init_variable__; \
+ };
+
+#define Q_DECLARE_USER_METATYPE(TYPE) \
+ Q_DECLARE_USER_METATYPE_NO_OPERATORS(TYPE) \
+ QDataStream &operator<<(QDataStream &stream, const TYPE &var); \
+ QDataStream &operator>>( QDataStream &stream, TYPE &var );
+
+#define Q_DECLARE_USER_METATYPE_TYPEDEF(TAG,TYPE) \
+ template <typename T> \
+ struct QMetaTypeRegister##TAG \
+ { \
+ static int registerType() { return 1; } \
+ }; \
+ template<> struct QMetaTypeRegister##TAG< TYPE > { \
+ static int registerType() { \
+ _QATOMIC_ONCE(); \
+ qRegisterMetaType< TYPE >( #TYPE ); \
+ qRegisterMetaTypeStreamOperators< TYPE >( #TYPE ); \
+ return 1; \
+ } \
+ static int __init_variable__; \
+ };
+
+#define Q_DECLARE_USER_METATYPE_ENUM(TYPE) \
+ Q_DECLARE_USER_METATYPE(TYPE)
+
+#define Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(TYPE) \
+ int QMetaTypeRegister< TYPE >::__init_variable__ = \
+ QMetaTypeRegister< TYPE >::registerType();
+
+#define Q_IMPLEMENT_USER_METATYPE(TYPE) \
+ QDataStream &operator<<(QDataStream &stream, const TYPE &var) \
+ { \
+ var.serialize(stream); \
+ return stream; \
+ } \
+ \
+ QDataStream &operator>>( QDataStream &stream, TYPE &var ) \
+ { \
+ var.deserialize(stream); \
+ return stream; \
+ } \
+ Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(TYPE)
+
+#define Q_IMPLEMENT_USER_METATYPE_TYPEDEF(TAG,TYPE) \
+ int QMetaTypeRegister##TAG< TYPE >::__init_variable__ = \
+ QMetaTypeRegister##TAG< TYPE >::registerType();
+
+#define Q_IMPLEMENT_USER_METATYPE_ENUM(TYPE) \
+ QDataStream& operator<<( QDataStream& stream, const TYPE &v ) \
+ { \
+ stream << static_cast<qint32>(v); \
+ return stream; \
+ } \
+ QDataStream& operator>>( QDataStream& stream, TYPE& v ) \
+ { \
+ qint32 _v; \
+ stream >> _v; \
+ v = static_cast<TYPE>(_v); \
+ return stream; \
+ } \
+ Q_IMPLEMENT_USER_METATYPE_NO_OPERATORS(TYPE)
+
+#define Q_REGISTER_USER_METATYPE(TYPE) \
+ QMetaTypeRegister< TYPE >::registerType()
+
+
+Q_DECLARE_USER_METATYPE_NO_OPERATORS(QUuid)
+
+#endif