Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SWModule Class Reference

The class SWModule is the base class for all modules used in Sword. More...

#include <swmodule.h>

Inheritance diagram for SWModule::

SWCom SWLD SWText List of all members.

Public Methods

 SWModule (const char *imodname=0, const char *imoddesc=0, SWDisplay *idisp=0, char *imodtype=0, SWTextEncoding encoding=ENC_UNKNOWN, SWTextDirection dir=DIRECTION_LTR, SWTextMarkup markup=FMT_UNKNOWN, const char *modlang=0)
 Initializes data for instance of SWModule. More...

virtual ~SWModule ()
 Cleans up instance of SWModule.

virtual char Error ()
 Gets and clears error status. More...

virtual const bool isUnicode () const
virtual const int getEntrySize () const
virtual char SetKey (const SWKey *ikey)
 Sets a key to this module for position to a particular record or set of records. More...

virtual char SetKey (const SWKey &ikey)
 Sets the key of this module. More...

virtual SWKeyKey () const
 Gets the current module key. More...

virtual char Key (const SWKey &ikey)
 Sets the current key of the module to ikey, and returns the keytext. More...

virtual const char * KeyText (const char *imodtype=0)
 Sets/gets module KeyText. More...

virtual char Display ()
 Calls this modules display object and passes itself. More...

virtual SWDisplayDisp (SWDisplay *idisp=0)
 Sets/gets display driver. More...

virtual char * Name (const char *imodname=0)
 Sets/gets module name. More...

virtual char * Description (const char *imoddesc=0)
 Sets/gets module description. More...

virtual char * Type (const char *imodtype=0)
 Sets/gets module type. More...

virtual char Direction (signed char newdir=-1)
 Sets/gets module direction. More...

virtual char Encoding (signed char enc=-1)
 Sets/gets module encoding. More...

virtual char Markup (signed char enc=-1)
 Sets/gets module markup. More...

virtual char * Lang (const char *imodlang=0)
 Sets/gets module language. More...

virtual ListKeySearch (const char *istr, int searchType=0, int flags=0, SWKey *scope=0, bool *justCheckIfSupported=0, void(*percent)(char, void *)=&nullPercent, void *percentUserData=0)
 Searches a module for a string. More...

