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

Generated by doxygen 1.8.5