KDECore
kmacroexpander.h
Go to the documentation of this file.
00001 /* 00002 This file is part of the KDE libraries 00003 00004 Copyright (c) 2002-2003 Oswald Buddenhagen <ossi@kde.org> 00005 Copyright (c) 2003 Waldo Bastian <bastian@kde.org> 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 #ifndef KMACROEXPANDER_H 00023 #define KMACROEXPANDER_H 00024 00025 #include <kdecore_export.h> 00026 #include <QtCore/QChar> 00027 00028 class QString; 00029 class QStringList; 00030 template <typename KT, typename VT> class QHash; 00031 class KMacroExpanderBasePrivate; 00032 00041 class KDECORE_EXPORT KMacroExpanderBase { 00042 00043 public: 00048 explicit KMacroExpanderBase( QChar c = QLatin1Char('%') ); 00049 00053 virtual ~KMacroExpanderBase(); 00054 00060 void expandMacros( QString &str ); 00061 00062 // TODO: This documentation is relevant for end-users. Where to put it? 00110 bool expandMacrosShellQuote( QString &str, int &pos ); 00111 00116 bool expandMacrosShellQuote( QString &str ); 00117 00122 void setEscapeChar( QChar c ); 00123 00128 QChar escapeChar() const; 00129 00130 protected: 00144 virtual int expandPlainMacro( const QString &str, int pos, QStringList &ret ); 00145 00161 virtual int expandEscapedMacro( const QString &str, int pos, QStringList &ret ); 00162 00163 private: 00164 KMacroExpanderBasePrivate * const d; 00165 }; 00166 00217 class KDECORE_EXPORT KWordMacroExpander : public KMacroExpanderBase { 00218 00219 public: 00224 explicit KWordMacroExpander( QChar c = QLatin1Char('%') ) : KMacroExpanderBase( c ) {} 00225 00226 protected: 00228 virtual int expandPlainMacro( const QString &str, int pos, QStringList &ret ); 00230 virtual int expandEscapedMacro( const QString &str, int pos, QStringList &ret ); 00231 00239 virtual bool expandMacro( const QString &str, QStringList &ret ) = 0; 00240 }; 00241 00253 class KDECORE_EXPORT KCharMacroExpander : public KMacroExpanderBase { 00254 00255 public: 00260 explicit KCharMacroExpander( QChar c = QLatin1Char('%') ) : KMacroExpanderBase( c ) {} 00261 00262 protected: 00264 virtual int expandPlainMacro( const QString &str, int pos, QStringList &ret ); 00266 virtual int expandEscapedMacro( const QString &str, int pos, QStringList &ret ); 00267 00275 virtual bool expandMacro( QChar chr, QStringList &ret ) = 0; 00276 }; 00277 00282 namespace KMacroExpander { 00303 KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QChar,QString> &map, QChar c = QLatin1Char('%') ); 00304 00328 KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QChar,QString> &map, 00329 QChar c = QLatin1Char('%') ); 00330 00354 KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QString,QString> &map, 00355 QChar c = QLatin1Char('%') ); 00356 00384 KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QString,QString> &map, 00385 QChar c = QLatin1Char('%') ); 00386 00391 KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QChar,QStringList> &map, 00392 QChar c = QLatin1Char('%') ); 00393 KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QString,QStringList> &map, 00394 QChar c = QLatin1Char('%') ); 00395 00402 KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QChar,QStringList> &map, 00403 QChar c = QLatin1Char('%') ); 00404 KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QString,QStringList> &map, 00405 QChar c = QLatin1Char('%') ); 00406 } 00407 00408 #endif /* KMACROEXPANDER_H */
KDE 4.6 API Reference