virtual signed char createSearchFramework ()
virtual bool hasSearchFramework ()
virtual bool isSearchOptimallySupported (const char *istr, int searchType, int flags, SWKey *scope)
 Check if the search is optimally supported (e.g. More...

virtual SWKeyCreateKey ()
 Allocates a key of specific type for module The different reimplementatiosn of SWModule (e.g. More...

virtual operator char * ()
 Renders and returns the current module text. More...

virtual char * getRawEntry ()=0
 This function is reimplemented by the different kinds of module objects. More...

virtual operator SWKey & ()
 Cast operator to cast to a SWKey reference. More...

virtual operator SWKey * ()
 Operator to cast to an SWKey pointer. More...

virtual bool isWritable ()
 Is the module writable? :). More...

virtual SWModule & setentry (const char *inbuf, long len)
 Modify the current module entry text only if module isWritable. More...

virtual SWModule & operator<< (const char *)
 Modify the current module entry text only if module isWritable. More...

virtual SWModule & operator<< (const SWKey *)
 Link the current module entry to another module entry only if module isWritable. More...

virtual void deleteEntry ()
 Delete current module entry - only if module isWritable.

virtual SWModule & operator-= (int decrement)
 Decrements module key a number of entries. More...

virtual SWModule & operator+= (int increment)
 Increments module key a number of entries. More...

virtual SWModule & operator++ (int)
 Increments module key by 1 entry.

virtual SWModule & operator-- (int)
 Decrements module key by 1 entry.

virtual SWModule & operator= (SW_POSITION p)
 Positions this modules to an entry. More...

virtual SWModule & AddRenderFilter (SWFilter *newfilter)
 Adds a RenderFilter to this module's. More...

virtual SWModule & RemoveRenderFilter (SWFilter *oldfilter)
 Removes a RenderFilter from this module's. More...

virtual SWModule & ReplaceRenderFilter (SWFilter *oldfilter, SWFilter *newfilter)
 Replaces a RenderFilter in this module's. More...

virtual void renderFilter (char *buf, long size, SWKey *key)
 RenderFilter a text buffer. More...

virtual SWModule & AddEncodingFilter (SWFilter *newfilter)
 Adds an EncodingFilter to this module's. More...

virtual SWModule & RemoveEncodingFilter (SWFilter *oldfilter)
 Removes an EncodingFilter from this module's. More...

virtual SWModule & ReplaceEncodingFilter (SWFilter *oldfilter, SWFilter *newfilter)
 Replaces an EncodingFilter in this module's. More...

virtual void encodingFilter (char *buf, long size, SWKey *key)
 encodingFilter a text buffer. More...

virtual SWModule & AddStripFilter (SWFilter *newfilter)
 Adds a StripFilter to this module's stripfilters queue. More...

virtual void stripFilter (char *buf, long size, SWKey *key)
 StripFilter a text buffer. More...

virtual SWModule & AddRawFilter (SWFilter *newfilter)
 Adds a RawFilter to this module's rawfilters queue. More...

virtual void filterBuffer (FilterList *filters, char *buf, long size, SWKey *key)
 FilterBuffer a text buffer. More...

virtual void rawFilter (char *buf, long size, SWKey *key)
 RawFilter a text buffer. More...

virtual SWModule & AddOptionFilter (SWFilter *newfilter)
 Adds an OptionFilter to this module's optionfilters queue. More...

virtual void optionFilter (char *buf, long size, SWKey *key)
 OptionFilter a text buffer. More...

virtual const char * StripText (char *buf=0, int len=-1)
 calls all StripFilters on buffer or current text. More...

virtual const char * RenderText (char *buf=0, int len=-1)
 calls all RenderFilters on buffer or current text. More...

virtual const char * StripText (SWKey *tmpKey)
 calls all StripFilters on current text. More...

virtual const char * RenderText (SWKey *tmpKey)
 calls all RenderFilters on current text. More...


Static Public Methods

void nullPercent (char percent, void *userData)
 This is the default callback function for searching. More...

signed char createModule (const char *)
 Creates a new module. More...


Public Attributes

bool terminateSearch
 Set this bool to false to terminate the search which is executed by this module (Search). More...


Protected Attributes

char error
SWKeykey
 the current key.

ListKey listkey
char * modname
char * moddesc
char * modtype
char * modlang
char direction
char markup
char encoding
SWDisplaydisp
 this module's display object.

char * entrybuf
FilterList * stripFilters
 executed to remove all markup (for searches).

FilterList * rawFilters
 executed immediately upon fileread.

FilterList * renderFilters
 executed to format for display.

FilterList * optionFilters
 executed to change markup to user prefs.

FilterList * encodingFilters
 executed to decode text for display.

bool render
int entrySize

Static Protected Attributes

SWDisplay rawdisp

Detailed Description

The class SWModule is the base class for all modules used in Sword.

It provides functions to look up a text passage, to search in the module, to switch on/off the state of optional things like Strong's numbers or footnotes.

SWModule has also functions to write to the data files. This might be useful in future for frontend authors to support user-created modules.

Definition at line 57 of file swmodule.h.


Constructor & Destructor Documentation

SWModule::SWModule const char * imodname = 0,
const char * imoddesc = 0,
SWDisplay * idisp = 0,
char * imodtype = 0,
SWTextEncoding encoding = ENC_UNKNOWN,
SWTextDirection dir = DIRECTION_LTR,
SWTextMarkup markup = FMT_UNKNOWN,
const char * modlang = 0
 

Initializes data for instance of SWModule.

Parameters:
imodname   Internal name for module; see also Name
imoddesc   Name to display to user for module; see also Description
idisp   Display object to use for displaying see also Disp
imodtype   Type of Module (All modules will be displayed with others of same type under their modtype heading) see also Type


Member Function Documentation

virtual SWModule& SWModule::AddEncodingFilter SWFilter * newfilter [inline, virtual]
 

Adds an EncodingFilter to this module's.

See also:
encodingfilters queue
Parameters:
newfilter   the filter to add
Returns:
*this

Definition at line 430 of file swmodule.h.

virtual SWModule& SWModule::AddOptionFilter SWFilter * newfilter [inline, virtual]
 

Adds an OptionFilter to this module's optionfilters queue.

Parameters:
newfilter   the filter to add
Returns:
*this

Definition at line 515 of file swmodule.h.

virtual SWModule& SWModule::AddRawFilter SWFilter * newfilter [inline, virtual]
 

Adds a RawFilter to this module's rawfilters queue.

Parameters:
newfilter   the filter to add
Returns:
*this

Definition at line 484 of file swmodule.h.

virtual SWModule& SWModule::AddRenderFilter SWFilter * newfilter [inline, virtual]
 

Adds a RenderFilter to this module's.

See also:
renderfilters queue
Parameters:
newfilter   the filter to add
Returns:
*this

Definition at line 393 of file swmodule.h.

virtual SWModule& SWModule::AddStripFilter SWFilter * newfilter [inline, virtual]
 

Adds a StripFilter to this module's stripfilters queue.

Parameters:
newfilter   the filter to add
Returns:
*this

Definition at line 467 of file swmodule.h.

virtual SWKey* SWModule::CreateKey [virtual]
 

Allocates a key of specific type for module The different reimplementatiosn of SWModule (e.g.

SWText) support SWKey implementations, which support special. This functions returns a SWKey object which works with the current implementation of SWModule. For example for the SWText class it returns a VerseKey object.

See also:
VerseKey, ListKey, SWText, SWLD, SWCom
Returns:
pointer to allocated key

Reimplemented in SWCom, SWLD, and SWText.

virtual char* SWModule::Description const char * imoddesc = 0 [virtual]
 

Sets/gets module description.

Parameters:
imoddesc   value which to set moddesc; [0] - only get
Returns:
pointer to moddesc

virtual char SWModule::Direction signed char newdir = -1 [virtual]
 

Sets/gets module direction.

Parameters:
newdir   value which to set direction; [-1] - only get
Returns:
char direction

virtual SWDisplay* SWModule::Disp SWDisplay * idisp = 0 [virtual]
 

Sets/gets display driver.

Parameters:
idisp   value which to set disp; [0] - only get
Returns:
pointer to disp

virtual char SWModule::Display [virtual]
 

Calls this modules display object and passes itself.

Returns:
error status

virtual char SWModule::Encoding signed char enc = -1 [virtual]
 

Sets/gets module encoding.

Parameters:
newdir   value which to set encoding; [-1] - only get
Returns:
char encoding

virtual char SWModule::Error [virtual]
 

Gets and clears error status.

Returns:
error status

virtual char SWModule::Key const SWKey & ikey [inline, virtual]
 

Sets the current key of the module to ikey, and returns the keytext.

Parameters:
ikey   new current key for the module
Returns:
the keytext of the current module key

Definition at line 168 of file swmodule.h.

virtual SWKey& SWModule::Key const [inline, virtual]
 

Gets the current module key.

Returns:
the current key of this module

Definition at line 159 of file swmodule.h.

virtual const char* SWModule::KeyText const char * ikeytext = 0 [virtual]
 

Sets/gets module KeyText.

Parameters:
ikeytext   value which to set keytext; [0] - only get
Returns:
pointer to keytext

Reimplemented in SWLD.

virtual char* SWModule::Lang const char * imodlang = 0 [virtual]
 

Sets/gets module language.

Parameters:
imodlang   value which to set modlang; [0] - only get
Returns:
pointer to modlang

virtual char SWModule::Markup signed char enc = -1 [virtual]
 

Sets/gets module markup.

Parameters:
newdir   value which to set markup; [-1] - only get
Returns:
char markup

virtual char* SWModule::Name const char * imodname = 0 [virtual]
 

Sets/gets module name.

Parameters:
imodname   value which to set modname; [0] - only get
Returns:
pointer to modname

virtual SWModule& SWModule::RemoveEncodingFilter SWFilter * oldfilter [inline, virtual]
 

Removes an EncodingFilter from this module's.

See also:
encodingfilters queue
Parameters:
oldfilter   the filter to remove
Returns:
*this

Definition at line 438 of file swmodule.h.

virtual SWModule& SWModule::RemoveRenderFilter SWFilter * oldfilter [inline, virtual]
 

Removes a RenderFilter from this module's.

See also:
renderfilters queue
Parameters:
oldfilter   the filter to remove
Returns:
*this

Definition at line 401 of file swmodule.h.

virtual const char* SWModule::RenderText SWKey * tmpKey [virtual]
 

calls all RenderFilters on current text.

Parameters:
tmpKey   key to use to grab text
Returns:
this module's text at specified key location massaged by Render filters

virtual const char* SWModule::RenderText char * buf = 0,
int len = -1
[virtual]
 

calls all RenderFilters on buffer or current text.

Parameters:
buf   buffer to Render instead of current module position; if buf is NULL, the current text will be used
len   max len of buf OR current text -- will be applied anyway
Returns:
this module's text at specified key location massaged by Render filters

virtual SWModule& SWModule::ReplaceEncodingFilter SWFilter * oldfilter,
SWFilter * newfilter
[inline, virtual]
 

Replaces an EncodingFilter in this module's.

See also:
encodingfilters queue
Parameters:
oldfilter   the filter to remove
newfilter   the filter to add in its place
Returns:
*this

Definition at line 447 of file swmodule.h.

virtual SWModule& SWModule::ReplaceRenderFilter SWFilter * oldfilter,
SWFilter * newfilter
[inline, virtual]
 

Replaces a RenderFilter in this module's.

See also:
renderfilters queue
Parameters:
oldfilter   the filter to remove
newfilter   the filter to add in its place
Returns:
*this

Definition at line 410 of file swmodule.h.

virtual ListKey& SWModule::Search const char * istr,
int searchType = 0,
int flags = 0,
SWKey * scope = 0,
bool * justCheckIfSupported = 0,
void(* percent)(char, void *) = &nullPercent,
void * percentUserData = 0
[virtual]
 

Searches a module for a string.

Parameters:
istr   string for which to search
searchType   type of search to perform <=0 ->regex; 1->phrase; 2->multiword;
flags   options flags for search
justCheckIfSupported   if set, don't search, only tell if this function supports requested search.

Returns:
listkey set to verses that contain istr

Referenced by isSearchOptimallySupported().

virtual char SWModule::SetKey const SWKey & ikey [virtual]
 

Sets the key of this module.

Similair to

See also:
SetKey(const SWKey*) .
Parameters:
ikey   The SWKey which should be used as new key.
Returns:
Error status

virtual char SWModule::SetKey const SWKey * ikey [virtual]
 

Sets a key to this module for position to a particular record or set of records.

Parameters:
ikey   key with which to set this module
Returns:
error status

Referenced by Key().

virtual const char* SWModule::StripText SWKey * tmpKey [virtual]
 

calls all StripFilters on current text.

Parameters:
tmpKey   key to use to grab text
Returns:
this module's text at specified key location massaged by Strip filters

virtual const char* SWModule::StripText char * buf = 0,
int len = -1
[virtual]
 

calls all StripFilters on buffer or current text.

Parameters:
buf   buf to massage instead of current module position; if buf is NULL, the current text will be used
len   max len of buf OR current text -- will be applied anyway
Returns:
this module's text at specified key location massaged by Strip filters

virtual char* SWModule::Type const char * imodtype = 0 [virtual]
 

Sets/gets module type.

Parameters:
imodtype   value which to set modtype; [0] - only get
Returns:
pointer to modtype

signed char SWModule::createModule const char * path [inline, static]
 

Creates a new module.

Parameters:
path   The first parameter is path of the new module
Returns:
error

Definition at line 328 of file swmodule.h.

virtual void SWModule::encodingFilter char * buf,
long size,
SWKey * key
[inline, virtual]
 

encodingFilter a text buffer.

Parameters:
buf   the buffer to filter
size   the allocated size of the buffer
key   key location from where this buffer was extracted
Returns:
*this

Definition at line 460 of file swmodule.h.

virtual void SWModule::filterBuffer FilterList * filters,
char * buf,
long size,
SWKey * key
[inline, virtual]
 

FilterBuffer a text buffer.

Parameters:
filters   the FilterList of filters to iterate
buf   the buffer to filter
size   the allocated size of the buffer
key   key location from where this buffer was extracted
Returns:
*this

Definition at line 495 of file swmodule.h.

Referenced by encodingFilter(), optionFilter(), rawFilter(), renderFilter(), and stripFilter().

virtual const int SWModule::getEntrySize const [inline, virtual]
 

Returns:
The size of the current entry.

Definition at line 141 of file swmodule.h.

virtual char* SWModule::getRawEntry [pure virtual]
 

This function is reimplemented by the different kinds of module objects.

Returns:
the raw module text of the current entry

virtual bool SWModule::isSearchOptimallySupported const char * istr,
int searchType,
int flags,
SWKey * scope
[inline, virtual]
 

Check if the search is optimally supported (e.g.

if index files are presnt and working) This function checks whether the search framework may work in the best way.

Returns:
True if the the search is optimally supported, false if it's not working in the best way.

Definition at line 274 of file swmodule.h.

virtual const bool SWModule::isUnicode const [inline, virtual]
 

Returns:
True if this module is encoded in Unicode, otherwise return false.

Definition at line 137 of file swmodule.h.

virtual bool SWModule::isWritable [inline, virtual]
 

Is the module writable? :).

