summaryrefslogtreecommitdiffstats
path: root/installerbuilder/libinstaller/kdtools/KDToolsCore/kdtoolsglobal.h
blob: 3d687da392c138532285aff9915c3a03b10a7a3e (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/****************************************************************************
** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB.  All rights reserved.
**
** This file is part of the KD Tools library.
**
** Licensees holding valid commercial KD Tools licenses may use this file in
** accordance with the KD Tools Commercial License Agreement provided with
** the Software.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU Lesser General Public License version 2 and version 3 as published by the
** Free Software Foundation and appearing in the file LICENSE.LGPL included.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** Contact info@kdab.com if any conditions of this licensing are not
** clear to you.
**
**********************************************************************/

#ifndef __KDTOOLS_KDTOOLSGLOBAL_H__
#define __KDTOOLS_KDTOOLSGLOBAL_H__

#include <QtCore/QtGlobal>

#define KDAB_DISABLE_COPY( x ) private: x( const x & ); x & operator=( const x & )

#ifdef KDTOOLS_SHARED
#  ifdef BUILD_SHARED_KDTOOLSCORE
#    define KDTOOLSCORE_EXPORT Q_DECL_EXPORT
#  else
#    define KDTOOLSCORE_EXPORT Q_DECL_IMPORT
#  endif
#  ifdef BUILD_SHARED_KDTOOLSGUI
#    define KDTOOLSGUI_EXPORT Q_DECL_EXPORT
#  else
#    define KDTOOLSGUI_EXPORT Q_DECL_IMPORT
#  endif
#  ifdef BUILD_SHARED_KDTOOLSXML
#    define KDTOOLSXML_EXPORT Q_DECL_EXPORT
#  else
#    define KDTOOLSXML_EXPORT Q_DECL_IMPORT
#  endif
#  ifdef BUILD_SHARED_KDUPDATER
#    define KDTOOLS_UPDATER_EXPORT    Q_DECL_EXPORT
#  else
#    define KDTOOLS_UPDATER_EXPORT    Q_DECL_IMPORT
#  endif
#else // KDTOOLS_SHARED
#  define KDTOOLSCORE_EXPORT
#  define KDTOOLSGUI_EXPORT
#  define KDTOOLSXML_EXPORT
#  define KDTOOLS_UPDATER_EXPORT
#endif // KDTOOLS_SHARED

#define MAKEINCLUDES_EXPORT

#define DOXYGEN_PROPERTY( x )
#ifdef DOXYGEN_RUN
# define KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( func ) operator unspecified_bool_type() const { return func; }
# define KDAB_USING_SAFE_BOOL_OPERATOR( Class ) operator unspecified_bool_type() const;
#else
# define KDAB_IMPLEMENT_SAFE_BOOL_OPERATOR( func )                      \
    private: struct __safe_bool_dummy__ { void nonnull() {} };          \
        typedef void ( __safe_bool_dummy__::*unspecified_bool_type )(); \
    public:                                                             \
        operator unspecified_bool_type() const {                        \
            return ( func ) ? &__safe_bool_dummy__::nonnull : 0 ;       \
        }
#define KDAB_USING_SAFE_BOOL_OPERATOR( Class ) \
    using Class::operator Class::unspecified_bool_type;
#endif

#define KDTOOLS_MAKE_RELATION_OPERATORS( Class, linkage )             \
    linkage bool operator>( const Class & lhs, const Class & rhs ) {  \
        return operator<( rhs, lhs );                                 \
    }                                                                 \
    linkage bool operator!=( const Class & lhs, const Class & rhs ) { \
        return !operator==( lhs, rhs );                               \
    }                                                                 \
    linkage bool operator<=( const Class & lhs, const Class & rhs ) { \
        return !operator>( lhs, rhs );                                \
    }                                                                 \
    linkage bool operator>=( const Class & lhs, const Class & rhs ) { \
        return !operator<( lhs, rhs );                                \
    }

template <typename T>
inline T & __kdtools__dereference_for_methodcall( T & o ) {
    return o;
}

template <typename T>
inline T & __kdtools__dereference_for_methodcall( T * o ) {
    return *o;
}

#define KDAB_SET_OBJECT_NAME( x ) __kdtools__dereference_for_methodcall( x ).setObjectName( QLatin1String( #x ) )

KDTOOLSCORE_EXPORT bool _kdCheckQtVersion_impl( int major, int minor=0, int patchlevel=0 );
static inline bool kdCheckQtVersion( unsigned int major, unsigned int minor=0, unsigned int patchlevel=0 ) {
    return (major<<16|minor<<8|patchlevel) <= static_cast<unsigned int>(QT_VERSION)
	|| _kdCheckQtVersion_impl( major, minor, patchlevel );
}

#define KDTOOLS_DECLARE_PRIVATE_BASE( Class )                        \
protected:                                                           \
    class Private;                                                   \
    Private * d_func() { return _d; }                                \
    const Private * d_func() const { return _d; }                    \
    Class( Private * _d_, bool b ) : _d( _d_ ) { init(b); }          \
private:                                                             \
    void init(bool);                                                 \
private:                                                             \
    Private * _d

#define KDTOOLS_DECLARE_PRIVATE_DERIVED( Class, Base )                  \
protected:                                                              \
    class Private;                                                      \
    Private * d_func() {                                                \
        return reinterpret_cast<Private*>( Base::d_func() );            \
    }                                                                   \
    const Private * d_func() const {                                    \
        return reinterpret_cast<const Private*>( Base::d_func() );      \
    }                                                                   \
    Class( Private * _d_, bool b )                                      \
        : Base( reinterpret_cast<Base::Private*>(_d_), b ) { init(b); } \
private:                                                                \
    void init(bool)


#endif /* __KDTOOLS_KDTOOLSGLOBAL_H__ */