.TH "KWordMacroExpander" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KWordMacroExpander \- Abstract base class for simple word macro substitutors.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kmacroexpander.h>\fP
.PP
Inherits \fBKMacroExpanderBase\fP.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKWordMacroExpander\fP (\fBQChar\fP c= '%')"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual int \fBexpandPlainMacro\fP (const \fBQString\fP &str, uint pos, \fBQStringList\fP &ret)"
.br
.ti -1c
.RI "virtual int \fBexpandEscapedMacro\fP (const \fBQString\fP &str, uint pos, \fBQStringList\fP &ret)"
.br
.ti -1c
.RI "virtual bool \fBexpandMacro\fP (const \fBQString\fP &str, \fBQStringList\fP &ret)=0"
.br
.in -1c
.SH "Detailed Description"
.PP 
Abstract base class for simple word macro substitutors. 

Use this instead of the functions in the \fBKMacroExpander\fP namespace if speculatively pre-filling the substitution map would be too expensive.
.PP
A typical application:
.PP
.PP
.nf
 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 );
   ...
 }
.fi
.PP
.PP
Alternatively MyClass could inherit from KWordMacroExpander directly.
.PP
\fBSince:\fP
.RS 4
3.3 
.RE
.PP
\fBAuthor:\fP
.RS 4
Oswald Buddenhagen <ossi@kde.org> 
.RE
.PP

.PP
Definition at line 191 of file kmacroexpander.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KWordMacroExpander::KWordMacroExpander (\fBQChar\fP c = \fC'%'\fP)\fC [inline]\fP"
.PP
Constructor. 
.PP
\fBParameters:\fP
.RS 4
\fIc\fP escape char indicating start of macros, or QChar::null for none 
.RE
.PP

.PP
Definition at line 198 of file kmacroexpander.h.
.SH "Member Function Documentation"
.PP 
.SS "int KWordMacroExpander::expandPlainMacro (const \fBQString\fP & str, uint pos, \fBQStringList\fP & ret)\fC [protected, virtual]\fP"
.PP
This function is called for every single char within the string if the escape char is QChar::null. 
.PP
It should determine whether the string starting at \fCpos\fP within \fCstr\fP is a valid macro and return the substitution value for it if so. 
.PP
\fBParameters:\fP
.RS 4
\fIstr\fP the input string 
.br
\fIpos\fP the offset within \fCstr\fP 
.br
\fIret\fP return value: the string to substitute for the macro 
.RE
.PP
\fBReturns:\fP
.RS 4
if greater than zero, the number of chars at \fCpos\fP in \fCstr\fP to substitute with \fCret\fP (i.e., a valid macro was found). if less than zero, subtract this value from \fCpos\fP (to skip a macro, i.e., substitute it with itself). zero requests no special action. 
.RE
.PP

.PP
Reimplemented from \fBKMacroExpanderBase\fP.
.PP
Definition at line 454 of file kmacroexpander.cpp.
.PP
References expandMacro().
.SS "int KWordMacroExpander::expandEscapedMacro (const \fBQString\fP & str, uint pos, \fBQStringList\fP & ret)\fC [protected, virtual]\fP"
.PP
This function is called every time the escape char is found if it is not QChar::null. 
.PP
It should determine whether the string starting at \fCpos\fP witin \fCstr\fP is a valid macro and return the substitution value for it if so. 
.PP
\fBParameters:\fP
.RS 4
\fIstr\fP the input string 
.br
\fIpos\fP the offset within \fCstr\fP. Note that this is the position of the occurrence of the escape char 
.br
\fIret\fP return value: the string to substitute for the macro 
.RE
.PP
\fBReturns:\fP
.RS 4
if greater than zero, the number of chars at \fCpos\fP in \fCstr\fP to substitute with \fCret\fP (i.e., a valid macro was found). if less than zero, subtract this value from \fCpos\fP (to skip a macro, i.e., substitute it with itself). zero requests no special action. 
.RE
.PP

.PP
Reimplemented from \fBKMacroExpanderBase\fP.
.PP
Definition at line 468 of file kmacroexpander.cpp.
.PP
References KMacroExpanderBase::escapeChar(), and expandMacro().
.SS "virtual bool KWordMacroExpander::expandMacro (const \fBQString\fP & str, \fBQStringList\fP & ret)\fC [protected, pure virtual]\fP"
.PP
Return substitution list \fCret\fP for string macro \fCstr\fP. 
.PP
\fBParameters:\fP
.RS 4
\fIstr\fP the macro to expand 
.br
\fIret\fP return variable reference. It is guaranteed to be empty when expandMacro is entered. 
.RE
.PP
\fBReturns:\fP
.RS 4
\fCtrue\fP iff \fCchr\fP was a recognized macro name 
.RE
.PP

.PP
Referenced by expandEscapedMacro(), and expandPlainMacro().

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