Returns:
yes or no

Definition at line 321 of file swmodule.h.

void SWModule::nullPercent char percent,
void * userData
[static]
 

This is the default callback function for searching.

This function is a placeholder and does nothing. You can define your own function for search progress evaluation, and pass it over to Search.

virtual SWModule::operator SWKey & [inline, virtual]
 

Cast operator to cast to a SWKey reference.

This operator may be used to cast this module to a SWKey object.

See also:
SWKey*()

Definition at line 301 of file swmodule.h.

virtual SWModule::operator SWKey * [inline, virtual]
 

Operator to cast to an SWKey pointer.

This function may be used to cast this object to an SWKey pointer.

 //we assume here that SWModule* module is already defined and valid.
 SWKey* currentKey = (SWKey*)module;
 // do something with currentKey (e.g. print out on screen)

Definition at line 312 of file swmodule.h.

virtual SWModule::operator char * [virtual]
 

Renders and returns the current module text.

Returns:
the rendered current module text

virtual SWModule& SWModule::operator+= int increment [virtual]
 

Increments module key a number of entries.

Parameters:
increment   Number of entries to jump forward
Returns:
*this

virtual SWModule& SWModule::operator-= int decrement [virtual]
 

Decrements module key a number of entries.

Parameters:
decrement   Number of entries to jump backward
Returns:
*this

