kjsembed
kjseglobal.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2004,2005,2006 Ian Reinhart Geiser <geiseri@kde.org> 00003 Copyright (C) 2004,2005,2006 Matt Broadstone <mbroadst@gmail.com> 00004 Copyright (C) 2004,2005,2006 Richard J. Moore <rich@kde.org> 00005 Copyright (C) 2004,2005,2006 Erik L. Bunce <kde@bunce.us> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library 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 GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef KJSEGLOBAL_H 00024 #define KJSEGLOBAL_H 00025 00026 #include <kdemacros.h> 00027 00028 #if defined(Q_OS_WIN) 00029 # if (defined(KJSEMBED_DLL) && defined(KJSEMBED_MAKE_DLL)) || defined(MAKE_KJSEMBED_LIB) 00030 # define KJSEMBED_EXPORT KDE_EXPORT 00031 # else 00032 # define KJSEMBED_EXPORT KDE_IMPORT 00033 # endif 00034 #else 00035 # define KJSEMBED_EXPORT KDE_EXPORT 00036 #endif 00037 00038 #if !defined(Q_OS_WIN) 00039 #include <stdlib.h> 00040 #include <ctype.h> 00041 00042 KJSEMBED_EXPORT void RedirectIOToConsole(); 00043 00044 #endif 00045 00046 #include <QtCore/QTextStream> 00047 namespace KJSEmbed { 00048 KJSEMBED_EXPORT QTextStream *conin(); 00049 KJSEMBED_EXPORT QTextStream *conout(); 00050 KJSEMBED_EXPORT QTextStream *conerr(); 00051 } 00052 00053 #include <kjs/ustring.h> 00054 #include <kjs/identifier.h> 00055 #include <kjs/value.h> 00056 00057 namespace KJSEmbed { 00058 inline QString toQString(const KJS::UString& u) 00059 { 00060 return QString((QChar*)u.data(), u.size()); 00061 } 00062 inline QString toQString(const KJS::Identifier& i) 00063 { 00064 return QString((QChar*)i.data(), i.size()); 00065 } 00066 inline KJS::UString toUString(const QString& qs) 00067 { 00068 return KJS::UString((KJS::UChar*)qs.data(), qs.size()); 00069 } 00070 } 00071 00072 namespace KJS { 00073 inline KJS::JSCell* jsString(const QString& s) 00074 { 00075 return jsString(KJSEmbed::toUString(s)); 00076 } 00077 } 00078 00079 #ifndef QT_ONLY 00080 00081 /* 00082 * These are the normal definitions used when KDE is available. 00083 */ 00084 00085 #include <kdebug.h> 00086 #include <klocale.h> 00087 00088 #else // QT_ONLY 00089 00090 /* 00091 * These are the custom definitions used when we only have Qt. 00092 */ 00093 00094 KJSEMBED_EXPORT QTextStream &kdDebug( int area=0 ); 00095 KJSEMBED_EXPORT QTextStream &kdWarning( int area=0 ); 00096 00097 #ifndef NO_I18N 00098 KJSEMBED_EXPORT QString i18n( const char *string ); 00099 #else 00100 #define i18n(x) QString(x) 00101 #endif // NO_I18N 00102 00103 inline KJSEMBED_EXPORT QString i18n( const QString& string, const QString& comment ) 00104 { 00105 return i18n(string.toUtf8().data(), comment.toUtf8().data()); 00106 } 00107 template <typename A1> 00108 inline QString i18n (const char *text, const A1 &a1) 00109 { 00110 return i18n(text).arg(a1); 00111 } 00112 template <typename A1, typename A2> 00113 inline QString i18n (const char *text, const A1 &a1, const A2 &a2) 00114 { 00115 return i18n(text).arg(a1).arg(a2); 00116 } 00117 template <typename A1, typename A2, typename A3> 00118 inline QString i18n (const char *text, const A1 &a1, const A2 &a2, const A3 &a3) 00119 { 00120 return i18n(text).arg(a1).arg(a2).arg(a3); 00121 } 00122 template <typename A1, typename A2, typename A3, typename A4> 00123 inline QString i18n (const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) 00124 { 00125 return i18n(text).arg(a1).arg(a2).arg(a3).arg(a4); 00126 } 00127 00128 #endif // QT_ONLY 00129 00130 #endif // KJSEGLOBAL_H 00131 00132 //kate: indent-spaces on; indent-width 4; replace-tabs on; indent-mode cstyle;
KDE 4.6 API Reference