File indexing completed on 2024-05-12 15:27:41

0001 
0002 /****************************************************************************
0003 ** Copyright (c) 2006 - 2011, the LibQxt project.
0004 ** See the Qxt AUTHORS file for a list of authors and copyright holders.
0005 ** All rights reserved.
0006 **
0007 ** Redistribution and use in source and binary forms, with or without
0008 ** modification, are permitted provided that the following conditions are met:
0009 **     * Redistributions of source code must retain the above copyright
0010 **       notice, this list of conditions and the following disclaimer.
0011 **     * Redistributions in binary form must reproduce the above copyright
0012 **       notice, this list of conditions and the following disclaimer in the
0013 **       documentation and/or other materials provided with the distribution.
0014 **     * Neither the name of the LibQxt project nor the
0015 **       names of its contributors may be used to endorse or promote products
0016 **       derived from this software without specific prior written permission.
0017 **
0018 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
0019 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
0020 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0021 ** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
0022 ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0023 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0024 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
0025 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0026 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0027 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0028 **
0029 ** <http://libqxt.org>  <foundation@libqxt.org>
0030 *****************************************************************************/
0031 
0032 #ifndef QXTGLOBAL_H
0033 #define QXTGLOBAL_H
0034 
0035 #include <QtGlobal>
0036 
0037 #define QXT_VERSION 0x000700
0038 #define QXT_VERSION_STR "0.7.0"
0039 
0040 //--------------------------global macros------------------------------
0041 
0042 #ifndef QXT_NO_MACROS
0043 
0044 #ifndef _countof
0045 #define _countof(x) (sizeof(x)/sizeof(*x))
0046 #endif
0047 
0048 #endif // QXT_NO_MACROS
0049 
0050 //--------------------------export macros------------------------------
0051 
0052 #define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE
0053 
0054 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
0055 #    if defined(BUILD_QXT_CORE)
0056 #        define QXT_CORE_EXPORT Q_DECL_EXPORT
0057 #    else
0058 #        define QXT_CORE_EXPORT Q_DECL_IMPORT
0059 #    endif
0060 #else
0061 #    define QXT_CORE_EXPORT
0062 #endif // BUILD_QXT_CORE
0063 
0064 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
0065 #    if defined(BUILD_QXT_GUI)
0066 #        define QXT_GUI_EXPORT Q_DECL_EXPORT
0067 #    else
0068 #        define QXT_GUI_EXPORT Q_DECL_IMPORT
0069 #    endif
0070 #else
0071 #    define QXT_GUI_EXPORT
0072 #endif // BUILD_QXT_GUI
0073 
0074 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
0075 #    if defined(BUILD_QXT_NETWORK)
0076 #        define QXT_NETWORK_EXPORT Q_DECL_EXPORT
0077 #    else
0078 #        define QXT_NETWORK_EXPORT Q_DECL_IMPORT
0079 #    endif
0080 #else
0081 #    define QXT_NETWORK_EXPORT
0082 #endif // BUILD_QXT_NETWORK
0083 
0084 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
0085 #    if defined(BUILD_QXT_SQL)
0086 #        define QXT_SQL_EXPORT Q_DECL_EXPORT
0087 #    else
0088 #        define QXT_SQL_EXPORT Q_DECL_IMPORT
0089 #    endif
0090 #else
0091 #    define QXT_SQL_EXPORT
0092 #endif // BUILD_QXT_SQL
0093 
0094 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
0095 #    if defined(BUILD_QXT_WEB)
0096 #        define QXT_WEB_EXPORT Q_DECL_EXPORT
0097 #    else
0098 #        define QXT_WEB_EXPORT Q_DECL_IMPORT
0099 #    endif
0100 #else
0101 #    define QXT_WEB_EXPORT
0102 #endif // BUILD_QXT_WEB
0103 
0104 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
0105 #    if defined(BUILD_QXT_BERKELEY)
0106 #        define QXT_BERKELEY_EXPORT Q_DECL_EXPORT
0107 #    else
0108 #        define QXT_BERKELEY_EXPORT Q_DECL_IMPORT
0109 #    endif
0110 #else
0111 #    define QXT_BERKELEY_EXPORT
0112 #endif // BUILD_QXT_BERKELEY
0113 
0114 #if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN)
0115 #    if defined(BUILD_QXT_ZEROCONF)
0116 #        define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT
0117 #    else
0118 #        define QXT_ZEROCONF_EXPORT Q_DECL_IMPORT
0119 #    endif
0120 #else
0121 #    define QXT_ZEROCONF_EXPORT
0122 #endif // QXT_ZEROCONF_EXPORT
0123 
0124 #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)
0125 #   define BUILD_QXT
0126 #endif
0127 
0128 QXT_CORE_EXPORT const char* qxtVersion();
0129 
0130 #ifndef QT_BEGIN_NAMESPACE
0131 #define QT_BEGIN_NAMESPACE
0132 #endif
0133 
0134 #ifndef QT_END_NAMESPACE
0135 #define QT_END_NAMESPACE
0136 #endif
0137 
0138 #ifndef QT_FORWARD_DECLARE_CLASS
0139 #define QT_FORWARD_DECLARE_CLASS(Class) class Class;
0140 #endif
0141 
0142 /****************************************************************************
0143 ** This file is derived from code bearing the following notice:
0144 ** The sole author of this file, Adam Higerd, has explicitly disclaimed all
0145 ** copyright interest and protection for the content within. This file has
0146 ** been placed in the public domain according to United States copyright
0147 ** statute and case law. In jurisdictions where this public domain dedication
0148 ** is not legally recognized, anyone who receives a copy of this file is
0149 ** permitted to use, modify, duplicate, and redistribute this file, in whole
0150 ** or in part, with no restrictions or conditions. In these jurisdictions,
0151 ** this file shall be copyright (C) 2006-2008 by Adam Higerd.
0152 ****************************************************************************/
0153 
0154 #define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface<PUB, PUB##Private> qxt_d;
0155 #define QXT_DECLARE_PUBLIC(PUB) friend class PUB;
0156 #define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this);
0157 #define QXT_D(PUB) PUB##Private& d = qxt_d()
0158 #define QXT_P(PUB) PUB& p = qxt_p()
0159 
0160 template <typename PUB>
0161 class QxtPrivate {
0162 public:
0163     virtual ~QxtPrivate()
0164         = default;
0165     inline void QXT_setPublic(PUB* pub) {
0166         qxt_p_ptr = pub;
0167     }
0168 
0169 protected:
0170     inline PUB& qxt_p() {
0171         return *qxt_p_ptr;
0172     }
0173     inline const PUB& qxt_p() const {
0174         return *qxt_p_ptr;
0175     }
0176     inline PUB* qxt_ptr() {
0177         return qxt_p_ptr;
0178     }
0179     inline const PUB* qxt_ptr() const {
0180         return qxt_p_ptr;
0181     }
0182 
0183 private:
0184     PUB* qxt_p_ptr;
0185 };
0186 
0187 template <typename PUB, typename PVT>
0188 class QxtPrivateInterface {
0189     friend class QxtPrivate<PUB>;
0190 public:
0191     QxtPrivateInterface() {
0192         pvt = new PVT;
0193     }
0194     ~QxtPrivateInterface() {
0195         delete pvt;
0196     }
0197 
0198     inline void setPublic(PUB* pub) {
0199         pvt->QXT_setPublic(pub);
0200     }
0201     inline PVT& operator()() {
0202         return *static_cast<PVT*>(pvt);
0203     }
0204     inline const PVT& operator()() const {
0205         return *static_cast<PVT*>(pvt);
0206     }
0207     inline PVT * operator->() {
0208         return static_cast<PVT*>(pvt);
0209     }
0210     inline const PVT * operator->() const {
0211         return static_cast<PVT*>(pvt);
0212     }
0213 private:
0214     QxtPrivateInterface(const QxtPrivateInterface&) { }
0215     QxtPrivateInterface& operator=(const QxtPrivateInterface& i) {
0216         return i;
0217     }
0218     QxtPrivate<PUB>* pvt;
0219 };
0220 
0221 #endif // QXT_GLOBAL