23#include <QtCore/QList>
24#include <boost/mpl/if.hpp>
36 typedef boost::mpl::if_c<
37 sizeof(size_t) ==
sizeof(
unsigned long),
39 QIntegerForSizeof<size_t>::Unsigned
66 enum FundamentalType {
90 inline Type() : m_type(0) {}
91 inline Type(Private::GType gtype) : m_type(gtype) {}
92 inline Type(FundamentalType ftype) : m_type(ftype) {}
93 inline Type(
const Type & other) : m_type(other.m_type) {}
96 inline bool operator==(
Type other)
const;
97 inline operator Private::GType()
const {
return m_type; }
99 static Type fromInstance(
void *nativeInstance);
100 static Type fromName(
const char *name);
102 QString name()
const;
103 Quark nameQuark()
const;
105 bool isValid()
const;
106 bool isAbstract()
const;
107 bool isDerived()
const;
108 bool isFundamental()
const;
109 bool isValueType()
const;
110 bool hasValueTable()
const;
111 bool isClassed()
const;
112 bool isInstantiatable()
const;
113 bool isDerivable()
const;
114 bool isDeepDerivable()
const;
115 bool isInterface()
const;
117 Type fundamental()
const;
121 bool isA(
Type is_a_type)
const;
123 template <
typename T>
124 inline bool isA()
const;
126 QList<Type> children()
const;
127 QList<Type> interfaces()
const;
128 QList<Type> interfacePrerequisites()
const;
130 void *quarkData(
const Quark & qname)
const;
131 void setQuarkData(
const Quark & qname,
void *data);
134 Private::GType m_type;
137inline Type & Type::operator=(
Type other)
139 m_type = other.m_type;
143inline bool Type::operator==(Type other)
const
145 return m_type == other.m_type;
149inline Type GetType();
152inline bool Type::isA()
const
154 return isA(GetType<T>());
169#if defined(QGLIB_HAVE_CXX0X_STATIC_ASSERT)
171 template <
class X>
struct FailStruct {
static const bool value =
false; };
172 static_assert(FailStruct<T>::value,
"Type T has not been registered with the QGlib type system");
182 return GetTypeImpl<T>();
190#define QGLIB_REGISTER_TYPE_WITH_EXPORT_MACRO(T, EXPORT_MACRO) \
193 struct EXPORT_MACRO GetTypeImpl<T> { operator Type(); }; \
203#define QGLIB_REGISTER_TYPE(T) \
204 QGLIB_REGISTER_TYPE_WITH_EXPORT_MACRO(T, QTGLIB_EXPORT)
210#define QGLIB_REGISTER_NATIVE_TYPE(T, GTYPE) \
213 struct GetTypeImpl<T> { \
214 inline operator Type() { return (GTYPE); }; \
218QGLIB_REGISTER_NATIVE_TYPE(
bool, Type::Boolean)
219QGLIB_REGISTER_NATIVE_TYPE(
char, Type::Char)
220QGLIB_REGISTER_NATIVE_TYPE(
unsigned char, Type::Uchar)
221QGLIB_REGISTER_NATIVE_TYPE(
int, Type::Int)
222QGLIB_REGISTER_NATIVE_TYPE(
unsigned int, Type::Uint)
223QGLIB_REGISTER_NATIVE_TYPE(
long, Type::Long)
224QGLIB_REGISTER_NATIVE_TYPE(
unsigned long, Type::Ulong)
225QGLIB_REGISTER_NATIVE_TYPE(qint64, Type::Int64)
226QGLIB_REGISTER_NATIVE_TYPE(quint64, Type::Uint64)
227QGLIB_REGISTER_NATIVE_TYPE(
float, Type::Float)
228QGLIB_REGISTER_NATIVE_TYPE(
double, Type::Double)
229QGLIB_REGISTER_NATIVE_TYPE(
void*, Type::Pointer)
230QGLIB_REGISTER_NATIVE_TYPE(
const char*, Type::String)
231QGLIB_REGISTER_NATIVE_TYPE(QByteArray, Type::String)
232QGLIB_REGISTER_NATIVE_TYPE(QString, Type::String)
237 struct GetTypeImpl<const char[N]> {
238 inline operator Type() {
return Type::String; };
244 struct GetTypeImpl<char[N]> {
245 inline operator Type() {
return Type::String; };
249#undef QGLIB_REGISTER_NATIVE_TYPE
Base class for interface wrappers.
Wrapper class for GObject.
Wrapper class for GQuark.
Wrappers for Glib and GObject classes.