Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KMacroExpanderBase Class Reference

#include <kmacroexpander.h>

List of all members.

Public Methods

 KMacroExpanderBase (QChar c= '%')
virtual ~KMacroExpanderBase ()
void expandMacros (QString &str)
bool expandMacrosShellQuote (QString &str)
void setEscapeChar (QChar c)
QChar escapeChar () const

Protected Methods

virtual int expandPlainMacro (const QString &str, uint pos, QStringList &ret)
virtual int expandEscapedMacro (const QString &str, uint pos, QStringList &ret)


Detailed Description

Abstract base class for the worker classes behind the KMacroExpander namespace.

Definition at line 36 of file kmacroexpander.h.


Constructor & Destructor Documentation

KMacroExpanderBase::KMacroExpanderBase QChar    c = '%'
 

Constructor.

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

virtual KMacroExpanderBase::~KMacroExpanderBase   [virtual]
 

Destructor.


Member Function Documentation

QChar KMacroExpanderBase::escapeChar  
 

Obtain the macro escape character.

Returns:
escape char indicating start of macros, or QChar::null if none

virtual int KMacroExpanderBase::expandEscapedMacro const QString &    str,
uint    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 occurence of the escape char
ret  return value: the string to substitute for the macro
Returns:
if greater than zero, the number of chars at pos in str to substitute with ret (i.e., a valid macro was found). if less than zero, subtract this value from pos (to skip a macro, i.e., substitute it with itself). zero requests no special action.

void KMacroExpanderBase::expandMacros QString &    str
 

Perform safe macro expansion (substitution) on a string.

Parameters:
str  the string in which macros are expanded in-place

bool KMacroExpanderBase::expandMacrosShellQuote QString &    str
 

Same as above, but always starts at position 0, and unmatched closing parens and braces are treated as errors.

virtual int KMacroExpanderBase::expandPlainMacro const QString &    str,
uint    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 in str to substitute with ret (i.e., a valid macro was found). if less than zero, subtract this value from pos (to skip a macro, i.e., substitute it with itself). zero requests no special action.

void KMacroExpanderBase::setEscapeChar QChar    c
 

Set the macro escape character.

Parameters:
c  escape char indicating start of macros, or QChar::null if none


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:18 2003 for kdelibs by doxygen1.2.18