#include <kmacroexpander.h>
Public Member Functions | |
KWordMacroExpander (TQChar c='%') | |
Public Member Functions inherited from KMacroExpanderBase | |
KMacroExpanderBase (TQChar c='%') | |
virtual | ~KMacroExpanderBase () |
void | expandMacros (TQString &str) |
bool | expandMacrosShellQuote (TQString &str, uint &pos) |
bool | expandMacrosShellQuote (TQString &str) |
void | setEscapeChar (TQChar c) |
TQChar | escapeChar () const |
Protected Member Functions | |
virtual int | expandPlainMacro (const TQString &str, uint pos, TQStringList &ret) |
virtual int | expandEscapedMacro (const TQString &str, uint pos, TQStringList &ret) |
virtual bool | expandMacro (const TQString &str, TQStringList &ret)=0 |
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:
Alternatively MyClass could inherit from KWordMacroExpander directly.
- Since
- 3.3
Definition at line 191 of file kmacroexpander.h.
Constructor & Destructor Documentation
◆ KWordMacroExpander()
|
inline |
Constructor.
- Parameters
-
c escape char indicating start of macros, or TQChar::null for none
Definition at line 198 of file kmacroexpander.h.
Member Function Documentation
◆ expandEscapedMacro()
|
protectedvirtual |
This function is called every time the escape char is found if it is not TQChar::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). zero requests no special action.
Reimplemented from KMacroExpanderBase.
Definition at line 469 of file kmacroexpander.cpp.
◆ expandMacro()
|
protectedpure virtual |
Return substitution list ret
for string macro str
.
- Parameters
-
str 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
◆ expandPlainMacro()
|
protectedvirtual |
This function is called for every single char within the string if the escape char is TQChar::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). zero requests no special action.
Reimplemented from KMacroExpanderBase.
Definition at line 455 of file kmacroexpander.cpp.
The documentation for this class was generated from the following files: