kdecore Library API Documentation

KMacroExpanderBase Class Reference

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

#include <kmacroexpander.h>

List of all members.

Public Member Functions

 KMacroExpanderBase (QChar c= '%')
 Constructor.

virtual ~KMacroExpanderBase ()
 Destructor.

void expandMacros (QString &str)
 Perform safe macro expansion (substitution) on a string.

bool expandMacrosShellQuote (QString &str, uint &pos)
bool expandMacrosShellQuote (QString &str)
 Same as above, but always starts at position 0, and unmatched closing parens and braces are treated as errors.

void setEscapeChar (QChar c)
 Set the macro escape character.

QChar escapeChar () const
 Obtain the macro escape character.


Protected Member Functions

virtual int expandPlainMacro (const QString &str, uint pos, QStringList &ret)
 This function is called for every single char within the string if the escape char is QChar::null.

virtual int expandEscapedMacro (const QString &str, uint pos, QStringList &ret)
 This function is called every time the escape char is found if it is not QChar::null.


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

Definition at line 28 of file kmacroexpander.cpp.

KMacroExpanderBase::~KMacroExpanderBase  )  [virtual]
 

Destructor.

Definition at line 33 of file kmacroexpander.cpp.


Member Function Documentation

void KMacroExpanderBase::expandMacros QString str  ) 
 

Perform safe macro expansion (substitution) on a string.

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

Definition at line 49 of file kmacroexpander.cpp.

References expandEscapedMacro(), expandPlainMacro(), QStringList::join(), QString::length(), QString::replace(), and QString::unicode().

bool KMacroExpanderBase::expandMacrosShellQuote QString str  ) 
 

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

Definition at line 280 of file kmacroexpander.cpp.

References QString::length().

void KMacroExpanderBase::setEscapeChar QChar  c  ) 
 

Set the macro escape character.

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

Definition at line 38 of file kmacroexpander.cpp.

QChar KMacroExpanderBase::escapeChar  )  const
 

Obtain the macro escape character.

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

Definition at line 44 of file kmacroexpander.cpp.

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.

Definition at line 286 of file kmacroexpander.cpp.

Referenced by expandMacros().

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.

Definition at line 289 of file kmacroexpander.cpp.

Referenced by expandMacros().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:14:51 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001