• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • util
kmacroexpander.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE libraries
3 
4  Copyright (c) 2002-2003 Oswald Buddenhagen <ossi@kde.org>
5  Copyright (c) 2003 Waldo Bastian <bastian@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library 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 GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 #ifndef KMACROEXPANDER_H
23 #define KMACROEXPANDER_H
24 
25 #include <kdecore_export.h>
26 #include <QtCore/QChar>
27 
28 class QString;
29 class QStringList;
30 template <typename KT, typename VT> class QHash;
31 class KMacroExpanderBasePrivate;
32 
41 class KDECORE_EXPORT KMacroExpanderBase {
42 
43 public:
48  explicit KMacroExpanderBase( QChar c = QLatin1Char('%') );
49 
53  virtual ~KMacroExpanderBase();
54 
60  void expandMacros( QString &str );
61 
62  // TODO: This documentation is relevant for end-users. Where to put it?
110  bool expandMacrosShellQuote( QString &str, int &pos );
111 
116  bool expandMacrosShellQuote( QString &str );
117 
122  void setEscapeChar( QChar c );
123 
128  QChar escapeChar() const;
129 
130 protected:
144  virtual int expandPlainMacro( const QString &str, int pos, QStringList &ret );
145 
161  virtual int expandEscapedMacro( const QString &str, int pos, QStringList &ret );
162 
163 private:
164  KMacroExpanderBasePrivate * const d;
165 };
166 
217 class KDECORE_EXPORT KWordMacroExpander : public KMacroExpanderBase {
218 
219 public:
224  explicit KWordMacroExpander( QChar c = QLatin1Char('%') ) : KMacroExpanderBase( c ) {}
225 
226 protected:
228  virtual int expandPlainMacro( const QString &str, int pos, QStringList &ret );
230  virtual int expandEscapedMacro( const QString &str, int pos, QStringList &ret );
231 
239  virtual bool expandMacro( const QString &str, QStringList &ret ) = 0;
240 };
241 
253 class KDECORE_EXPORT KCharMacroExpander : public KMacroExpanderBase {
254 
255 public:
260  explicit KCharMacroExpander( QChar c = QLatin1Char('%') ) : KMacroExpanderBase( c ) {}
261 
262 protected:
264  virtual int expandPlainMacro( const QString &str, int pos, QStringList &ret );
266  virtual int expandEscapedMacro( const QString &str, int pos, QStringList &ret );
267 
275  virtual bool expandMacro( QChar chr, QStringList &ret ) = 0;
276 };
277 
282 namespace KMacroExpander {
303  KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QChar,QString> &map, QChar c = QLatin1Char('%') );
304 
328  KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QChar,QString> &map,
329  QChar c = QLatin1Char('%') );
330 
354  KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QString,QString> &map,
355  QChar c = QLatin1Char('%') );
356 
384  KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QString,QString> &map,
385  QChar c = QLatin1Char('%') );
386 
391  KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QChar,QStringList> &map,
392  QChar c = QLatin1Char('%') );
393  KDECORE_EXPORT QString expandMacros( const QString &str, const QHash<QString,QStringList> &map,
394  QChar c = QLatin1Char('%') );
395 
402  KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QChar,QStringList> &map,
403  QChar c = QLatin1Char('%') );
404  KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash<QString,QStringList> &map,
405  QChar c = QLatin1Char('%') );
406 }
407 
408 #endif /* KMACROEXPANDER_H */
KMacroExpanderBase
Abstract base class for the worker classes behind the KMacroExpander namespace and the KCharMacroExpa...
Definition: kmacroexpander.h:41
kdecore_export.h
KWordMacroExpander::KWordMacroExpander
KWordMacroExpander(QChar c=QLatin1Char('%'))
Constructor.
Definition: kmacroexpander.h:224
QChar
KMacroExpanderBase::expandEscapedMacro
virtual int expandEscapedMacro(const QString &str, int pos, QStringList &ret)
This function is called every time the escape char is found if it is not QChar::null.
Definition: kmacroexpander.cpp:91
KMacroExpanderBasePrivate
Definition: kmacroexpander_p.h:27
QHash
Definition: ksycocafactory.h:28
KMacroExpanderBase::expandPlainMacro
virtual int expandPlainMacro(const QString &str, int pos, QStringList &ret)
This function is called for every single char within the string if the escape char is QChar::null...
Definition: kmacroexpander.cpp:88
QString
QStringList
KMacroExpander::expandMacros
QString expandMacros(const QString &ostr, const QHash< QChar, QString > &map, QChar c)
Perform safe macro expansion (substitution) on a string.
Definition: kmacroexpander.cpp:340
QLatin1Char
KMacroExpander::expandMacrosShellQuote
QString expandMacrosShellQuote(const QString &ostr, const QHash< QChar, QString > &map, QChar c)
Perform safe macro expansion (substitution) on a string for use in shell commands.
Definition: kmacroexpander.cpp:342
KWordMacroExpander
Abstract base class for simple word macro substitutors.
Definition: kmacroexpander.h:217
KCharMacroExpander
Abstract base class for single char macro substitutors.
Definition: kmacroexpander.h:253
KCharMacroExpander::KCharMacroExpander
KCharMacroExpander(QChar c=QLatin1Char('%'))
Constructor.
Definition: kmacroexpander.h:260
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal