KDECore
kmacroexpander.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _KMACROEXPANDER_H
00023 #define _KMACROEXPANDER_H
00024
00025 #include <qstringlist.h>
00026 #include <qstring.h>
00027 #include <qmap.h>
00028 #include "kdelibs_export.h"
00029
00037 class KDECORE_EXPORT KMacroExpanderBase {
00038
00039 public:
00044 KMacroExpanderBase( QChar c = '%' );
00045
00049 virtual ~KMacroExpanderBase();
00050
00056 void expandMacros( QString &str );
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 bool expandMacrosShellQuote( QString &str, uint &pos );
00087
00092 bool expandMacrosShellQuote( QString &str );
00093
00098 void setEscapeChar( QChar c );
00099
00104 QChar escapeChar() const;
00105
00106 protected:
00120 virtual int expandPlainMacro( const QString &str, uint pos, QStringList &ret );
00121
00136 virtual int expandEscapedMacro( const QString &str, uint pos, QStringList &ret );
00137
00138 private:
00139 QChar escapechar;
00140 };
00141
00191 class KDECORE_EXPORT KWordMacroExpander : public KMacroExpanderBase {
00192
00193 public:
00198 KWordMacroExpander( QChar c = '%' ) : KMacroExpanderBase( c ) {}
00199
00200 protected:
00201 virtual int expandPlainMacro( const QString &str, uint pos, QStringList &ret );
00202 virtual int expandEscapedMacro( const QString &str, uint pos, QStringList &ret );
00203
00211 virtual bool expandMacro( const QString &str, QStringList &ret ) = 0;
00212 };
00213
00224 class KDECORE_EXPORT KCharMacroExpander : public KMacroExpanderBase {
00225
00226 public:
00231 KCharMacroExpander( QChar c = '%' ) : KMacroExpanderBase( c ) {}
00232
00233 protected:
00234 virtual int expandPlainMacro( const QString &str, uint pos, QStringList &ret );
00235 virtual int expandEscapedMacro( const QString &str, uint pos, QStringList &ret );
00236
00244 virtual bool expandMacro( QChar chr, QStringList &ret ) = 0;
00245 };
00246
00252 namespace KMacroExpander {
00273 KDECORE_EXPORT QString expandMacros( const QString &str, const QMap<QChar,QString> &map, QChar c = '%' );
00274
00298 KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QMap<QChar,QString> &map, QChar c = '%' );
00299
00323 KDECORE_EXPORT QString expandMacros( const QString &str, const QMap<QString,QString> &map, QChar c = '%' );
00324
00351 KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QMap<QString,QString> &map, QChar c = '%' );
00352
00357 KDECORE_EXPORT QString expandMacros( const QString &str, const QMap<QChar,QStringList> &map, QChar c = '%' );
00362 KDECORE_EXPORT QString expandMacros( const QString &str, const QMap<QString,QStringList> &map, QChar c = '%' );
00363
00370 KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QMap<QChar,QStringList> &map, QChar c = '%' );
00377 KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QMap<QString,QStringList> &map, QChar c = '%' );
00378 }
00379
00380 #endif