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

KDECore

  • 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
28class QString;
29class QStringList;
30template <typename KT, typename VT> class QHash;
31class KMacroExpanderBasePrivate;
32
41class KDECORE_EXPORT KMacroExpanderBase {
42
43public:
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
130protected:
144 virtual int expandPlainMacro( const QString &str, int pos, QStringList &ret );
145
161 virtual int expandEscapedMacro( const QString &str, int pos, QStringList &ret );
162
163private:
164 KMacroExpanderBasePrivate * const d;
165};
166
217class KDECORE_EXPORT KWordMacroExpander : public KMacroExpanderBase {
218
219public:
224 explicit KWordMacroExpander( QChar c = QLatin1Char('%') ) : KMacroExpanderBase( c ) {}
225
226protected:
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
253class KDECORE_EXPORT KCharMacroExpander : public KMacroExpanderBase {
254
255public:
260 explicit KCharMacroExpander( QChar c = QLatin1Char('%') ) : KMacroExpanderBase( c ) {}
261
262protected:
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
282namespace 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 */
KCharMacroExpander
Abstract base class for single char macro substitutors.
Definition: kmacroexpander.h:253
KCharMacroExpander::KCharMacroExpander
KCharMacroExpander(QChar c=QLatin1Char('%'))
Constructor.
Definition: kmacroexpander.h:260
KCharMacroExpander::expandMacro
virtual bool expandMacro(QChar chr, QStringList &ret)=0
Return substitution list ret for single-character macro chr.
KMacroExpanderBasePrivate
Definition: kmacroexpander_p.h:28
KMacroExpanderBase
Abstract base class for the worker classes behind the KMacroExpander namespace and the KCharMacroExpa...
Definition: kmacroexpander.h:41
KWordMacroExpander
Abstract base class for simple word macro substitutors.
Definition: kmacroexpander.h:217
KWordMacroExpander::KWordMacroExpander
KWordMacroExpander(QChar c=QLatin1Char('%'))
Constructor.
Definition: kmacroexpander.h:224
KWordMacroExpander::expandMacro
virtual bool expandMacro(const QString &str, QStringList &ret)=0
Return substitution list ret for string macro str.
QHash
Definition: ksycocafactory.h:28
QStringList
QString
kdecore_export.h
KMacroExpander
A group of functions providing macro expansion (substitution) in strings, optionally with quoting app...
Definition: kmacroexpander.cpp:338
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
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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