class KMacroExpanderBase

# class KMacroExpanderBase | Abstract base class for the worker classes behind the KMacroExpander namespace. More...
Internal Use Only
Definition | `#include <kmacroexpander.h>`
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- KMacroExpanderBase ( QChar c = '%' )
- virtual ~KMacroExpanderBase ()
- void expandMacros ( QString &str )
- bool expandMacrosShellQuote ( QString &str, uint &pos )
- 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.

KMacroExpanderBase ( QChar c = '%' ) | ### KMacroExpanderBase

Constructor.

Parameters:

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

~KMacroExpanderBase () | ### ~KMacroExpanderBase

[virtual]

Destructor.

void expandMacros ( QString &str ) | ### expandMacros

Perform safe macro expansion (substitution) on a string.

Parameters:

str | the string in which macros are expanded in-place

bool expandMacrosShellQuote ( QString &str, uint &pos ) | ### expandMacrosShellQuote

bool expandMacrosShellQuote ( QString &str ) | ### expandMacrosShellQuote

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

void setEscapeChar ( QChar c ) | ### setEscapeChar

Set the macro escape character.

Parameters:

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

QChar escapeChar () | ### escapeChar

[const]

Obtain the macro escape character.

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

int expandPlainMacro ( const QString &str, uint pos, QStringList &ret ) | ### expandPlainMacro

[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.

int expandEscapedMacro ( const QString &str, uint pos, QStringList &ret ) | ### expandEscapedMacro

[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.

- Author: Oswald Buddenhagen
- Generated: root on macppc.ports.openbsd.org on Sat Sep 6 10:36:15 2003, using kdoc 2.0a54.