• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KDECore

Public Member Functions | Protected Member Functions

KWordMacroExpander Class Reference

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

#include <KMacroExpanderBase>

Inheritance diagram for KWordMacroExpander:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 KWordMacroExpander (QChar c=QLatin1Char('%'))

Protected Member Functions

virtual int expandEscapedMacro (const QString &str, int pos, QStringList &ret)
virtual bool expandMacro (const QString &str, QStringList &ret)=0
virtual int expandPlainMacro (const QString &str, int pos, QStringList &ret)

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:
     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 );
   ...
 }

Alternatively MyClass could inherit from KWordMacroExpander directly.

Author:
Oswald Buddenhagen <ossi@kde.org>

Definition at line 217 of file kmacroexpander.h.


Constructor & Destructor Documentation

KWordMacroExpander::KWordMacroExpander ( QChar  c = QLatin1Char('%')) [inline, explicit]

Constructor.

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

Definition at line 224 of file kmacroexpander.h.


Member Function Documentation

int KWordMacroExpander::expandEscapedMacro ( const QString &  str,
int  pos,
QStringList &  ret 
) [protected, virtual]

Not to be called or reimplemented.

Reimplemented from KMacroExpanderBase.

Definition at line 285 of file kmacroexpander.cpp.

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

Return substitution list ret for string macro str.

Parameters:
strthe macro to expand
retreturn 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 QString &  str,
int  pos,
QStringList &  ret 
) [protected, virtual]

Not to be called or reimplemented.

Reimplemented from KMacroExpanderBase.

Definition at line 270 of file kmacroexpander.cpp.


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

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal