KDECore
KCharMacroExpander Class Reference
#include <KMacroExpanderBase>

Detailed Description
Abstract base class for single char macro substitutors.Use this instead of the functions in the KMacroExpander namespace if speculatively pre-filling the substitution map would be too expensive.
See KWordMacroExpander for a sample application.
Definition at line 251 of file kmacroexpander.h.
Public Member Functions | |
KCharMacroExpander (QChar c=QLatin1Char('%')) | |
Protected Member Functions | |
virtual int | expandEscapedMacro (const QString &str, int pos, QStringList &ret) |
virtual bool | expandMacro (QChar chr, QStringList &ret)=0 |
virtual int | expandPlainMacro (const QString &str, int pos, QStringList &ret) |
Constructor & Destructor Documentation
KCharMacroExpander::KCharMacroExpander | ( | QChar | c = QLatin1Char('%') |
) | [inline, explicit] |
Constructor.
- Parameters:
-
c escape char indicating start of macros, or QChar::null for none
Definition at line 258 of file kmacroexpander.h.
Member Function Documentation
int KCharMacroExpander::expandEscapedMacro | ( | const QString & | str, | |
int | pos, | |||
QStringList & | ret | |||
) | [protected, virtual] |
This function is called every time the escape char is found if it is not QChar::null.
It should determine whether the string starting at pos
witin str
is a valid macro and return the substitution value for it if so.
- Parameters:
-
str the input string pos the offset within str
. Note that this is the position of the occurrence of the escape charret return value: the string to substitute for the macro
- Returns:
- If greater than zero, the number of chars at
pos
instr
to substitute withret
(i.e., a valid macro was found). If less than zero, subtract this value frompos
(to skip a macro, i.e., substitute it with itself). If zero, scanning continues as if no escape char was encountered at all.
Reimplemented from KMacroExpanderBase.
Definition at line 258 of file kmacroexpander.cpp.
virtual bool KCharMacroExpander::expandMacro | ( | QChar | chr, | |
QStringList & | ret | |||
) | [protected, pure virtual] |
Return substitution list ret
for single-character macro chr
.
- Parameters:
-
chr the macro to expand ret return variable reference. It is guaranteed to be empty when expandMacro is entered.
- Returns:
true
iffchr
was a recognized macro name
int KCharMacroExpander::expandPlainMacro | ( | const QString & | str, | |
int | pos, | |||
QStringList & | ret | |||
) | [protected, virtual] |
This function is called for every single char within the string if the escape char is QChar::null.
It should determine whether the string starting at pos
within str
is a valid macro and return the substitution value for it if so.
- Parameters:
-
str the input string pos the offset within str
ret return value: the string to substitute for the macro
- Returns:
- If greater than zero, the number of chars at
pos
instr
to substitute withret
(i.e., a valid macro was found). If less than zero, subtract this value frompos
(to skip a macro, i.e., substitute it with itself). If zero, no macro starts atpos
.
Reimplemented from KMacroExpanderBase.
Definition at line 250 of file kmacroexpander.cpp.
The documentation for this class was generated from the following files: