Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

sword::SWModule Class Reference

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

#include <swmodule.h>

Inheritance diagram for sword::SWModule:

Inheritance graph
[legend]
Collaboration diagram for sword::SWModule:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

virtual ~SWModule ()
 Cleans up instance of SWModule.

virtual char Error ()
 Gets and clears error status.

virtual const bool isUnicode () const
virtual const ConfigEntMap & getConfig () const
virtual void setConfig (ConfigEntMap *config)
virtual const char * getConfigEntry (const char *key) const
virtual const int getEntrySize () const
char SetKey (const SWKey *ikey)
 Sets a key to this module for position to a particular record or set of records.

virtual char setKey (const SWKey *ikey)
virtual long Index () const
virtual long Index (long iindex)
char SetKey (const SWKey &ikey)
 Sets the key of this module.

char setKey (const SWKey &ikey)
SWKeyKey () const
 Gets the current module key.

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

virtual const char * KeyText (const char *ikeytext=0)
virtual char Display ()
 Calls this modules display object and passes itself.

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

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

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

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

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

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

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

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

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.

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.

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

virtual SWBufgetRawEntryBuf ()=0
 This function is reimplemented by the different kinds of module objects.

virtual const char * getRawEntry ()
virtual bool isWritable ()
 Is the module writable? :).

virtual void setEntry (const char *inbuf, long len=-1)
 Modify the current module entry text only if module isWritable().

virtual void linkEntry (const SWKey *sourceKey)
 Link the current module entry to another module entry only if module isWritable().

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

virtual void decrement (int steps=1)
 Decrements module key a number of entries.

virtual void increment (int steps=1)
 Increments module key a number of entries.

virtual void setPosition (SW_POSITION pos)
 Positions this modules to an entry.

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

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

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

virtual void renderFilter (SWBuf &buf, SWKey *key)
 RenderFilter a text buffer.

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

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

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

virtual void encodingFilter (SWBuf &buf, SWKey *key)
 encodingFilter a text buffer

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

virtual void stripFilter (SWBuf &buf, SWKey *key)
 StripFilter a text buffer.

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

virtual void filterBuffer (FilterList *filters, SWBuf &buf, SWKey *key)
 FilterBuffer a text buffer.

virtual void rawFilter (SWBuf &buf, SWKey *key)
 RawFilter a text buffer.

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

virtual void optionFilter (SWBuf &buf, SWKey *key)
 OptionFilter a text buffer.

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

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

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

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

virtual void setSkipConsecutiveLinks (bool val)
 option to specify behaviour when iterating over consecutive entried linked to same text

virtual bool getSkipConsecutiveLinks ()
virtual AttributeTypeList & getEntryAttributes () const
virtual void processEntryAttributes (bool val) const
virtual bool isProcessEntryAttributes () const
 operator const char * ()
 operator SWKey & ()
 operator SWKey * ()
SWModule & operator<< (const char *inbuf)
SWModule & operator<< (const SWKey *sourceKey)
SWModule & operator-= (int steps)
SWModule & operator+= (int steps)
SWModule & operator++ (int)
SWModule & operator-- (int)
SWModule & operator= (SW_POSITION p)

Static Public Member Functions

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

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


Public Attributes

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


Protected Attributes

ConfigEntMap ownConfig
ConfigEntMap * config
AttributeTypeList entryAttributes
bool procEntAttr
char error
bool skipConsecutiveLinks
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

SWBuf 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

int entrySize
long entryIndex

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.


Constructor & Destructor Documentation

sword::SWModule::SWModule const char *    imodname = 0,
const char *    imoddesc = 0,
SWDisplay   idisp = 0,
char *    imodtype = 0,
char    encoding = ENC_UNKNOWN,
char    dir = DIRECTION_LTR,
char    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()
encoding Encoding of the module.
dir Direction of text flow.
markup Markup of the module.
modlang Language of the module.


Member Function Documentation

virtual SWModule& sword::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

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

Adds an OptionFilter to this module's optionfilters queue.

Parameters:
newfilter the filter to add
Returns:
*this

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

Adds a RawFilter to this module's rawfilters queue.

Parameters:
newfilter the filter to add
Returns:
*this

virtual SWModule& sword::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

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

Adds a StripFilter to this module's stripfilters queue.

Parameters:
newfilter the filter to add
Returns:
*this

