[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project

src/klfbackend/klfqt34common.h

00001 /***************************************************************************
00002  *   file klfqt34common.h
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2010 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: klfqt34common.h 540 2010-10-04 00:19:05Z philippe $ */
00023 
00024 #ifndef KLFQT34COMMON_H
00025 #define KLFQT34COMMON_H
00026 
00027 
00028 // some convenient #define's for Qt3/4 compatibility
00029 
00030 #ifdef KLFBACKEND_QT4
00031 #define dir_native_separators(x) QDir::toNativeSeparators(x)
00032 #define ba_assign(otherba) operator=(otherba)
00033 #define dev_WRITEONLY QIODevice::WriteOnly
00034 #define dev_READONLY QIODevice::ReadOnly
00035 #define dev_write write
00036 #define fi_suffix suffix
00037 #define fi_absolutePath absolutePath
00038 #define f_open_fp(fp) open((fp), dev_WRITEONLY)
00039 #define f_setFileName setFileName
00040 #define f_error error
00041 #define s_trimmed trimmed
00042 #define s_toUpper toUpper
00043 #define s_toLatin1 toLatin1
00044 #define s_toLocal8Bit toLocal8Bit
00045 #define s_indexOf indexOf
00046 #define str_split(string, sep, boolAllowEmptyEntries)                   \
00047   (string).split((sep), (boolAllowEmptyEntries) ? QString::KeepEmptyParts : QString::SkipEmptyParts)
00048 #define list_indexOf(x) indexOf((x))
00049 #define rx_indexin(str) indexIn((str))
00050 #define rx_indexin_i(str, i) indexIn((str), (i))
00051 #define img_settext(key, value)  setText((key), (value))
00052 #else
00053 #define qPrintable(x) (x).local8Bit().data()
00054 #define QLatin1String QString::fromLatin1
00055 #define dir_native_separators(x) QDir::convertSeparators(x)
00056 #define ba_assign(otherba) duplicate((otherba).data(), (otherba).size())
00057 #define dev_WRITEONLY IO_WriteOnly
00058 #define dev_READONLY IO_ReadOnly
00059 #define dev_write writeBlock
00060 #define fi_suffix extension
00061 #define fi_absolutePath() dirPath(true)
00062 #define f_open_fp(fp) open(dev_WRITEONLY, (fp))
00063 #define f_setFileName setName
00064 #define f_error errorString
00065 #define s_trimmed stripWhiteSpace
00066 #define s_toUpper upper
00067 #define s_toLatin1 latin1
00068 #define s_toLocal8Bit local8Bit
00069 #define s_indexOf find
00070 #define str_split(string, sep, boolAllowEmptyEntries)           \
00071   QStringList::split((sep), (string), (boolAllowEmptyEntries))
00072 #define list_indexOf(x) findIndex((x))
00073 #define rx_indexin(str) search((str))
00074 #define rx_indexin_i(str, i) search((str), (i))
00075 #define img_settext(key, value)  setText((key), 0, (value))
00076 #endif
00077 
00078 
00079 // EXTRA DEFINITIONS
00080 
00081 #ifndef KLFBACKEND_QT4
00082 // The following lines defining quintptr/qptrdiff are taken from Qt's corelib/global/qglobal.h
00083 // source file. (changed QIntegerForSize -> __klf_integer_for_size)
00084 /*
00085   quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e.
00086 
00087       sizeof(void *) == sizeof(quintptr)
00088       && sizeof(void *) == sizeof(qptrdiff)
00089 */
00090 template <int> struct __klf_integer_for_size;
00091 template <>    struct __klf_integer_for_size<1> { typedef Q_UINT8  Unsigned; typedef Q_INT8  Signed; };
00092 template <>    struct __klf_integer_for_size<2> { typedef Q_UINT16 Unsigned; typedef Q_INT16 Signed; };
00093 template <>    struct __klf_integer_for_size<4> { typedef Q_UINT32 Unsigned; typedef Q_INT32 Signed; };
00094 template <>    struct __klf_integer_for_size<8> { typedef Q_UINT64 Unsigned; typedef Q_INT64 Signed; };
00095 template <class T> struct __klf_integer_for_sizeof: __klf_integer_for_size<sizeof(T)> { };
00096 typedef __klf_integer_for_sizeof<void*>::Unsigned quintptr;
00097 typedef __klf_integer_for_sizeof<void*>::Signed qptrdiff;
00098 #endif
00099 
00100 
00101 
00102 
00103 
00104 #endif // KLFQT34COMMON_H

Generated by doxygen 1.7.3