• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Public Member Functions | Protected Member Functions

KWordMacroExpander Class Reference

Abstract base class for simple word macro substitutors. More...

#include <kmacroexpander.h>

Inheritance diagram for KWordMacroExpander:
KMacroExpanderBase

List of all members.

Public Member Functions

 KWordMacroExpander (TQChar c= '%')

Protected Member Functions

virtual int expandPlainMacro (const TQString &str, uint pos, TQStringList &ret)
virtual int expandEscapedMacro (const TQString &str, uint pos, TQStringList &ret)
virtual bool expandMacro (const TQString &str, TQStringList &ret)=0

Detailed Description

Abstract base class for simple word macro substitutors.

Use this instead of the functions in the KMacroExpander namespace if speculatively pre-filling the substitution map would be too expensive.

A typical application:

 class MyClass {
 ...
   private:
     TQString m_str;
 ...
   friend class MyExpander;
 };

 class MyExpander : public KWordMacroExpander {
   public:
     MyExpander( MyClass *_that ) : KWordMacroExpander(), that( _that ) {}
   protected:
     virtual bool expandMacro( const TQString &str, TQStringList &ret );
   private:
     MyClass *that;
 };

 bool MyExpander::expandMacro( const TQString &str, TQStringList &ret )
 {
   if (str == "macro") {
     ret += complexOperation( that->m_str );
     return true;
   }
   return false;
 }

 ... MyClass::...(...)
 {
   TQString str;
   ...
   MyExpander mx( this );
   mx.expandMacrosShellQuote( str );
   ...
 }

Alternatively MyClass could inherit from KWordMacroExpander directly.

Since:
3.3
Author:
Oswald Buddenhagen <ossi@kde.org>

Definition at line 191 of file kmacroexpander.h.


Constructor & Destructor Documentation

KWordMacroExpander::KWordMacroExpander ( TQChar  c = '%'  )  [inline]

Constructor.

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

Definition at line 198 of file kmacroexpander.h.


Member Function Documentation

int KWordMacroExpander::expandEscapedMacro ( const TQString &  str,
uint  pos,
TQStringList &  ret 
) [protected, virtual]

This function is called every time the escape char is found if it is not TQChar::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 occurrence 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.

Reimplemented from KMacroExpanderBase.

Definition at line 469 of file kmacroexpander.cpp.

virtual bool KWordMacroExpander::expandMacro ( const TQString &  str,
TQStringList &  ret 
) [protected, pure virtual]

Return substitution list ret for string macro str.

Parameters:
str the macro to expand
ret return variable reference. It is guaranteed to be empty when expandMacro is entered.
Returns:
true iff chr was a recognized macro name
int KWordMacroExpander::expandPlainMacro ( const TQString &  str,
uint  pos,
TQStringList &  ret 
) [protected, virtual]

This function is called for every single char within the string if the escape char is TQChar::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.

Reimplemented from KMacroExpanderBase.

Definition at line 455 of file kmacroexpander.cpp.


The documentation for this class was generated from the following files:
  • kmacroexpander.h
  • kmacroexpander.cpp

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.7.1
This website is maintained by Timothy Pearson.