andre@1: andre@1: /**************************************************************************** andre@1: ** Copyright (c) 2006 - 2011, the LibQxt project. andre@1: ** See the Qxt AUTHORS file for a list of authors and copyright holders. andre@1: ** All rights reserved. andre@1: ** andre@1: ** Redistribution and use in source and binary forms, with or without andre@1: ** modification, are permitted provided that the following conditions are met: andre@1: ** * Redistributions of source code must retain the above copyright andre@1: ** notice, this list of conditions and the following disclaimer. andre@1: ** * Redistributions in binary form must reproduce the above copyright andre@1: ** notice, this list of conditions and the following disclaimer in the andre@1: ** documentation and/or other materials provided with the distribution. andre@1: ** * Neither the name of the LibQxt project nor the andre@1: ** names of its contributors may be used to endorse or promote products andre@1: ** derived from this software without specific prior written permission. andre@1: ** andre@1: ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND andre@1: ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED andre@1: ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE andre@1: ** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY andre@1: ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES andre@1: ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; andre@1: ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND andre@1: ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT andre@1: ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS andre@1: ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. andre@1: ** andre@1: ** andre@1: *****************************************************************************/ andre@1: andre@1: #ifndef QXTGLOBAL_H andre@1: #define QXTGLOBAL_H andre@1: andre@1: #include andre@1: andre@1: #define QXT_VERSION 0x000700 andre@1: #define QXT_VERSION_STR "0.7.0" andre@1: andre@1: //--------------------------global macros------------------------------ andre@1: andre@1: #ifndef QXT_NO_MACROS andre@1: andre@1: #ifndef _countof andre@1: #define _countof(x) (sizeof(x)/sizeof(*x)) andre@1: #endif andre@1: andre@1: #endif // QXT_NO_MACROS andre@1: andre@1: //--------------------------export macros------------------------------ andre@1: andre@1: #define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE andre@1: andre@1: #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) andre@1: # if defined(BUILD_QXT_CORE) andre@1: # define QXT_CORE_EXPORT Q_DECL_EXPORT andre@1: # else andre@1: # define QXT_CORE_EXPORT Q_DECL_IMPORT andre@1: # endif andre@1: #else andre@1: # define QXT_CORE_EXPORT andre@1: #endif // BUILD_QXT_CORE andre@1: andre@1: #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) andre@1: # if defined(BUILD_QXT_GUI) andre@1: # define QXT_GUI_EXPORT Q_DECL_EXPORT andre@1: # else andre@1: # define QXT_GUI_EXPORT Q_DECL_IMPORT andre@1: # endif andre@1: #else andre@1: # define QXT_GUI_EXPORT andre@1: #endif // BUILD_QXT_GUI andre@1: andre@1: #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) andre@1: # if defined(BUILD_QXT_NETWORK) andre@1: # define QXT_NETWORK_EXPORT Q_DECL_EXPORT andre@1: # else andre@1: # define QXT_NETWORK_EXPORT Q_DECL_IMPORT andre@1: # endif andre@1: #else andre@1: # define QXT_NETWORK_EXPORT andre@1: #endif // BUILD_QXT_NETWORK andre@1: andre@1: #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) andre@1: # if defined(BUILD_QXT_SQL) andre@1: # define QXT_SQL_EXPORT Q_DECL_EXPORT andre@1: # else andre@1: # define QXT_SQL_EXPORT Q_DECL_IMPORT andre@1: # endif andre@1: #else andre@1: # define QXT_SQL_EXPORT andre@1: #endif // BUILD_QXT_SQL andre@1: andre@1: #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) andre@1: # if defined(BUILD_QXT_WEB) andre@1: # define QXT_WEB_EXPORT Q_DECL_EXPORT andre@1: # else andre@1: # define QXT_WEB_EXPORT Q_DECL_IMPORT andre@1: # endif andre@1: #else andre@1: # define QXT_WEB_EXPORT andre@1: #endif // BUILD_QXT_WEB andre@1: andre@1: #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) andre@1: # if defined(BUILD_QXT_BERKELEY) andre@1: # define QXT_BERKELEY_EXPORT Q_DECL_EXPORT andre@1: # else andre@1: # define QXT_BERKELEY_EXPORT Q_DECL_IMPORT andre@1: # endif andre@1: #else andre@1: # define QXT_BERKELEY_EXPORT andre@1: #endif // BUILD_QXT_BERKELEY andre@1: andre@1: #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) andre@1: # if defined(BUILD_QXT_ZEROCONF) andre@1: # define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT andre@1: # else andre@1: # define QXT_ZEROCONF_EXPORT Q_DECL_IMPORT andre@1: # endif andre@1: #else andre@1: # define QXT_ZEROCONF_EXPORT andre@1: #endif // QXT_ZEROCONF_EXPORT andre@1: andre@1: #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) andre@1: # define BUILD_QXT andre@1: #endif andre@1: andre@1: QXT_CORE_EXPORT const char* qxtVersion(); andre@1: andre@1: #ifndef QT_BEGIN_NAMESPACE andre@1: #define QT_BEGIN_NAMESPACE andre@1: #endif andre@1: andre@1: #ifndef QT_END_NAMESPACE andre@1: #define QT_END_NAMESPACE andre@1: #endif andre@1: andre@1: #ifndef QT_FORWARD_DECLARE_CLASS andre@1: #define QT_FORWARD_DECLARE_CLASS(Class) class Class; andre@1: #endif andre@1: andre@1: /**************************************************************************** andre@1: ** This file is derived from code bearing the following notice: andre@1: ** The sole author of this file, Adam Higerd, has explicitly disclaimed all andre@1: ** copyright interest and protection for the content within. This file has andre@1: ** been placed in the public domain according to United States copyright andre@1: ** statute and case law. In jurisdictions where this public domain dedication andre@1: ** is not legally recognized, anyone who receives a copy of this file is andre@1: ** permitted to use, modify, duplicate, and redistribute this file, in whole andre@1: ** or in part, with no restrictions or conditions. In these jurisdictions, andre@1: ** this file shall be copyright (C) 2006-2008 by Adam Higerd. andre@1: ****************************************************************************/ andre@1: andre@1: #define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface qxt_d; andre@1: #define QXT_DECLARE_PUBLIC(PUB) friend class PUB; andre@1: #define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this); andre@1: #define QXT_D(PUB) PUB##Private& d = qxt_d() andre@1: #define QXT_P(PUB) PUB& p = qxt_p() andre@1: andre@1: template andre@1: class QxtPrivate andre@1: { andre@1: public: andre@1: virtual ~QxtPrivate() andre@1: {} andre@1: inline void QXT_setPublic(PUB* pub) andre@1: { andre@1: qxt_p_ptr = pub; andre@1: } andre@1: andre@1: protected: andre@1: inline PUB& qxt_p() andre@1: { andre@1: return *qxt_p_ptr; andre@1: } andre@1: inline const PUB& qxt_p() const andre@1: { andre@1: return *qxt_p_ptr; andre@1: } andre@1: inline PUB* qxt_ptr() andre@1: { andre@1: return qxt_p_ptr; andre@1: } andre@1: inline const PUB* qxt_ptr() const andre@1: { andre@1: return qxt_p_ptr; andre@1: } andre@1: andre@1: private: andre@1: PUB* qxt_p_ptr; andre@1: }; andre@1: andre@1: template andre@1: class QxtPrivateInterface andre@1: { andre@1: friend class QxtPrivate; andre@1: public: andre@1: QxtPrivateInterface() andre@1: { andre@1: pvt = new PVT; andre@1: } andre@1: ~QxtPrivateInterface() andre@1: { andre@1: delete pvt; andre@1: } andre@1: andre@1: inline void setPublic(PUB* pub) andre@1: { andre@1: pvt->QXT_setPublic(pub); andre@1: } andre@1: inline PVT& operator()() andre@1: { andre@1: return *static_cast(pvt); andre@1: } andre@1: inline const PVT& operator()() const andre@1: { andre@1: return *static_cast(pvt); andre@1: } andre@1: inline PVT * operator->() andre@1: { andre@1: return static_cast(pvt); andre@1: } andre@1: inline const PVT * operator->() const andre@1: { andre@1: return static_cast(pvt); andre@1: } andre@1: private: andre@1: QxtPrivateInterface(const QxtPrivateInterface&) { } andre@1: QxtPrivateInterface& operator=(const QxtPrivateInterface&) { } andre@1: QxtPrivate* pvt; andre@1: }; andre@1: andre@1: #endif // QXT_GLOBAL