Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef KLFDEFS_H_
00025 #define KLFDEFS_H_
00026
00027 #include <QObject>
00028 #include <QString>
00029 #include <QVariant>
00030
00031
00032
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
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
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
00138 #include <klfdebug.h>
00139
00140
00141 #endif