blob: 0e9d99a4afa21408b9bf51c29dda2e06c8c25003 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#ifndef PLACE_MACRO_H
#define PLACE_MACRO_H
#define Q_DECLARE_D_FUNC(Class) \
inline Class##Private* d_func(); \
inline const Class##Private* d_func() const;\
friend class Class##Private;
#define Q_DECLARE_COPY_CTOR(Class, BaseClass) \
Class(const BaseClass &other);
#define Q_IMPLEMENT_D_FUNC(Class) \
Class##Private* Class::d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \
const Class##Private* Class::d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.constData()); }
#define Q_IMPLEMENT_COPY_CTOR(Class, BaseClass) \
Class::Class(const BaseClass& other) : BaseClass() { Class##Private::copyIfPossible(d_ptr, other); }
#define Q_DEFINE_PRIVATE_HELPER(Class, BaseClass, ClassType, basename) \
BaseClass##Private* clone() const { return new Class##Private(*this); } \
virtual BaseClass::Type type() const {return ClassType;} \
static void copyIfPossible(QSharedDataPointer<BaseClass##Private>& d_ptr, const BaseClass &other) \
{ \
if (other.basename##Type() == ClassType) \
d_ptr = extract_d(other); \
else \
d_ptr = new Class##Private; \
}
#endif
|