comparison src/libqxt/qxtglobal.h @ 1:7a2637c3eb83

Add csv parser from libqxt
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 23 Mar 2015 16:33:26 +0100
parents
children
comparison
equal deleted inserted replaced
0:147b08bc7d64 1:7a2637c3eb83
1
2 /****************************************************************************
3 ** Copyright (c) 2006 - 2011, the LibQxt project.
4 ** See the Qxt AUTHORS file for a list of authors and copyright holders.
5 ** All rights reserved.
6 **
7 ** Redistribution and use in source and binary forms, with or without
8 ** modification, are permitted provided that the following conditions are met:
9 ** * Redistributions of source code must retain the above copyright
10 ** notice, this list of conditions and the following disclaimer.
11 ** * Redistributions in binary form must reproduce the above copyright
12 ** notice, this list of conditions and the following disclaimer in the
13 ** documentation and/or other materials provided with the distribution.
14 ** * Neither the name of the LibQxt project nor the
15 ** names of its contributors may be used to endorse or promote products
16 ** derived from this software without specific prior written permission.
17 **
18 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 ** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
22 ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 **
29 ** <http://libqxt.org> <foundation@libqxt.org>
30 *****************************************************************************/
31
32 #ifndef QXTGLOBAL_H
33 #define QXTGLOBAL_H
34
35 #include <QtGlobal>
36
37 #define QXT_VERSION 0x000700
38 #define QXT_VERSION_STR "0.7.0"
39
40 //--------------------------global macros------------------------------
41
42 #ifndef QXT_NO_MACROS
43
44 #ifndef _countof
45 #define _countof(x) (sizeof(x)/sizeof(*x))
46 #endif
47
48 #endif // QXT_NO_MACROS
49
50 //--------------------------export macros------------------------------
51
52 #define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE
53
54 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
55 # if defined(BUILD_QXT_CORE)
56 # define QXT_CORE_EXPORT Q_DECL_EXPORT
57 # else
58 # define QXT_CORE_EXPORT Q_DECL_IMPORT
59 # endif
60 #else
61 # define QXT_CORE_EXPORT
62 #endif // BUILD_QXT_CORE
63
64 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
65 # if defined(BUILD_QXT_GUI)
66 # define QXT_GUI_EXPORT Q_DECL_EXPORT
67 # else
68 # define QXT_GUI_EXPORT Q_DECL_IMPORT
69 # endif
70 #else
71 # define QXT_GUI_EXPORT
72 #endif // BUILD_QXT_GUI
73
74 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
75 # if defined(BUILD_QXT_NETWORK)
76 # define QXT_NETWORK_EXPORT Q_DECL_EXPORT
77 # else
78 # define QXT_NETWORK_EXPORT Q_DECL_IMPORT
79 # endif
80 #else
81 # define QXT_NETWORK_EXPORT
82 #endif // BUILD_QXT_NETWORK
83
84 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
85 # if defined(BUILD_QXT_SQL)
86 # define QXT_SQL_EXPORT Q_DECL_EXPORT
87 # else
88 # define QXT_SQL_EXPORT Q_DECL_IMPORT
89 # endif
90 #else
91 # define QXT_SQL_EXPORT
92 #endif // BUILD_QXT_SQL
93
94 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
95 # if defined(BUILD_QXT_WEB)
96 # define QXT_WEB_EXPORT Q_DECL_EXPORT
97 # else
98 # define QXT_WEB_EXPORT Q_DECL_IMPORT
99 # endif
100 #else
101 # define QXT_WEB_EXPORT
102 #endif // BUILD_QXT_WEB
103
104 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
105 # if defined(BUILD_QXT_BERKELEY)
106 # define QXT_BERKELEY_EXPORT Q_DECL_EXPORT
107 # else
108 # define QXT_BERKELEY_EXPORT Q_DECL_IMPORT
109 # endif
110 #else
111 # define QXT_BERKELEY_EXPORT
112 #endif // BUILD_QXT_BERKELEY
113
114 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
115 # if defined(BUILD_QXT_ZEROCONF)
116 # define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT
117 # else
118 # define QXT_ZEROCONF_EXPORT Q_DECL_IMPORT
119 # endif
120 #else
121 # define QXT_ZEROCONF_EXPORT
122 #endif // QXT_ZEROCONF_EXPORT
123
124 #if defined(BUILD_QXT_CORE) || defined(BUILD_QXT_GUI) || defined(BUILD_QXT_SQL) || defined(BUILD_QXT_NETWORK) || defined(BUILD_QXT_WEB) || defined(BUILD_QXT_BERKELEY) || defined(BUILD_QXT_ZEROCONF)
125 # define BUILD_QXT
126 #endif
127
128 QXT_CORE_EXPORT const char* qxtVersion();
129
130 #ifndef QT_BEGIN_NAMESPACE
131 #define QT_BEGIN_NAMESPACE
132 #endif
133
134 #ifndef QT_END_NAMESPACE
135 #define QT_END_NAMESPACE
136 #endif
137
138 #ifndef QT_FORWARD_DECLARE_CLASS
139 #define QT_FORWARD_DECLARE_CLASS(Class) class Class;
140 #endif
141
142 /****************************************************************************
143 ** This file is derived from code bearing the following notice:
144 ** The sole author of this file, Adam Higerd, has explicitly disclaimed all
145 ** copyright interest and protection for the content within. This file has
146 ** been placed in the public domain according to United States copyright
147 ** statute and case law. In jurisdictions where this public domain dedication
148 ** is not legally recognized, anyone who receives a copy of this file is
149 ** permitted to use, modify, duplicate, and redistribute this file, in whole
150 ** or in part, with no restrictions or conditions. In these jurisdictions,
151 ** this file shall be copyright (C) 2006-2008 by Adam Higerd.
152 ****************************************************************************/
153
154 #define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface<PUB, PUB##Private> qxt_d;
155 #define QXT_DECLARE_PUBLIC(PUB) friend class PUB;
156 #define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this);
157 #define QXT_D(PUB) PUB##Private& d = qxt_d()
158 #define QXT_P(PUB) PUB& p = qxt_p()
159
160 template <typename PUB>
161 class QxtPrivate
162 {
163 public:
164 virtual ~QxtPrivate()
165 {}
166 inline void QXT_setPublic(PUB* pub)
167 {
168 qxt_p_ptr = pub;
169 }
170
171 protected:
172 inline PUB& qxt_p()
173 {
174 return *qxt_p_ptr;
175 }
176 inline const PUB& qxt_p() const
177 {
178 return *qxt_p_ptr;
179 }
180 inline PUB* qxt_ptr()
181 {
182 return qxt_p_ptr;
183 }
184 inline const PUB* qxt_ptr() const
185 {
186 return qxt_p_ptr;
187 }
188
189 private:
190 PUB* qxt_p_ptr;
191 };
192
193 template <typename PUB, typename PVT>
194 class QxtPrivateInterface
195 {
196 friend class QxtPrivate<PUB>;
197 public:
198 QxtPrivateInterface()
199 {
200 pvt = new PVT;
201 }
202 ~QxtPrivateInterface()
203 {
204 delete pvt;
205 }
206
207 inline void setPublic(PUB* pub)
208 {
209 pvt->QXT_setPublic(pub);
210 }
211 inline PVT& operator()()
212 {
213 return *static_cast<PVT*>(pvt);
214 }
215 inline const PVT& operator()() const
216 {
217 return *static_cast<PVT*>(pvt);
218 }
219 inline PVT * operator->()
220 {
221 return static_cast<PVT*>(pvt);
222 }
223 inline const PVT * operator->() const
224 {
225 return static_cast<PVT*>(pvt);
226 }
227 private:
228 QxtPrivateInterface(const QxtPrivateInterface&) { }
229 QxtPrivateInterface& operator=(const QxtPrivateInterface&) { }
230 QxtPrivate<PUB>* pvt;
231 };
232
233 #endif // QXT_GLOBAL
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)