virtual SWModule& SWModule::operator<< const SWKey * linkKey [inline, virtual]
 

Link the current module entry to another module entry only if module isWritable.

  • Returns:
    *this

Definition at line 349 of file swmodule.h.

virtual SWModule& SWModule::operator<< const char * inbuf [inline, virtual]
 

Modify the current module entry text only if module isWritable.

  • Returns:
    *this

Definition at line 342 of file swmodule.h.

virtual SWModule& SWModule::operator= SW_POSITION pos [virtual]
 

Positions this modules to an entry.

Parameters:
p   position (e.g. TOP, BOTTOM)
Returns:
*this

virtual void SWModule::optionFilter char * buf,
long size,
SWKey * key
[inline, virtual]
 

OptionFilter a text buffer.

Parameters:
buf   the buffer to filter
size   the allocated size of the buffer
key   key location from where this buffer was extracted
Returns:
*this

Definition at line 525 of file swmodule.h.

virtual void SWModule::rawFilter char * buf,
long size,
SWKey * key
[inline, virtual]
 

RawFilter a text buffer.

Parameters:
buf   the buffer to filter
size   the allocated size of the buffer
key   key location from where this buffer was extracted
Returns:
*this

Definition at line 507 of file swmodule.h.

virtual void SWModule::renderFilter char * buf,
long size,
SWKey * key
[inline, virtual]
 

RenderFilter a text buffer.

Parameters:
buf   the buffer to filter
size   the allocated size of the buffer
key   key location from where this buffer was extracted
Returns:
*this

Definition at line 423 of file swmodule.h.

virtual SWModule& SWModule::setentry const char * inbuf,
long len
[inline, virtual]
 

Modify the current module entry text only if module isWritable.

  • Returns:
    *this

Definition at line 335 of file swmodule.h.

virtual void SWModule::stripFilter char * buf,
long size,
SWKey * key
[inline, virtual]
 

StripFilter a text buffer.

Parameters:
buf   the buffer to filter
size   the allocated size of the buffer
key   key location from where this buffer was extracted
Returns:
*this

Definition at line 477 of file swmodule.h.


Member Data Documentation

bool SWModule::terminateSearch
 

Set this bool to false to terminate the search which is executed by this module (Search).

This is useful for threaded applications to terminate the search in another thread.

Definition at line 112 of file swmodule.h.


The documentation for this class was generated from the following file:
Generated at Tue Jan 22 14:52:49 2002 for The Sword Project by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001