[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
src/klftools/klfdefs.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  *   file klfdefs.h
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2011 by Philippe Faist
00005  *   philippe.faist at bluewin.ch
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 /* $Id$ */
00023 
00024 #ifndef KLFDEFS_H_
00025 #define KLFDEFS_H_
00026 
00027 #include <QObject>
00028 #include <QString>
00029 #include <QVariant>
00030 
00031 
00032 // EXPORTING SYMBOLS TO E.G. PLUGINS ...
00033 #ifndef KLF_EXPORT
00034 #  if defined(Q_OS_WIN)
00035 #    if defined(KLF_SRC_BUILD)
00036 #      define KLF_EXPORT __declspec(dllexport)
00037 #    else
00038 #      define KLF_EXPORT __declspec(dllimport)
00039 #    endif
00040 #  else
00041 #    define KLF_EXPORT __attribute__((visibility("default")))
00042 #  endif
00043 #endif
00044 
00045 
00046 // VERSION INFORMATION
00047 
00048 KLF_EXPORT const char * klfVersion();
00049 
00050 KLF_EXPORT int klfVersionMaj();
00051 KLF_EXPORT int klfVersionMin();
00052 KLF_EXPORT int klfVersionRelease();
00053 
00054 
00055 KLF_EXPORT QByteArray klfFmt(const char * fmt, ...)
00056 #if defined(Q_CC_GNU) && !defined(__INSURE__)
00057     __attribute__ ((format (printf, 1, 2)))
00058 #endif
00059 ;
00060 
00061 #define klfFmtCC   (const char*)klfFmt
00062 
00063 KLF_EXPORT QByteArray klfFmt(const char * fmt, va_list pp) ;
00064 
00065 KLF_EXPORT QByteArray klfFmtDouble(double num, char fmt = 'g', int precision = 6);
00066 
00067 #define klfFmtDoubleCC (const char*)klfFmtDouble
00068 
00069 
00070 #define KLF_FUNC_SINGLE_RUN                                             \
00071   { static bool first_run = true;  if ( ! first_run )  return; first_run = false; }
00072 
00073 
00074 #define KLF_DECLARE_PRIVATE(ClassName)                                  \
00075   private:                                                              \
00076   ClassName##Private *d;                                                \
00077   friend struct ClassName##Private;                                     \
00078   inline ClassName##Private * d_func() { return d; }                    \
00079   inline const ClassName##Private * d_func() const { return d; }
00080 
00081 #define KLF_PRIVATE_HEAD(ClassName)                             \
00082   private: ClassName *K;                                        \
00083   public:  ClassName * parentClass() const { return K; }        \
00084   public:  ClassName##Private (ClassName * ptr) : K(ptr)
00085 #define KLF_PRIVATE_INHERIT_HEAD(ClassName, BaseInit)                   \
00086   private: ClassName *K;                                                \
00087   public:  ClassName * parentClass() const { return K; }                  \
00088   public:  ClassName##Private (ClassName * ptr) BaseInit, K(ptr)
00089 #define KLF_PRIVATE_QOBJ_HEAD(ClassName, QObj)                          \
00090   private: ClassName *K;                                                \
00091   public:  ClassName * parentClass() const { return K; }                \
00092   public:  ClassName##Private (ClassName * ptr) : QObj(ptr), K(ptr)
00093 
00094 #define KLF_INIT_PRIVATE(ClassName)             \
00095   do { d = new ClassName##Private(this); } while (0)
00096 #define KLF_DELETE_PRIVATE                      \
00097   do { if (d != NULL) { delete d; } } while (0)
00098 
00099 
00100 #define KLF_BLOCK                                                       \
00101   for (bool _klf_block_first = true; _klf_block_first; _klf_block_first = false)
00102 
00103 #define KLF_TRY(expr, msg, failaction)                                 \
00104   if ( !(expr) ) {                                                     \
00105     klfWarning(msg);                                                   \
00106     failaction;                                                        \
00107   }
00108 
00109 
00110 
00111 
00112 
00113 #define KLF_DEFINE_PROPERTY_GET(ClassName, type, prop)  \
00114   type ClassName::prop() const { return d_func()->prop; }
00115 
00116 #define KLF_DEFINE_PROPERTY_GETSET(ClassName, type, prop, Prop) \
00117   KLF_DEFINE_PROPERTY_GET(ClassName, type, prop)                \
00118     void ClassName::set##Prop(type value) { d_func()->prop = value; }
00119 
00120 #define KLF_DEFINE_PROPERTY_GETSET_C(ClassName, type, prop, Prop)       \
00121   KLF_DEFINE_PROPERTY_GET(ClassName, type, prop)                        \
00122     void ClassName::set##Prop(const type& value) { d_func()->prop = value; }
00123 
00124 
00125 
00126 
00127 // utility functions
00128 
00129 KLF_EXPORT bool klfIsValidVersion(const QString& v);
00130 
00131 KLF_EXPORT int klfVersionCompare(const QString& v1, const QString& v2);
00132 
00133 KLF_EXPORT bool klfVersionCompareLessThan(const QString& v1, const QString& v2);
00134 
00135 
00136 
00137 // Import debugging utilities
00138 #include <klfdebug.h>
00139 
00140 
00141 #endif

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net