[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfdefs.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfdefs.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfdefs.h 971 2016-12-30 04:24:56Z phfaist $ */
23 
24 #ifndef KLFDEFS_H_
25 #define KLFDEFS_H_
26 
27 #include <QObject>
28 #include <QString>
29 #include <QVariant>
30 
31 
32 // EXPORTING SYMBOLS TO E.G. PLUGINS ...
33 #ifndef KLF_EXPORT
34 # if defined(Q_OS_WIN)
35 # if defined(KLF_SRC_BUILD)
36 # define KLF_EXPORT __declspec(dllexport)
37 # else
38 # define KLF_EXPORT __declspec(dllimport)
39 # endif
40 # else
41 # define KLF_EXPORT __attribute__((visibility("default")))
42 # endif
43 #endif
44 
45 
46 // VERSION INFORMATION
47 
48 KLF_EXPORT const char * klfVersion();
49 
53 
54 
55 KLF_EXPORT QByteArray klfFmt(const char * fmt, ...)
56 #if defined(Q_CC_GNU) && !defined(__INSURE__)
57  __attribute__ ((format (printf, 1, 2)))
58 #endif
59 ;
60 
61 #define klfFmtCC (const char*)klfFmt
62 
63 KLF_EXPORT QByteArray klfFmt(const char * fmt, va_list pp) ;
64 
65 KLF_EXPORT QByteArray klfFmtDouble(double num, char fmt = 'g', int precision = 6);
66 
67 #define klfFmtDoubleCC (const char*)klfFmtDouble
68 
69 
70 #define KLF_FUNC_SINGLE_RUN \
71  { static bool first_run = true; if ( ! first_run ) return; first_run = false; }
72 
73 
74 #define KLF_DECLARE_PRIVATE(ClassName) \
75  private: \
76  ClassName##Private *d; \
77  friend struct ClassName##Private; \
78  inline ClassName##Private * d_func() { return d; } \
79  inline const ClassName##Private * d_func() const { return d; }
80 
81 #define KLF_PRIVATE_HEAD(ClassName) \
82  private: ClassName *K; \
83  public: ClassName * parentClass() const { return K; } \
84  public: ClassName##Private (ClassName * ptr) : K(ptr)
85 #define KLF_PRIVATE_INHERIT_HEAD(ClassName, BaseInit) \
86  private: ClassName *K; \
87  public: ClassName * parentClass() const { return K; } \
88  public: ClassName##Private (ClassName * ptr) BaseInit, K(ptr)
89 #define KLF_PRIVATE_QOBJ_HEAD(ClassName, QObj) \
90  private: ClassName *K; \
91  public: ClassName * parentClass() const { return K; } \
92  public: ClassName##Private (ClassName * ptr) : QObj(ptr), K(ptr)
93 
94 #define KLF_INIT_PRIVATE(ClassName) \
95  do { d = new ClassName##Private(this); } while (0)
96 #define KLF_DELETE_PRIVATE \
97  do { if (d != NULL) { delete d; } } while (0)
98 
99 
100 #define KLF_BLOCK \
101  for (bool _klf_block_first = true; _klf_block_first; _klf_block_first = false)
102 
103 #define KLF_TRY(expr, msg, failaction) \
104  if ( !(expr) ) { \
105  klfWarning(msg); \
106  failaction; \
107  }
108 
109 
110 
111 
112 
113 #define KLF_DEFINE_PROPERTY_GET(ClassName, type, prop) \
114  type ClassName::prop() const { return d_func()->prop; }
115 
116 #define KLF_DEFINE_PROPERTY_GETSET(ClassName, type, prop, Prop) \
117  KLF_DEFINE_PROPERTY_GET(ClassName, type, prop) \
118  void ClassName::set##Prop(type value) { d_func()->prop = value; }
119 
120 #define KLF_DEFINE_PROPERTY_GETSET_C(ClassName, type, prop, Prop) \
121  KLF_DEFINE_PROPERTY_GET(ClassName, type, prop) \
122  void ClassName::set##Prop(const type& value) { d_func()->prop = value; }
123 
124 
125 
126 
127 // utility functions
128 
129 KLF_EXPORT bool klfIsValidVersion(const QString& v);
130 
131 KLF_EXPORT int klfVersionCompare(const QString& v1, const QString& v2);
132 
133 KLF_EXPORT bool klfVersionCompareLessThan(const QString& v1, const QString& v2);
134 
135 
136 
137 // Import debugging utilities
138 #include <klfdebug.h>
139 
140 
141 #endif
KLF_EXPORT int klfVersionRelease()
Definition: klfdefs.cpp:919
KLF_EXPORT int klfVersionMin()
Definition: klfdefs.cpp:915
KLF_EXPORT int klfVersionMaj()
Definition: klfdefs.cpp:911
Debugging utilities.
KLF_EXPORT bool klfVersionCompareLessThan(const QString &v1, const QString &v2)
Same as klfVersionCompare(v1,v2) < 0
Definition: klfdefs.cpp:1270
KLF_EXPORT const char * klfVersion()
Definition: klfdefs.cpp:906
#define KLF_EXPORT
Definition: klfdefs.h:41
const char * format
Definition: klfdatautil.cpp:81
KLF_EXPORT int klfVersionCompare(const QString &v1, const QString &v2)
Compares two version strings.
Definition: klfdefs.cpp:1181
KLF_EXPORT bool klfIsValidVersion(const QString &v)
Definition: klfdefs.cpp:1175
KLF_EXPORT QByteArray klfFmtDouble(double num, char fmt='g', int precision=6)
Definition: klfdefs.cpp:1037
KLF_EXPORT QByteArray klfFmt(const char *fmt,...)
Definition: klfdefs.cpp:1027

Generated by doxygen 1.8.13