[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
klfqt34common.h
1 /***************************************************************************
2  * file klfqt34common.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: klfqt34common.h 862 2013-11-23 11:10:54Z phfaist $ */
23 
24 #ifndef KLFQT34COMMON_H
25 #define KLFQT34COMMON_H
26 
27 
28 // some convenient #define's for Qt3/4 compatibility
29 
30 #ifdef KLFBACKEND_QT4
31 #define dir_native_separators(x) QDir::toNativeSeparators(x)
32 #define ba_assign(otherba) operator=(otherba)
33 #define buf_setdata(buf, ba_ref) buf.setData(ba_ref)
34 #define dev_WRITEONLY QIODevice::WriteOnly
35 #define dev_READONLY QIODevice::ReadOnly
36 #define dev_write write
37 #define fi_suffix suffix
38 #define fi_absolutePath absolutePath
39 #define f_open_fp(fp) open((fp), dev_WRITEONLY)
40 #define f_setFileName setFileName
41 #define f_error error
42 #define s_trimmed trimmed
43 #define s_toUpper toUpper
44 #define s_toLatin1 toLatin1
45 #define s_toLocal8Bit toLocal8Bit
46 #define s_indexOf indexOf
47 #define str_split(string, sep, boolAllowEmptyEntries) \
48  (string).split((sep), (boolAllowEmptyEntries) ? QString::KeepEmptyParts : QString::SkipEmptyParts)
49 #define list_indexOf(x) indexOf((x))
50 #define rx_indexin(str) indexIn((str))
51 #define rx_indexin_i(str, i) indexIn((str), (i))
52 #define img_settext(key, value) setText((key), (value))
53 #else
54 #define qPrintable(x) (x).local8Bit().data()
55 #define QLatin1String QString::fromLatin1
56 #define dir_native_separators(x) QDir::convertSeparators(x)
57 #define ba_assign(otherba) duplicate((otherba).data(), (otherba).size())
58 #define buf_setdata(buf, ba_ref) buf.setBuffer(ba_ref)
59 #define dev_WRITEONLY IO_WriteOnly
60 #define dev_READONLY IO_ReadOnly
61 #define dev_write writeBlock
62 #define fi_suffix extension
63 #define fi_absolutePath() dirPath(true)
64 #define f_open_fp(fp) open(dev_WRITEONLY, (fp))
65 #define f_setFileName setName
66 #define f_error errorString
67 #define s_trimmed stripWhiteSpace
68 #define s_toUpper upper
69 #define s_toLatin1 latin1
70 #define s_toLocal8Bit local8Bit
71 #define s_indexOf find
72 #define str_split(string, sep, boolAllowEmptyEntries) \
73  QStringList::split((sep), (string), (boolAllowEmptyEntries))
74 #define list_indexOf(x) findIndex((x))
75 #define rx_indexin(str) search((str))
76 #define rx_indexin_i(str, i) search((str), (i))
77 #define img_settext(key, value) setText((key), 0, (value))
78 #endif
79 
80 
81 // EXTRA DEFINITIONS
82 
83 #ifndef KLFBACKEND_QT4
84 // The following lines defining quintptr/qptrdiff are taken from Qt's corelib/global/qglobal.h
85 // source file. (changed QIntegerForSize -> __klf_integer_for_size)
86 /*
87  quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e.
88 
89  sizeof(void *) == sizeof(quintptr)
90  && sizeof(void *) == sizeof(qptrdiff)
91 */
92 template <int> struct __klf_integer_for_size;
93 template <> struct __klf_integer_for_size<1> { typedef Q_UINT8 Unsigned; typedef Q_INT8 Signed; };
94 template <> struct __klf_integer_for_size<2> { typedef Q_UINT16 Unsigned; typedef Q_INT16 Signed; };
95 template <> struct __klf_integer_for_size<4> { typedef Q_UINT32 Unsigned; typedef Q_INT32 Signed; };
96 template <> struct __klf_integer_for_size<8> { typedef Q_UINT64 Unsigned; typedef Q_INT64 Signed; };
97 template <class T> struct __klf_integer_for_sizeof: __klf_integer_for_size<sizeof(T)> { };
98 typedef __klf_integer_for_sizeof<void*>::Unsigned quintptr;
99 typedef __klf_integer_for_sizeof<void*>::Signed qptrdiff;
100 #endif
101 
102 
103 
104 
105 
106 #endif // KLFQT34COMMON_H

Generated by doxygen 1.8.6