SWKey * sword::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 sword::SWCom, sword::SWGenBook, sword::SWLD, and sword::SWText.

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

Creates a new module.

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

void sword::SWModule::decrement int    steps = 1 [virtual]
 

Decrements module key a number of entries.

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

virtual void sword::SWModule::deleteEntry   [inline, virtual]
 

Delete current module entry - only if module isWritable().

char * sword::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

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

Sets/gets module direction.

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

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

Sets/gets display driver.

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

char sword::SWModule::Display   [virtual]
 

Calls this modules display object and passes itself.

Returns:
error status

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

Sets/gets module encoding.

Parameters:
enc value which to set encoding; [-1] - only get
Returns:
Encoding

virtual void sword::SWModule::encodingFilter SWBuf   buf,
SWKey   key
[inline, virtual]
 

encodingFilter a text buffer

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

char sword::SWModule::Error   [virtual]
 

Gets and clears error status.

Returns:
error status

virtual void sword::SWModule::filterBuffer FilterList *    filters,
SWBuf   buf,
SWKey   key
[inline, virtual]
 

FilterBuffer a text buffer.

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

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

Returns:
The size of the current entry.

virtual SWBuf& sword::SWModule::getRawEntryBuf   [pure virtual]
 

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

Returns:
the raw module text of the current entry

void sword::SWModule::increment int    steps = 1 [virtual]
 

Increments module key a number of entries.

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

virtual bool sword::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.

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

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

virtual bool sword::SWModule::isWritable   [inline, virtual]
 

Is the module writable? :).

Returns:
yes or no

char sword::SWModule::Key const SWKey   ikey [inline]
 

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
Deprecated:
See setKey()

SWKey& sword::SWModule::Key   const [inline]
 

Gets the current module key.

Returns:
the current key of this module
Deprecated:
See getKey()

char * sword::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 void sword::SWModule::linkEntry const SWKey   sourceKey [inline, virtual]
 

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

char sword::SWModule::Markup signed char    markup = -1 [virtual]
 

Sets/gets module markup.

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

char * sword::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

void sword::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 void sword::SWModule::optionFilter SWBuf   buf,
SWKey   key
[inline, virtual]
 

OptionFilter a text buffer.

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

virtual void sword::SWModule::rawFilter SWBuf   buf,
SWKey   key
[inline, virtual]
 

RawFilter a text buffer.

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

virtual SWModule& sword::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

virtual SWModule& sword::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

virtual void sword::SWModule::renderFilter SWBuf   buf,
SWKey   key
[inline, virtual]
 

RenderFilter a text buffer.

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

const char * sword::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

const char * sword::SWModule::RenderText char *    buf = 0,
int    len = -1,
bool    render = true
[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
render Perform the rendering.
Returns:
this module's text at specified key location massaged by Render filters

virtual SWModule& sword::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

virtual SWModule& sword::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

ListKey & sword::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
scope Key containing the scope. VerseKey or ListKey are useful here.
justCheckIfSupported if set, don't search, only tell if this function supports requested search.
percent Callback function to get the current search status in .
percentUserData User data that is given to the callback function as parameter.
Returns:
listkey set to verses that contain istr

virtual void sword::SWModule::setEntry const char *    inbuf,
long    len = -1
[inline, virtual]
 

Modify the current module entry text only if module isWritable().

  • Returns:
    *this

char sword::SWModule::SetKey const SWKey   ikey [inline]
 

Sets the key of this module.

Similar to

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

char sword::SWModule::SetKey const SWKey   ikey [inline]
 

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
Deprecated:
See setKey()

void sword::SWModule::setPosition SW_POSITION    pos [virtual]
 

Positions this modules to an entry.

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

Reimplemented in sword::SWLD.

virtual void sword::SWModule::setSkipConsecutiveLinks bool    val [inline, virtual]
 

option to specify behaviour when iterating over consecutive entried linked to same text

Parameters:
val = true means only include entry once in iteration

virtual void sword::SWModule::stripFilter SWBuf   buf,
SWKey   key
[inline, virtual]
 

StripFilter a text buffer.

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

const char * sword::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

const char * sword::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

char * sword::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


Member Data Documentation

bool sword::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.


The documentation for this class was generated from the following files:
Generated on Fri Feb 28 22:01:44 2003 for The Sword Project by doxygen1.3-rc3