Introduce QMetaType::UnknownType.
[profile/ivi/qtbase.git] / src / corelib / kernel / qcore_mac_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QCORE_MAC_P_H
43 #define QCORE_MAC_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists for the convenience
50 // of other Qt classes.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55
56 #ifndef __IMAGECAPTURE__
57 #  define __IMAGECAPTURE__
58 #endif
59
60 #undef OLD_DEBUG
61 #ifdef DEBUG
62 # define OLD_DEBUG DEBUG
63 # undef DEBUG
64 #endif
65 #define DEBUG 0
66 #ifdef qDebug
67 #  define old_qDebug qDebug
68 #  undef qDebug
69 #endif
70
71 #if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED)
72 #include <ApplicationServices/ApplicationServices.h>
73 #else
74 #include <CoreFoundation/CoreFoundation.h>
75 #endif
76
77 #ifndef QT_NO_CORESERVICES
78 #include <CoreServices/CoreServices.h>
79 #endif
80
81 #ifdef __OBJC__
82 #include <Foundation/Foundation.h>
83 #endif
84
85 #undef DEBUG
86 #ifdef OLD_DEBUG
87 #  define DEBUG OLD_DEBUG
88 #  undef OLD_DEBUG
89 #endif
90
91 #ifdef old_qDebug
92 #  undef qDebug
93 #  define qDebug QT_NO_QDEBUG_MACRO
94 #  undef old_qDebug
95 #endif
96
97 #include "qstring.h"
98
99 QT_BEGIN_NAMESPACE
100
101 /*
102     Helper class that automates refernce counting for CFtypes.
103     After constructing the QCFType object, it can be copied like a
104     value-based type.
105
106     Note that you must own the object you are wrapping.
107     This is typically the case if you get the object from a Core
108     Foundation function with the word "Create" or "Copy" in it. If
109     you got the object from a "Get" function, either retain it or use
110     constructFromGet(). One exception to this rule is the
111     HIThemeGet*Shape functions, which in reality are "Copy" functions.
112 */
113 template <typename T>
114 class Q_CORE_EXPORT QCFType
115 {
116 public:
117     inline QCFType(const T &t = 0) : type(t) {}
118     inline QCFType(const QCFType &helper) : type(helper.type) { if (type) CFRetain(type); }
119     inline ~QCFType() { if (type) CFRelease(type); }
120     inline operator T() { return type; }
121     inline QCFType operator =(const QCFType &helper)
122     {
123         if (helper.type)
124             CFRetain(helper.type);
125         CFTypeRef type2 = type;
126         type = helper.type;
127         if (type2)
128             CFRelease(type2);
129         return *this;
130     }
131     inline T *operator&() { return &type; }
132     static QCFType constructFromGet(const T &t)
133     {
134         CFRetain(t);
135         return QCFType<T>(t);
136     }
137 protected:
138     T type;
139 };
140
141 class Q_CORE_EXPORT QCFString : public QCFType<CFStringRef>
142 {
143 public:
144     inline QCFString(const QString &str) : QCFType<CFStringRef>(0), string(str) {}
145     inline QCFString(const CFStringRef cfstr = 0) : QCFType<CFStringRef>(cfstr) {}
146     inline QCFString(const QCFType<CFStringRef> &other) : QCFType<CFStringRef>(other) {}
147     operator QString() const;
148     operator CFStringRef() const;
149     static QString toQString(CFStringRef cfstr);
150     static CFStringRef toCFStringRef(const QString &str);
151 #ifdef __OBJC__
152     static QString toQString(const NSString *nsstr);
153     static  NSString *toNSString(const QString &string);
154 #endif
155
156 private:
157     QString string;
158 };
159
160 QT_END_NAMESPACE
161
162 #if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5)
163 #ifndef __LP64__
164         typedef float CGFloat;
165         typedef int NSInteger;
166         typedef unsigned int NSUInteger;
167         #define SRefCon SInt32
168         #define URefCon UInt32
169 #endif
170 #endif
171
172 #endif // QCORE_MAC_P_H