\section{KWord\-Macro\-Expander Class Reference}
\label{classKWordMacroExpander}\index{KWordMacroExpander@{KWordMacroExpander}}
Abstract base class for simple word macro substitutors.  


{\tt \#include $<$kmacroexpander.h$>$}

Inheritance diagram for KWord\-Macro\-Expander:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=76pt]{classKWordMacroExpander__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KWord\-Macro\-Expander:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=76pt]{classKWordMacroExpander__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KWord\-Macro\-Expander} ({\bf QChar} c= '\%')
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual int {\bf expand\-Plain\-Macro} (const {\bf QString} \&str, uint pos, {\bf QString\-List} \&ret)
\item 
virtual int {\bf expand\-Escaped\-Macro} (const {\bf QString} \&str, uint pos, {\bf QString\-List} \&ret)
\item 
virtual bool {\bf expand\-Macro} (const {\bf QString} \&str, {\bf QString\-List} \&ret)=0
\end{CompactItemize}


\subsection{Detailed Description}
Abstract base class for simple word macro substitutors. 

Use this instead of the functions in the {\bf KMacro\-Expander}{\rm (p.\,\pageref{namespaceKMacroExpander})} namespace if speculatively pre-filling the substitution map would be too expensive.

A typical application:



\footnotesize\begin{verbatim} 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 );
   ...
 }
\end{verbatim}
\normalsize


Alternatively My\-Class could inherit from KWord\-Macro\-Expander directly.

\begin{Desc}
\item[Since:]3.3 \end{Desc}
\begin{Desc}
\item[Author:]Oswald Buddenhagen $<${\tt ossi@kde.org}$>$ \end{Desc}




Definition at line 191 of file kmacroexpander.h.

\subsection{Constructor \& Destructor Documentation}
\index{KWordMacroExpander@{KWord\-Macro\-Expander}!KWordMacroExpander@{KWordMacroExpander}}
\index{KWordMacroExpander@{KWordMacroExpander}!KWordMacroExpander@{KWord\-Macro\-Expander}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KWord\-Macro\-Expander::KWord\-Macro\-Expander ({\bf QChar} {\em c} = {\tt '\%'})\hspace{0.3cm}{\tt  [inline]}}\label{classKWordMacroExpander_a0}


Constructor. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em c}]escape char indicating start of macros, or QChar::null for none \end{description}
\end{Desc}


Definition at line 198 of file kmacroexpander.h.

\subsection{Member Function Documentation}
\index{KWordMacroExpander@{KWord\-Macro\-Expander}!expandPlainMacro@{expandPlainMacro}}
\index{expandPlainMacro@{expandPlainMacro}!KWordMacroExpander@{KWord\-Macro\-Expander}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KWord\-Macro\-Expander::expand\-Plain\-Macro (const {\bf QString} \& {\em str}, uint {\em pos}, {\bf QString\-List} \& {\em ret})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKWordMacroExpander_b0}


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 {\tt pos} within {\tt str} is a valid macro and return the substitution value for it if so. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em str}]the input string \item[{\em pos}]the offset within {\tt str} \item[{\em ret}]return value: the string to substitute for the macro \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]if greater than zero, the number of chars at {\tt pos} in {\tt str} to substitute with {\tt ret} (i.e., a valid macro was found). if less than zero, subtract this value from {\tt pos} (to skip a macro, i.e., substitute it with itself). zero requests no special action. \end{Desc}


Reimplemented from {\bf KMacro\-Expander\-Base} {\rm (p.\,\pageref{classKMacroExpanderBase_b0})}.

Definition at line 454 of file kmacroexpander.cpp.

References expand\-Macro().\index{KWordMacroExpander@{KWord\-Macro\-Expander}!expandEscapedMacro@{expandEscapedMacro}}
\index{expandEscapedMacro@{expandEscapedMacro}!KWordMacroExpander@{KWord\-Macro\-Expander}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int KWord\-Macro\-Expander::expand\-Escaped\-Macro (const {\bf QString} \& {\em str}, uint {\em pos}, {\bf QString\-List} \& {\em ret})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKWordMacroExpander_b1}


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 {\tt pos} witin {\tt str} is a valid macro and return the substitution value for it if so. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em str}]the input string \item[{\em pos}]the offset within {\tt str}. Note that this is the position of the occurrence of the escape char \item[{\em ret}]return value: the string to substitute for the macro \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]if greater than zero, the number of chars at {\tt pos} in {\tt str} to substitute with {\tt ret} (i.e., a valid macro was found). if less than zero, subtract this value from {\tt pos} (to skip a macro, i.e., substitute it with itself). zero requests no special action. \end{Desc}


Reimplemented from {\bf KMacro\-Expander\-Base} {\rm (p.\,\pageref{classKMacroExpanderBase_b1})}.

Definition at line 468 of file kmacroexpander.cpp.

References KMacro\-Expander\-Base::escape\-Char(), and expand\-Macro().\index{KWordMacroExpander@{KWord\-Macro\-Expander}!expandMacro@{expandMacro}}
\index{expandMacro@{expandMacro}!KWordMacroExpander@{KWord\-Macro\-Expander}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual bool KWord\-Macro\-Expander::expand\-Macro (const {\bf QString} \& {\em str}, {\bf QString\-List} \& {\em ret})\hspace{0.3cm}{\tt  [protected, pure virtual]}}\label{classKWordMacroExpander_b2}


Return substitution list {\tt ret} for string macro {\tt str}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em str}]the macro to expand \item[{\em ret}]return variable reference. It is guaranteed to be empty when expand\-Macro is entered. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]{\tt true} iff {\tt chr} was a recognized macro name \end{Desc}


Referenced by expand\-Escaped\-Macro(), and expand\-Plain\-Macro().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
kmacroexpander.h\item 
kmacroexpander.cpp\end{CompactItemize}
