KWordMacroExpander

Search for usage in LXR

KWordMacroExpander Class Referenceabstract

#include <KMacroExpanderBase>

Inheritance diagram for KWordMacroExpander:

Public Member Functions

 KWordMacroExpander (QChar c=QLatin1Char('%'))
 
- Public Member Functions inherited from KMacroExpanderBase
 KMacroExpanderBase (QChar c=QLatin1Char('%'))
 
virtual ~KMacroExpanderBase ()
 
QChar escapeChar () const
 
void expandMacros (QString &str)
 
bool expandMacrosShellQuote (QString &str)
 
bool expandMacrosShellQuote (QString &str, int &pos)
 
void setEscapeChar (QChar c)
 

Protected Member Functions

int expandEscapedMacro (const QString &str, int pos, QStringList &ret) override
 
virtual bool expandMacro (const QString &str, QStringList &ret)=0
 
int expandPlainMacro (const QString &str, int pos, QStringList &ret) override
 
- Protected Member Functions inherited from KMacroExpanderBase

Detailed Description

Abstract base class for simple word macro substitutors.

Use this instead of the functions in the KMacroExpander namespace if speculatively pre-filling the substitution map would be too expensive.

A typical application:

class MyClass {
...
private:
QString m_str;
...
friend class MyExpander;
};
class MyExpander : public KWordMacroExpander {
public:
MyExpander( MyClass *_that ) : KWordMacroExpander(), that( _that ) {}
protected:
virtual bool expandMacro( const QString &str, QStringList &ret );
private:
MyClass *that;
};
bool MyExpander::expandMacro( const QString &str, QStringList &ret )
{
if (str == "macro") {
ret += complexOperation( that->m_str );
return true;
}
return false;
}
... MyClass::...(...)
{
QString str;
...
MyExpander mx( this );
mx.expandMacrosShellQuote( str );
...
}
Abstract base class for simple word macro substitutors.
virtual bool expandMacro(const QString &str, QStringList &ret)=0
Return substitution list ret for string macro str.

Alternatively MyClass could inherit from KWordMacroExpander directly.

Author
Oswald Buddenhagen ossi@.nosp@m.kde..nosp@m.org

Definition at line 207 of file kmacroexpander.h.

Constructor & Destructor Documentation

◆ KWordMacroExpander()

KWordMacroExpander::KWordMacroExpander ( QChar c = QLatin1Char('%'))
inlineexplicit

Constructor.

Parameters
cescape char indicating start of macros, or QChar::null for none

Definition at line 214 of file kmacroexpander.h.

Member Function Documentation

◆ expandEscapedMacro()

int KWordMacroExpander::expandEscapedMacro ( const QString & str,
int pos,
QStringList & ret )
overrideprotectedvirtual

Not to be called or reimplemented.

Reimplemented from KMacroExpanderBase.

Definition at line 284 of file kmacroexpander.cpp.

◆ expandMacro()

virtual bool KWordMacroExpander::expandMacro ( const QString & str,
QStringList & ret )
protectedpure virtual

Return substitution list ret for string macro str.

Parameters
strthe macro to expand
retreturn variable reference. It is guaranteed to be empty when expandMacro is entered.
Returns
true iff str was a recognized macro name

◆ expandPlainMacro()

int KWordMacroExpander::expandPlainMacro ( const QString & str,
int pos,
QStringList & ret )
overrideprotectedvirtual

Not to be called or reimplemented.

Reimplemented from KMacroExpanderBase.

Definition at line 266 of file kmacroexpander.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.