zCom Class Reference

#include <zcom.h>

Inheritance diagram for zCom:
Inheritance graph
[legend]
Collaboration diagram for zCom:
Collaboration graph
[legend]

List of all members.

Public Member Functions

SWDEPRECATED SWModuleAddEncodingFilter (SWFilter *newFilter)
virtual SWModuleaddEncodingFilter (SWFilter *newFilter)
SWDEPRECATED SWModuleAddOptionFilter (SWOptionFilter *newFilter)
virtual SWModuleaddOptionFilter (SWOptionFilter *newFilter)
SWDEPRECATED SWModuleAddRawFilter (SWFilter *newFilter)
virtual SWModuleaddRawFilter (SWFilter *newfilter)
SWDEPRECATED SWModuleAddRenderFilter (SWFilter *newFilter)
virtual SWModuleaddRenderFilter (SWFilter *newFilter)
SWDEPRECATED SWModuleAddStripFilter (SWFilter *newFilter)
virtual SWModuleaddStripFilter (SWFilter *newFilter)
SWDEPRECATED SWKeyCreateKey () const
virtual SWKeycreateKey () const
virtual signed char createSearchFramework (void(*percent)(char, void *)=&nullPercent, void *percentUserData=0)
virtual void decrement (int steps=1)
virtual void deleteEntry ()
virtual void deleteSearchFramework ()
SWDEPRECATED const char * Description (const char *imoddesc)
SWDEPRECATED const char * Description () const
SWDEPRECATED char Direction (signed char newdir=-1)
SWDEPRECATED SWDisplayDisp (SWDisplay *idisp=0)
SWDEPRECATED char Display ()
virtual char display ()
SWDEPRECATED char Encoding (signed char enc=-1)
virtual void encodingFilter (SWBuf &buf, const SWKey *key) const
virtual SWDEPRECATED char Error ()
virtual void filterBuffer (FilterList *filters, SWBuf &buf, const SWKey *key) const
virtual void filterBuffer (OptionFilterList *filters, SWBuf &buf, const SWKey *key) const
void findOffset (char testmt, long idxoff, long *start, unsigned short *size, unsigned long *buffnum) const
virtual void flush ()
virtual const ConfigEntMapgetConfig () const
virtual const char * getConfigEntry (const char *key) const
const char * getDescription () const
virtual char getDirection () const
virtual SWDisplaygetDisplay () const
char getEncoding () const
virtual AttributeTypeListgetEntryAttributes () const
virtual int getEntrySize () const
virtual long getIndex () const
virtual SWKeygetKey () const
virtual const char * getKeyText () const
const char * getLanguage () const
char getMarkup () const
const char * getName () const
const char * getRawEntry () const
virtual SWBufgetRawEntryBuf () const
virtual const FilterListgetRenderFilters () const
virtual const char * getRenderHeader () const
SWDEPRECATED bool getSkipConsecutiveLinks ()
const char * getType () const
virtual bool hasEntry (const SWKey *k) const
virtual bool hasSearchFramework ()
virtual void increment (int steps=1)
SWDEPRECATED long Index (long iindex)
SWDEPRECATED long Index () const
virtual bool isLinked (const SWKey *k1, const SWKey *k2) const
virtual bool isProcessEntryAttributes () const
virtual bool isSearchOptimallySupported (const char *istr, int searchType, int flags, SWKey *scope)
virtual bool isSkipConsecutiveLinks ()
virtual bool isUnicode () const
virtual bool isWritable () const
SWDEPRECATED SWKeyKey () const
SWDEPRECATED char Key (const SWKey &ikey)
SWDEPRECATED const char * KeyText (const char *ikeytext=0)
SWDEPRECATED const char * Lang (char *imodlang=0)
virtual long lastAccess ()
virtual void linkEntry (const SWKey *linkKey)
SWDEPRECATED char Markup (signed char imarkup=-1)
SWDEPRECATED const char * Name (const char *imodname)
SWDEPRECATED const char * Name () const
virtual void optionFilter (SWBuf &buf, const SWKey *key) const
virtual char popError ()
SWDEPRECATED void processEntryAttributes (bool val) const
virtual void rawFilter (SWBuf &buf, const SWKey *key) const
virtual void rawZFilter (SWBuf &buf, char direction=0) const
SWDEPRECATED SWModuleRemoveEncodingFilter (SWFilter *oldFilter)
virtual SWModuleremoveEncodingFilter (SWFilter *oldFilter)
SWDEPRECATED SWModuleRemoveRenderFilter (SWFilter *oldFilter)
virtual SWModuleremoveRenderFilter (SWFilter *oldFilter)
virtual void renderFilter (SWBuf &buf, const SWKey *key) const
SWDEPRECATED const char * RenderText (const char *buf=0, int len=-1, bool render=true)
virtual const char * renderText (const SWKey *tmpKey)
virtual const char * renderText (const char *buf=0, int len=-1, bool render=true)
SWDEPRECATED SWModuleReplaceEncodingFilter (SWFilter *oldFilter, SWFilter *newFilter)
virtual SWModulereplaceEncodingFilter (SWFilter *oldFilter, SWFilter *newFilter)
SWDEPRECATED SWModuleReplaceRenderFilter (SWFilter *oldFilter, SWFilter *newFilter)
virtual SWModulereplaceRenderFilter (SWFilter *oldFilter, SWFilter *newFilter)
virtual long resourceConsumption ()
SWDEPRECATED ListKeySearch (const char *istr, int searchType=0, int flags=0, SWKey *scope=0, bool *justCheckIfSupported=0, void(*percent)(char, void *)=&nullPercent, void *percentUserData=0)
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)
virtual void setConfig (ConfigEntMap *config)
virtual void setDisplay (SWDisplay *idisp)
virtual void setEntry (const char *inbuf, long len=-1)
virtual void setIndex (long iindex)
SWDEPRECATED char SetKey (const SWKey &ikey)
SWDEPRECATED char SetKey (const SWKey *ikey)
char setKey (const SWKey &ikey)
virtual char setKey (const SWKey *ikey)
virtual void setPosition (SW_POSITION pos)
virtual void setProcessEntryAttributes (bool val) const
virtual void setSkipConsecutiveLinks (bool val)
void setType (const char *imodtype)
virtual void stripFilter (SWBuf &buf, const SWKey *key) const
SWDEPRECATED const char * StripText (const char *buf=0, int len=-1)
virtual const char * stripText (const SWKey *tmpKey)
virtual const char * stripText (const char *buf=0, int len=-1)
SWDEPRECATED const char * Type (const char *imodtype)
SWDEPRECATED const char * Type () const
 zCom (const char *ipath, const char *iname=0, const char *idesc=0, int blockType=CHAPTERBLOCKS, SWCompress *icomp=0, SWDisplay *idisp=0, SWTextEncoding encoding=ENC_UNKNOWN, SWTextDirection dir=DIRECTION_LTR, SWTextMarkup markup=FMT_UNKNOWN, const char *ilang=0, const char *versification="KJV")
void zReadText (char testmt, long start, unsigned short size, unsigned long buffnum, SWBuf &buf) const
virtual ~zCom ()

Static Public Member Functions

static signed char createModule (const char *path)
static char createModule (const char *path, int blockBound, const char *v11n="KJV")
static void nullPercent (char percent, void *userData)

Public Attributes

char nl
bool terminateSearch

Static Public Attributes

static const char uniqueIndexID [] = {'X', 'r', 'v', 'c', 'b'}

Protected Member Functions

void doLinkEntry (char testmt, long destidxoff, long srcidxoff)
void doSetText (char testmt, long idxoff, const char *buf, long len=0)
void flushCache () const
VerseKeygetVerseKey (const SWKey *key=0) const

Static Protected Member Functions

static void prepText (SWBuf &buf)

Protected Attributes

char * cacheBuf
long cacheBufIdx
unsigned int cacheBufSize
char cacheTestament
FileDesccompfp [2]
ConfigEntMapconfig
char direction
bool dirtyCache
SWDisplaydisp
char encoding
FilterListencodingFilters
AttributeTypeList entryAttributes
SWBuf entryBuf
long entryIndex
int entrySize
char error
FileDescidxfp [2]
SWKeykey
ListKey listKey
char markup
char * moddesc
char * modlang
char * modname
char * modtype
OptionFilterListoptionFilters
ConfigEntMap ownConfig
char * path
bool procEntAttr
FilterListrawFilters
FilterListrenderFilters
bool skipConsecutiveLinks
FilterListstripFilters
FileDesctextfp [2]

Static Protected Attributes

static int instance = 0
static StdOutDisplay rawdisp

Private Member Functions

bool sameBlock (VerseKey *lastWriteKey, VerseKey *key)

Private Attributes

int blockType
VerseKeylastWriteKey

Detailed Description

Definition at line 32 of file zcom.h.


Constructor & Destructor Documentation

SWORD_NAMESPACE_START zCom::zCom ( const char *  ipath,
const char *  iname = 0,
const char *  idesc = 0,
int  blockType = CHAPTERBLOCKS,
SWCompress icomp = 0,
SWDisplay idisp = 0,
SWTextEncoding  encoding = ENC_UNKNOWN,
SWTextDirection  dir = DIRECTION_LTR,
SWTextMarkup  markup = FMT_UNKNOWN,
const char *  ilang = 0,
const char *  versification = "KJV" 
)

Definition at line 45 of file zcom.cpp.

00045                                                                                                                                                                                                                                  : zVerse(ipath, -1, iblockType, icomp), SWCom(iname, idesc, idisp, enc, dir, mark, ilang, versification)/*, SWCompress()*/
00046 {
00047     blockType = iblockType;
00048     lastWriteKey = 0;
00049 }

zCom::~zCom (  )  [virtual]

Definition at line 55 of file zcom.cpp.

00055             {
00056     flushCache();
00057 
00058     if (lastWriteKey)
00059         delete lastWriteKey;
00060 }


Member Function Documentation

SWDEPRECATED SWModule& SWModule::AddEncodingFilter ( SWFilter newFilter  )  [inline, inherited]

Definition at line 530 of file swmodule.h.

00530 { return addEncodingFilter(newFilter); }

virtual SWModule& SWModule::addEncodingFilter ( SWFilter newFilter  )  [inline, virtual, inherited]

Adds an EncodingFilter to this module's

See also:
encodingFilters queue. Encoding Filters are called immediately when the module is read from data source, to assure we have desired internal data stream (e.g. UTF-8 for text modules)
Parameters:
newfilter the filter to add
Returns:
*this

Definition at line 526 of file swmodule.h.

00526                                                              {
00527         encodingFilters->push_back(newFilter);
00528         return *this;
00529     }

SWDEPRECATED SWModule& SWModule::AddOptionFilter ( SWOptionFilter newFilter  )  [inline, inherited]

Definition at line 615 of file swmodule.h.

00615 { return addOptionFilter(newFilter); }

virtual SWModule& SWModule::addOptionFilter ( SWOptionFilter newFilter  )  [inline, virtual, inherited]

Adds an OptionFilter to this module's optionFilters queue. Option Filters are used to turn options in the text on or off, or so some other state (e.g. Strong's Number, Footnotes, Cross References, etc.)

Parameters:
newfilter the filter to add
Returns:
*this

Definition at line 611 of file swmodule.h.

00611                                                                  {
00612         optionFilters->push_back(newFilter);
00613         return *this;
00614     }

SWDEPRECATED SWModule& SWModule::AddRawFilter ( SWFilter newFilter  )  [inline, inherited]

Definition at line 585 of file swmodule.h.

00585 { return addRawFilter(newFilter); }

virtual SWModule& SWModule::addRawFilter ( SWFilter newfilter  )  [inline, virtual, inherited]

Adds a RawFilter to this module's rawFilters queue

Parameters:
newFilter the filter to add
Returns:
*this

Definition at line 581 of file swmodule.h.

00581                                                         {
00582         rawFilters->push_back(newfilter);
00583         return *this;
00584     }

SWDEPRECATED SWModule& SWModule::AddRenderFilter ( SWFilter newFilter  )  [inline, inherited]

Definition at line 476 of file swmodule.h.

00476 { return addRenderFilter(newFilter); }

virtual SWModule& SWModule::addRenderFilter ( SWFilter newFilter  )  [inline, virtual, inherited]

Adds a RenderFilter to this module's renderFilters queue. Render Filters are called when the module is asked to produce renderable text.

Parameters:
newfilter the filter to add
Returns:
*this

Definition at line 472 of file swmodule.h.

00472                                                            {
00473         renderFilters->push_back(newFilter);
00474         return *this;
00475     }

SWDEPRECATED SWModule& SWModule::AddStripFilter ( SWFilter newFilter  )  [inline, inherited]

Definition at line 575 of file swmodule.h.

00575 { return addStripFilter(newFilter); }

virtual SWModule& SWModule::addStripFilter ( SWFilter newFilter  )  [inline, virtual, inherited]

Adds a StripFilter to this module's stripFilters queue. Strip filters are called when a module is asked to render an entry without any markup (like when searching).

Parameters:
newfilter the filter to add
Returns:
*this

Definition at line 571 of file swmodule.h.

00571                                                           {
00572         stripFilters->push_back(newFilter);
00573         return *this;
00574     }

SWDEPRECATED SWKey* SWModule::CreateKey (  )  const [inline, inherited]

Definition at line 400 of file swmodule.h.

00400 { return createKey(); }

SWKey * SWCom::createKey (  )  const [virtual, inherited]

Allocates a key of specific type for module The different reimplementations 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. Caller is responsible for deleting the object

Reimplemented from SWModule.

Definition at line 62 of file swcom.cpp.

00062                               {
00063     VerseKey *vk = new VerseKey();
00064 
00065     vk->setVersificationSystem(versification);
00066 
00067     return vk;
00068 }

signed char SWModule::createModule ( const char *  path  )  [static, inherited]

Creates a new, empty module

Parameters:
path path where to create the new module
Returns:
error

Reimplemented in RawFiles, RawGenBook, RawLD, RawLD4, and zLD.

Definition at line 1368 of file swmodule.cpp.

01368                                               {
01369     return -1;
01370 }

static char zCom::createModule ( const char *  path,
int  blockBound,
const char *  v11n = "KJV" 
) [inline, static]

Reimplemented from zVerse.

Definition at line 54 of file zcom.h.

00054                                                                                          {
00055         return zVerse::createModule(path, blockBound, v11n);
00056     }

signed char SWModule::createSearchFramework ( void(*)(char, void *)  percent = &nullPercent,
void *  percentUserData = 0 
) [virtual, inherited]

ask the object to build any indecies it wants for optimal searching

Reimplemented from SWSearchable.

Definition at line 941 of file swmodule.cpp.

00941                                                                                                 {
00942 
00943 #ifdef USELUCENE
00944     SWBuf target = getConfigEntry("AbsoluteDataPath");
00945     if (!target.endsWith("/") && !target.endsWith("\\")) {
00946         target.append('/');
00947     }
00948     target.append("lucene");
00949     int status = FileMgr::createParent(target+"/dummy");
00950     if (status) return -1;
00951 
00952     SWKey *saveKey = 0;
00953     SWKey *searchKey = 0;
00954     SWKey textkey;
00955     SWBuf c;
00956 
00957     const int MAX_CONV_SIZE = 1024 * 1024;
00958 
00959     // turn all filters to default values
00960     StringList filterSettings;
00961     for (OptionFilterList::iterator filter = optionFilters->begin(); filter != optionFilters->end(); filter++) {
00962         filterSettings.push_back((*filter)->getOptionValue());
00963         (*filter)->setOptionValue(*((*filter)->getOptionValues().begin()));
00964 
00965         if ( (!strcmp("Greek Accents", (*filter)->getOptionName())) ||
00966             (!strcmp("Hebrew Vowel Points", (*filter)->getOptionName())) ||
00967             (!strcmp("Arabic Vowel Points", (*filter)->getOptionName()))
00968            ) {
00969             (*filter)->setOptionValue("Off");
00970         }
00971     }
00972 
00973 
00974     // be sure we give CLucene enough file handles
00975     FileMgr::getSystemFileMgr()->flush();
00976 
00977     // save key information so as not to disrupt original
00978     // module position
00979     if (!key->isPersist()) {
00980         saveKey = createKey();
00981         *saveKey = *key;
00982     }
00983     else    saveKey = key;
00984 
00985     searchKey = (key->isPersist())?key->clone():0;
00986     if (searchKey) {
00987         searchKey->setPersist(1);
00988         setKey(*searchKey);
00989     }
00990 
00991     RAMDirectory *ramDir = 0;
00992     IndexWriter *coreWriter = 0;
00993     IndexWriter *fsWriter = 0;
00994     Directory *d = 0;
00995 
00996     const TCHAR *stopWords[] = { 0 };
00997     standard::StandardAnalyzer *an = new standard::StandardAnalyzer(stopWords);
00998     bool includeKeyInSearch = getConfig().has("SearchOption", "IncludeKeyInSearch");
00999 
01000     ramDir = new RAMDirectory();
01001     coreWriter = new IndexWriter(ramDir, an, true);
01002     coreWriter->setMaxFieldLength(MAX_CONV_SIZE);
01003 
01004 
01005 
01006 
01007     char perc = 1;
01008     VerseKey *vkcheck = 0;
01009     vkcheck = SWDYNAMIC_CAST(VerseKey, key);
01010     VerseKey *chapMax = 0;
01011         if (vkcheck) chapMax = (VerseKey *)vkcheck->clone();
01012 
01013     TreeKeyIdx *tkcheck = 0;
01014     tkcheck = SWDYNAMIC_CAST(TreeKeyIdx, key);
01015 
01016 
01017     *this = BOTTOM;
01018     long highIndex = key->getIndex();
01019     if (!highIndex)
01020         highIndex = 1;      // avoid division by zero errors.
01021 
01022     bool savePEA = isProcessEntryAttributes();
01023     setProcessEntryAttributes(true);
01024 
01025     // prox chapter blocks
01026     // position module at the beginning
01027     *this = TOP;
01028 
01029     SWBuf proxBuf;
01030     SWBuf proxLem;
01031     SWBuf proxMorph;
01032     SWBuf strong;
01033     SWBuf morph;
01034 
01035     char err = popError();
01036     while (!err) {
01037         long mindex = key->getIndex();
01038 
01039         proxBuf = "";
01040         proxLem = "";
01041         proxMorph = "";
01042 
01043         // computer percent complete so we can report to our progress callback
01044         float per = (float)mindex / highIndex;
01045         // between 5%-98%
01046         per *= 93; per += 5;
01047         char newperc = (char)per;
01048         if (newperc > perc) {
01049             perc = newperc;
01050             (*percent)(perc, percentUserData);
01051         }
01052 
01053         // get "content" field
01054         const char *content = stripText();
01055 
01056         bool good = false;
01057 
01058         // start out entry
01059         Document *doc = new Document();
01060         // get "key" field
01061         SWBuf keyText = (vkcheck) ? vkcheck->getOSISRef() : getKeyText();
01062         if (content && *content) {
01063             good = true;
01064 
01065 
01066             // build "strong" field
01067             AttributeTypeList::iterator words;
01068             AttributeList::iterator word;
01069             AttributeValue::iterator strongVal;
01070             AttributeValue::iterator morphVal;
01071 
01072             strong="";
01073             morph="";
01074             words = getEntryAttributes().find("Word");
01075             if (words != getEntryAttributes().end()) {
01076                 for (word = words->second.begin();word != words->second.end(); word++) {
01077                     int partCount = atoi(word->second["PartCount"]);
01078                     if (!partCount) partCount = 1;
01079                     for (int i = 0; i < partCount; i++) {
01080                         SWBuf tmp = "Lemma";
01081                         if (partCount > 1) tmp.appendFormatted(".%d", i+1);
01082                         strongVal = word->second.find(tmp);
01083                         if (strongVal != word->second.end()) {
01084                             // cheeze.  skip empty article tags that weren't assigned to any text
01085                             if (strongVal->second == "G3588") {
01086                                 if (word->second.find("Text") == word->second.end())
01087                                     continue;   // no text? let's skip
01088                             }
01089                             strong.append(strongVal->second);
01090                             morph.append(strongVal->second);
01091                             morph.append('@');
01092                             SWBuf tmp = "Morph";
01093                             if (partCount > 1) tmp.appendFormatted(".%d", i+1);
01094                             morphVal = word->second.find(tmp);
01095                             if (morphVal != word->second.end()) {
01096                                 morph.append(morphVal->second);
01097                             }
01098                             strong.append(' ');
01099                             morph.append(' ');
01100                         }
01101                     }
01102                 }
01103             }
01104 
01105             doc->add(*_CLNEW Field(_T("key"), (wchar_t *)utf8ToWChar(keyText).getRawData(), Field::STORE_YES | Field::INDEX_UNTOKENIZED));
01106 
01107             if (includeKeyInSearch) {
01108                 c = keyText;
01109                 c += " ";
01110                 c += content;
01111                 content = c.c_str();
01112             }
01113 
01114             doc->add(*_CLNEW Field(_T("content"), (wchar_t *)utf8ToWChar(content).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
01115 
01116             if (strong.length() > 0) {
01117                 doc->add(*_CLNEW Field(_T("lemma"), (wchar_t *)utf8ToWChar(strong).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
01118                 doc->add(*_CLNEW Field(_T("morph"), (wchar_t *)utf8ToWChar(morph).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
01119 //printf("setting fields (%s).\ncontent: %s\nlemma: %s\n", (const char *)*key, content, strong.c_str());
01120             }
01121 
01122 //printf("setting fields (%s).\n", (const char *)*key);
01123 //fflush(stdout);
01124         }
01125         // don't write yet, cuz we have to see if we're the first of a prox block (5:1 or chapter5/verse1
01126 
01127         // for VerseKeys use chapter
01128         if (vkcheck) {
01129             *chapMax = *vkcheck;
01130             // we're the first verse in a chapter
01131             if (vkcheck->getVerse() == 1) {
01132                 *chapMax = MAXVERSE;
01133                 VerseKey saveKey = *vkcheck;
01134                 while ((!err) && (*vkcheck <= *chapMax)) {
01135 //printf("building proxBuf from (%s).\nproxBuf.c_str(): %s\n", (const char *)*key, proxBuf.c_str());
01136 //printf("building proxBuf from (%s).\n", (const char *)*key);
01137 
01138                     content = stripText();
01139                     if (content && *content) {
01140                         // build "strong" field
01141                         strong = "";
01142                         morph = "";
01143                         AttributeTypeList::iterator words;
01144                         AttributeList::iterator word;
01145                         AttributeValue::iterator strongVal;
01146                         AttributeValue::iterator morphVal;
01147 
01148                         words = getEntryAttributes().find("Word");
01149                         if (words != getEntryAttributes().end()) {
01150                             for (word = words->second.begin();word != words->second.end(); word++) {
01151                                 int partCount = atoi(word->second["PartCount"]);
01152                                 if (!partCount) partCount = 1;
01153                                 for (int i = 0; i < partCount; i++) {
01154                                     SWBuf tmp = "Lemma";
01155                                     if (partCount > 1) tmp.appendFormatted(".%d", i+1);
01156                                     strongVal = word->second.find(tmp);
01157                                     if (strongVal != word->second.end()) {
01158                                         // cheeze.  skip empty article tags that weren't assigned to any text
01159                                         if (strongVal->second == "G3588") {
01160                                             if (word->second.find("Text") == word->second.end())
01161                                                 continue;   // no text? let's skip
01162                                         }
01163                                         strong.append(strongVal->second);
01164                                         morph.append(strongVal->second);
01165                                         morph.append('@');
01166                                         SWBuf tmp = "Morph";
01167                                         if (partCount > 1) tmp.appendFormatted(".%d", i+1);
01168                                         morphVal = word->second.find(tmp);
01169                                         if (morphVal != word->second.end()) {
01170                                             morph.append(morphVal->second);
01171                                         }
01172                                         strong.append(' ');
01173                                         morph.append(' ');
01174                                     }
01175                                 }
01176                             }
01177                         }
01178                         proxBuf += content;
01179                         proxBuf.append(' ');
01180                         proxLem += strong;
01181                         proxMorph += morph;
01182                         if (proxLem.length()) {
01183                             proxLem.append("\n");
01184                             proxMorph.append("\n");
01185                         }
01186                     }
01187                     (*this)++;
01188                     err = popError();
01189                 }
01190                 err = 0;
01191                 *vkcheck = saveKey;
01192             }
01193         }
01194 
01195         // for TreeKeys use siblings if we have no children
01196         else if (tkcheck) {
01197             if (!tkcheck->hasChildren()) {
01198                 if (!tkcheck->previousSibling()) {
01199                     do {
01200 //printf("building proxBuf from (%s).\n", (const char *)*key);
01201 //fflush(stdout);
01202 
01203                         content = stripText();
01204                         if (content && *content) {
01205                             // build "strong" field
01206                             strong = "";
01207                             morph = "";
01208                             AttributeTypeList::iterator words;
01209                             AttributeList::iterator word;
01210                             AttributeValue::iterator strongVal;
01211                             AttributeValue::iterator morphVal;
01212 
01213                             words = getEntryAttributes().find("Word");
01214                             if (words != getEntryAttributes().end()) {
01215                                 for (word = words->second.begin();word != words->second.end(); word++) {
01216                                     int partCount = atoi(word->second["PartCount"]);
01217                                     if (!partCount) partCount = 1;
01218                                     for (int i = 0; i < partCount; i++) {
01219                                         SWBuf tmp = "Lemma";
01220                                         if (partCount > 1) tmp.appendFormatted(".%d", i+1);
01221                                         strongVal = word->second.find(tmp);
01222                                         if (strongVal != word->second.end()) {
01223                                             // cheeze.  skip empty article tags that weren't assigned to any text
01224                                             if (strongVal->second == "G3588") {
01225                                                 if (word->second.find("Text") == word->second.end())
01226                                                     continue;   // no text? let's skip
01227                                             }
01228                                             strong.append(strongVal->second);
01229                                             morph.append(strongVal->second);
01230                                             morph.append('@');
01231                                             SWBuf tmp = "Morph";
01232                                             if (partCount > 1) tmp.appendFormatted(".%d", i+1);
01233                                             morphVal = word->second.find(tmp);
01234                                             if (morphVal != word->second.end()) {
01235                                                 morph.append(morphVal->second);
01236                                             }
01237                                             strong.append(' ');
01238                                             morph.append(' ');
01239                                         }
01240                                     }
01241                                 }
01242                             }
01243 
01244                             proxBuf += content;
01245                             proxBuf.append(' ');
01246                             proxLem += strong;
01247                             proxMorph += morph;
01248                             if (proxLem.length()) {
01249                                 proxLem.append("\n");
01250                                 proxMorph.append("\n");
01251                             }
01252                         }
01253                     } while (tkcheck->nextSibling());
01254                     tkcheck->parent();
01255                     tkcheck->firstChild();
01256                 }
01257                 else tkcheck->nextSibling();    // reposition from our previousSibling test
01258             }
01259         }
01260 
01261         if (proxBuf.length() > 0) {
01262 
01263             doc->add(*_CLNEW Field(_T("prox"), (wchar_t *)utf8ToWChar(proxBuf).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
01264             good = true;
01265         }
01266         if (proxLem.length() > 0) {
01267             doc->add(*_CLNEW Field(_T("proxlem"), (wchar_t *)utf8ToWChar(proxLem).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED) );
01268             doc->add(*_CLNEW Field(_T("proxmorph"), (wchar_t *)utf8ToWChar(proxMorph).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED) );
01269             good = true;
01270         }
01271         if (good) {
01272 //printf("writing (%s).\n", (const char *)*key);
01273 //fflush(stdout);
01274             coreWriter->addDocument(doc);
01275         }
01276         delete doc;
01277 
01278         (*this)++;
01279         err = popError();
01280     }
01281 
01282     // Optimizing automatically happens with the call to addIndexes
01283     //coreWriter->optimize();
01284     coreWriter->close();
01285 
01286 #ifdef CLUCENE2
01287     d = FSDirectory::getDirectory(target.c_str());
01288 #endif
01289     if (IndexReader::indexExists(target.c_str())) {
01290 #ifndef CLUCENE2
01291         d = FSDirectory::getDirectory(target.c_str(), false);
01292 #endif
01293         if (IndexReader::isLocked(d)) {
01294             IndexReader::unlock(d);
01295         }
01296         fsWriter = new IndexWriter( d, an, false);
01297     }
01298     else {
01299 #ifndef CLUCENE2
01300         d = FSDirectory::getDirectory(target.c_str(), true);
01301 #endif
01302         fsWriter = new IndexWriter(d, an, true);
01303     }
01304 
01305     Directory *dirs[] = { ramDir, 0 };
01306 #ifdef CLUCENE2
01307     lucene::util::ConstValueArray< lucene::store::Directory *>dirsa(dirs, 1);
01308     fsWriter->addIndexes(dirsa);
01309 #else
01310     fsWriter->addIndexes(dirs);
01311 #endif
01312     fsWriter->close();
01313 
01314     delete ramDir;
01315     delete coreWriter;
01316     delete fsWriter;
01317     delete an;
01318 
01319     // reposition module back to where it was before we were called
01320     setKey(*saveKey);
01321 
01322     if (!saveKey->isPersist())
01323         delete saveKey;
01324 
01325     if (searchKey)
01326         delete searchKey;
01327 
01328         delete chapMax;
01329 
01330     setProcessEntryAttributes(savePEA);
01331 
01332     // reset option filters back to original values
01333     StringList::iterator origVal = filterSettings.begin();
01334     for (OptionFilterList::iterator filter = optionFilters->begin(); filter != optionFilters->end(); filter++) {
01335         (*filter)->setOptionValue(*origVal++);
01336     }
01337 
01338     return 0;
01339 #else
01340     return SWSearchable::createSearchFramework(percent, percentUserData);
01341 #endif
01342 }

virtual void zCom::decrement ( int  steps = 1  )  [inline, virtual]

Decrements module key a number of entries

Parameters:
steps Number of entries to jump backward

Reimplemented from SWModule.

Definition at line 50 of file zcom.h.

00050 { increment(-steps); }

void zCom::deleteEntry (  )  [virtual]

Delete current module entry - only if module isWritable()

Reimplemented from SWModule.

Definition at line 146 of file zcom.cpp.

00146                        {
00147 
00148     VerseKey *key = &getVerseKey();
00149     doSetText(key->getTestament(), key->getTestamentIndex(), "");
00150 }

void SWModule::deleteSearchFramework (  )  [virtual, inherited]

Reimplemented from SWSearchable.

Definition at line 926 of file swmodule.cpp.

00926                                      {
00927 #ifdef USELUCENE
00928     SWBuf target = getConfigEntry("AbsoluteDataPath");
00929     if (!target.endsWith("/") && !target.endsWith("\\")) {
00930         target.append('/');
00931     }
00932     target.append("lucene");
00933 
00934     FileMgr::removeDir(target.c_str());
00935 #else
00936     SWSearchable::deleteSearchFramework();
00937 #endif
00938 }

SWDEPRECATED const char* SWModule::Description ( const char *  imoddesc  )  [inline, inherited]

Sets module description

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

Definition at line 312 of file swmodule.h.

00312 { stdstr(&moddesc, imoddesc); return getDescription(); }

SWDEPRECATED const char* SWModule::Description (  )  const [inline, inherited]

Definition at line 305 of file swmodule.h.

00305 { return getDescription(); }

SWDEPRECATED char SWModule::Direction ( signed char  newdir = -1  )  [inline, inherited]

Definition at line 335 of file swmodule.h.

00335 { char retVal = getDirection(); if (newdir != -1) return direction = newdir; return retVal; }

SWDEPRECATED SWDisplay* SWModule::Disp ( SWDisplay idisp = 0  )  [inline, inherited]
Deprecated:
Use get/setDisplay() instead.

Definition at line 284 of file swmodule.h.

00284 { if (idisp)    setDisplay(idisp); return getDisplay(); }

SWDEPRECATED char SWModule::Display (  )  [inline, inherited]

Definition at line 267 of file swmodule.h.

00267 { return display(); }

char SWModule::display (  )  [virtual, inherited]

Calls this module's display object and passes itself

Returns:
error status

Definition at line 245 of file swmodule.cpp.

00245                        {
00246      disp->display(*this);
00247      return 0;
00248 }

void zVerse::doLinkEntry ( char  testmt,
long  destidxoff,
long  srcidxoff 
) [protected, inherited]

Definition at line 393 of file zverse.cpp.

00393                                                                      {
00394     __s32 bufidx;
00395     __s32 start;
00396     __u16 size;
00397 
00398     destidxoff *= 10;
00399     srcidxoff  *= 10;
00400 
00401     if (!testmt)
00402         testmt = ((idxfp[1]) ? 1:2);
00403 
00404     // get source
00405     compfp[testmt-1]->seek(srcidxoff, SEEK_SET);
00406     compfp[testmt-1]->read(&bufidx, 4);
00407     compfp[testmt-1]->read(&start, 4);
00408     compfp[testmt-1]->read(&size, 2);
00409 
00410     // write dest
00411     compfp[testmt-1]->seek(destidxoff, SEEK_SET);
00412     compfp[testmt-1]->write(&bufidx, 4);
00413     compfp[testmt-1]->write(&start, 4);
00414     compfp[testmt-1]->write(&size, 2);
00415 }

void zVerse::doSetText ( char  testmt,
long  idxoff,
const char *  buf,
long  len = 0 
) [protected, inherited]

Definition at line 298 of file zverse.cpp.

00298                                                                           {
00299 
00300     len = (len < 0) ? strlen(buf) : len;
00301     if (!testmt) 
00302         testmt = ((idxfp[0]) ? 1:2);
00303     if ((!dirtyCache) || (cacheBufIdx < 0)) {
00304         cacheBufIdx = idxfp[testmt-1]->seek(0, SEEK_END) / 12;
00305         cacheTestament = testmt;
00306         if (cacheBuf)
00307             free(cacheBuf);
00308         cacheBuf = (char *)calloc(len + 1, 1);
00309     }
00310     else cacheBuf = (char *)((cacheBuf)?realloc(cacheBuf, strlen(cacheBuf)+(len + 1)):calloc((len + 1), 1));
00311 
00312     dirtyCache = true;
00313 
00314     __u32 start;
00315     __u16 size;
00316     __u32 outBufIdx = cacheBufIdx;
00317 
00318     idxoff *= 10;
00319     size = len;
00320 
00321     start = strlen(cacheBuf);
00322 
00323     if (!size)
00324         start = outBufIdx = 0;
00325 
00326     outBufIdx = archtosword32(outBufIdx);
00327     start  = archtosword32(start);
00328     size   = archtosword16(size);
00329 
00330     compfp[testmt-1]->seek(idxoff, SEEK_SET);
00331     compfp[testmt-1]->write(&outBufIdx, 4);
00332     compfp[testmt-1]->write(&start, 4);
00333     compfp[testmt-1]->write(&size, 2);
00334     strcat(cacheBuf, buf);
00335 }

SWDEPRECATED char SWModule::Encoding ( signed char  enc = -1  )  [inline, inherited]

Definition at line 343 of file swmodule.h.

00343 { char retVal = getEncoding(); if (enc != -1) encoding = enc; return retVal; }

virtual void SWModule::encodingFilter ( SWBuf buf,
const SWKey key 
) const [inline, virtual, inherited]

encodingFilter run a buf through this module's Encoding Filters

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

Definition at line 561 of file swmodule.h.

00561                                                                     {
00562         filterBuffer(encodingFilters, buf, key);
00563     }

virtual SWDEPRECATED char SWModule::Error (  )  [inline, virtual, inherited]

Definition at line 182 of file swmodule.h.

00182 { return popError(); }

virtual void SWModule::filterBuffer ( FilterList filters,
SWBuf buf,
const SWKey key 
) const [virtual, inherited]

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
void SWModule::filterBuffer ( OptionFilterList filters,
SWBuf buf,
const SWKey key 
) const [virtual, inherited]

OptionFilterBuffer 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

Definition at line 1349 of file swmodule.cpp.

01349                                                                                          {
01350     OptionFilterList::iterator it;
01351     for (it = filters->begin(); it != filters->end(); it++) {
01352         (*it)->processText(buf, key, this);
01353     }
01354 }

void zVerse::findOffset ( char  testmt,
long  idxoff,
long *  start,
unsigned short *  size,
unsigned long *  buffnum 
) const [inherited]

Definition at line 149 of file zverse.cpp.

00150 {
00151     __u32 ulBuffNum    = 0;           // buffer number
00152     __u32 ulVerseStart = 0;        // verse offset within buffer
00153     __u16 usVerseSize  = 0;        // verse size
00154     // set start to offset in
00155     // set size to
00156     // set
00157     *start = *size = *buffnum = 0;
00158     //printf ("Finding offset %ld\n", idxoff);
00159     idxoff *= 10;
00160     if (!testmt) {
00161         testmt = ((idxfp[0]) ? 1:2);
00162     }
00163     
00164     // assert we have and valid file descriptor
00165     if (compfp[testmt-1]->getFd() < 1)
00166         return;
00167         
00168     long newOffset = compfp[testmt-1]->seek(idxoff, SEEK_SET);
00169     if (newOffset == idxoff) {
00170         if (compfp[testmt-1]->read(&ulBuffNum, 4) != 4) {
00171             printf ("Error reading ulBuffNum\n");
00172             return;
00173         }
00174     }
00175     else return;    
00176     
00177     if (compfp[testmt-1]->read(&ulVerseStart, 4) < 2)
00178     {
00179         printf ("Error reading ulVerseStart\n");
00180         return;
00181     }
00182     if (compfp[testmt-1]->read(&usVerseSize, 2) < 2)
00183     {
00184         printf ("Error reading usVerseSize\n");
00185         return;
00186     }
00187 
00188     *buffnum = swordtoarch32(ulBuffNum);
00189     *start = swordtoarch32(ulVerseStart);
00190     *size = swordtoarch16(usVerseSize);
00191 
00192 }

virtual void zCom::flush (  )  [inline, virtual]

Reimplemented from SWCacher.

Definition at line 65 of file zcom.h.

00065 { flushCache(); }

void zVerse::flushCache (  )  const [protected, inherited]

Definition at line 338 of file zverse.cpp.

00338                               {
00339     if (dirtyCache) {
00340         __u32 idxoff;
00341         __u32 start, outstart;
00342         __u32 size, outsize;
00343         __u32 zsize, outzsize;
00344 
00345         idxoff = cacheBufIdx * 12;
00346         if (cacheBuf) {
00347             size = outsize = zsize = outzsize = strlen(cacheBuf);
00348             if (size) {
00349     //          if (compressor) {
00350     //              delete compressor;
00351     //              compressor = new LZSSCompress();
00352     //          }
00353                 compressor->Buf(cacheBuf);
00354                 unsigned long tmpSize;
00355                 compressor->zBuf(&tmpSize);
00356                 outzsize = zsize = tmpSize;
00357 
00358                 SWBuf buf;
00359                 buf.setSize(zsize + 5);
00360                 memcpy(buf.getRawData(), compressor->zBuf(&tmpSize), tmpSize);
00361                 outzsize = zsize = tmpSize;
00362                 buf.setSize(zsize);
00363                 rawZFilter(buf, 1); // 1 = encipher
00364 
00365                 start = outstart = textfp[cacheTestament-1]->seek(0, SEEK_END);
00366 
00367                 outstart  = archtosword32(start);
00368                 outsize   = archtosword32(size);
00369                 outzsize  = archtosword32(zsize);
00370 
00371                 textfp[cacheTestament-1]->write(buf, zsize);
00372 
00373                 idxfp[cacheTestament-1]->seek(idxoff, SEEK_SET);
00374                 idxfp[cacheTestament-1]->write(&outstart, 4);
00375                 idxfp[cacheTestament-1]->write(&outzsize, 4);
00376                 idxfp[cacheTestament-1]->write(&outsize, 4);
00377             }
00378             free(cacheBuf);
00379             cacheBuf = 0;
00380         }
00381         dirtyCache = false;
00382     }
00383 }

virtual const ConfigEntMap& SWModule::getConfig (  )  const [inline, virtual, inherited]

Definition at line 193 of file swmodule.h.

00193 { return *config; }

const char * SWModule::getConfigEntry ( const char *  key  )  const [virtual, inherited]

Definition at line 907 of file swmodule.cpp.

00907                                                           {
00908     ConfigEntMap::iterator it = config->find(key);
00909     return (it != config->end()) ? it->second.c_str() : 0;
00910 }

const char * SWModule::getDescription (  )  const [inherited]

Gets module description

Returns:
pointer to moddesc

Definition at line 191 of file swmodule.cpp.

00191                                            {
00192     return moddesc;
00193 }

char SWModule::getDirection (  )  const [virtual, inherited]

Sets/gets module direction

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

Definition at line 217 of file swmodule.cpp.

00217                                   {
00218         return direction;
00219 }

SWDisplay * SWModule::getDisplay (  )  const [virtual, inherited]

Gets display driver

Returns:
pointer to SWDisplay class for this module

Definition at line 231 of file swmodule.cpp.

00231                                       {
00232     return disp;
00233 }

char SWModule::getEncoding (  )  const [inline, inherited]

Sets/gets module encoding

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

Definition at line 342 of file swmodule.h.

00342 { return encoding; }

virtual AttributeTypeList& SWModule::getEntryAttributes (  )  const [inline, virtual, inherited]

Entry Attributes are special data pertaining to the current entry. To see what Entry Attributes exists for a specific entry of a module, the example examples/cmdline/lookup.cpp is a good utility which displays this information. It is also useful as an example of how to access such.

Definition at line 686 of file swmodule.h.

00686 { return entryAttributes; }

virtual int SWModule::getEntrySize (  )  const [inline, virtual, inherited]
Returns:
The size of the text entry for the module's current key position.

Definition at line 199 of file swmodule.h.

00199 { return entrySize; }

long SWCom::getIndex (  )  const [virtual, inherited]

Reimplemented from SWModule.

Definition at line 71 of file swcom.cpp.

00071                            {
00072     VerseKey *key = &getVerseKey();
00073     entryIndex = key->getIndex();
00074     return entryIndex;
00075 }

SWKey * SWModule::getKey (  )  const [virtual, inherited]

Gets the current module key

Returns:
the current key of this module

Definition at line 257 of file swmodule.cpp.

00257                               {
00258     return key;
00259 }

virtual const char* SWModule::getKeyText (  )  const [inline, virtual, inherited]

gets the key text for the module. do we really need this?

Reimplemented in SWLD.

Definition at line 250 of file swmodule.h.

00250                                            {
00251         return *getKey();
00252     }

const char* SWModule::getLanguage (  )  const [inline, inherited]

Sets/gets module language

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

Definition at line 358 of file swmodule.h.

00358 { return modlang; }

char SWModule::getMarkup (  )  const [inline, inherited]

Sets/gets module markup

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

Definition at line 350 of file swmodule.h.

00350 { return markup; }

const char * SWModule::getName (  )  const [inherited]

Gets module name

Returns:
pointer to modname

Definition at line 177 of file swmodule.cpp.

00177                                     {
00178     return modname;
00179 }

const char* SWModule::getRawEntry (  )  const [inline, inherited]

Definition at line 408 of file swmodule.h.

00408 { return getRawEntryBuf().c_str(); }

SWBuf & zCom::getRawEntryBuf (  )  const [virtual]

This function is reimplemented by the different kinds of module objects

Returns:
the raw module text of the current entry

Implements SWModule.

Definition at line 74 of file zcom.cpp.

00074                                   {
00075     long  start = 0;
00076     unsigned short size = 0;
00077     unsigned long buffnum;
00078     VerseKey *key = &getVerseKey();
00079 
00080     findOffset(key->getTestament(), key->getTestamentIndex(), &start, &size, &buffnum);
00081     entrySize = size;        // support getEntrySize call
00082 
00083     entryBuf = "";
00084     zReadText(key->getTestament(), start, size, buffnum, entryBuf);
00085 
00086     rawFilter(entryBuf, key);
00087 
00088 //  if (!isUnicode())
00089         prepText(entryBuf);
00090 
00091     return entryBuf;
00092 }

virtual const FilterList& SWModule::getRenderFilters (  )  const [inline, virtual, inherited]

Retrieves a container of render filters associated with this module.

Returns:
container of render filters

Definition at line 482 of file swmodule.h.

00482                                                        {
00483         return *renderFilters;
00484     }

const char * SWModule::getRenderHeader (  )  const [virtual, inherited]

Produces any header data which might be useful which associated with the processing done with this filter. A typical example is a suggested CSS style block for classed containers.

SWModule::getRenderHeader() - Produces any header data which might be useful which associated with the processing done with this filter. A typical example is a suggested CSS style block for classed containers.

Definition at line 787 of file swmodule.cpp.

00787                                             {
00788     FilterList::const_iterator first = getRenderFilters().begin();
00789     if (first != getRenderFilters().end()) {
00790         return (*first)->getHeader();
00791     }
00792     return "";
00793 }

SWDEPRECATED bool SWModule::getSkipConsecutiveLinks (  )  [inline, inherited]

Definition at line 675 of file swmodule.h.

00675 { return isSkipConsecutiveLinks(); }

const char * SWModule::getType (  )  const [inherited]

Gets module type

Returns:
pointer to modtype

Definition at line 205 of file swmodule.cpp.

00205                                     {
00206     return modtype;
00207 }

VerseKey & SWCom::getVerseKey ( const SWKey key = 0  )  const [protected, inherited]

Definition at line 88 of file swcom.cpp.

00088                                                             {
00089     const SWKey *thisKey = keyToConvert ? keyToConvert : this->key;
00090 
00091     VerseKey *key = 0;
00092     // see if we have a VerseKey * or decendant
00093     SWTRY {
00094         key = SWDYNAMIC_CAST(VerseKey, thisKey);
00095     }
00096     SWCATCH ( ... ) {   }
00097     if (!key) {
00098         ListKey *lkTest = 0;
00099         SWTRY {
00100             lkTest = SWDYNAMIC_CAST(ListKey, thisKey);
00101         }
00102         SWCATCH ( ... ) {   }
00103         if (lkTest) {
00104             SWTRY {
00105                 key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
00106             }
00107             SWCATCH ( ... ) {   }
00108         }
00109     }
00110     if (!key) {
00111                 VerseKey *retKey = (tmpSecond) ? tmpVK1 : tmpVK2;
00112                 tmpSecond = !tmpSecond;
00113         retKey->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName());
00114         (*retKey) = *(thisKey);
00115         return (*retKey);
00116     }
00117     else    return *key;
00118 }

bool zCom::hasEntry ( const SWKey k  )  const [virtual]

Reimplemented from SWModule.

Definition at line 208 of file zcom.cpp.

00208                                         {
00209     long start;
00210     unsigned short size;
00211     unsigned long buffnum;
00212     VerseKey *vk = &getVerseKey(k);
00213 
00214     findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size, &buffnum);
00215     return size;
00216 }

bool SWModule::hasSearchFramework (  )  [virtual, inherited]

was SWORD compiled with code to optimize searching for this driver?

Reimplemented from SWSearchable.

Definition at line 918 of file swmodule.cpp.

00918                                   {
00919 #ifdef USELUCENE
00920     return true;
00921 #else
00922     return SWSearchable::hasSearchFramework();
00923 #endif
00924 }

void zCom::increment ( int  steps = 1  )  [virtual]

Increments module key a number of entries

Parameters:
steps Number of entries to jump forward

Reimplemented from SWModule.

Definition at line 161 of file zcom.cpp.

00161                               {
00162     long  start;
00163     unsigned short size;
00164     unsigned long buffnum;
00165     VerseKey *tmpkey = &getVerseKey();
00166 
00167     findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size, &buffnum);
00168 
00169     SWKey lastgood = *tmpkey;
00170     while (steps) {
00171         long laststart = start;
00172         unsigned short lastsize = size;
00173         SWKey lasttry = *tmpkey;
00174         (steps > 0) ? ++(*key) : --(*key);
00175         tmpkey = &getVerseKey();
00176 
00177         if ((error = key->popError())) {
00178             *key = lastgood;
00179             break;
00180         }
00181         long index = tmpkey->getTestamentIndex();
00182         findOffset(tmpkey->getTestament(), index, &start, &size, &buffnum);
00183         if (
00184             (((laststart != start) || (lastsize != size))   // we're a different entry
00185 //              && (start > 0) 
00186                 && (size))  // and we actually have a size
00187                 ||(!skipConsecutiveLinks)) {    // or we don't want to skip consecutive links
00188             steps += (steps < 0) ? 1 : -1;
00189             lastgood = *tmpkey;
00190         }
00191     }
00192     error = (error) ? KEYERR_OUTOFBOUNDS : 0;
00193 }

SWDEPRECATED long SWModule::Index ( long  iindex  )  [inline, inherited]

Definition at line 260 of file swmodule.h.

00260 { setIndex(iindex); return getIndex(); }

SWDEPRECATED long SWModule::Index (  )  const [inline, inherited]

Definition at line 258 of file swmodule.h.

00258 { return getIndex(); }

bool zCom::isLinked ( const SWKey k1,
const SWKey k2 
) const [virtual]

Reimplemented from SWModule.

Definition at line 195 of file zcom.cpp.

00195                                                           {
00196     long start1, start2;
00197     unsigned short size1, size2;
00198     unsigned long buffnum1, buffnum2;
00199     VerseKey *vk1 = &getVerseKey(k1);
00200     VerseKey *vk2 = &getVerseKey(k2);
00201     if (vk1->getTestament() != vk2->getTestament()) return false;
00202 
00203     findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1, &buffnum1);
00204     findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2, &buffnum2);
00205     return start1 == start2 && buffnum1 == buffnum2;
00206 }

virtual bool SWModule::isProcessEntryAttributes (  )  const [inline, virtual, inherited]

Whether or not we're processing Entry Attributes

Definition at line 698 of file swmodule.h.

00698 { return procEntAttr; }

bool SWSearchable::isSearchOptimallySupported ( const char *  istr,
int  searchType,
int  flags,
SWKey scope 
) [virtual, inherited]

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 47 of file swsearchable.cpp.

00047                                                                                                        {
00048     bool retVal = false;
00049     search(istr, searchType, flags, scope, &retVal);
00050     return retVal;
00051 }

virtual bool SWModule::isSkipConsecutiveLinks (  )  [inline, virtual, inherited]

Whether or not to only hit one entry when iterating encounters consecutive links when iterating

Definition at line 674 of file swmodule.h.

00674 { return skipConsecutiveLinks; }

virtual bool SWModule::isUnicode (  )  const [inline, virtual, inherited]
Returns:
True if this module is encoded in Unicode, otherwise returns false.

Definition at line 187 of file swmodule.h.

00187 { return (encoding == (char)ENC_UTF8); }

bool zCom::isWritable (  )  const [virtual]

Is the module writable? :)

Returns:
yes or no

Reimplemented from SWModule.

Definition at line 63 of file zcom.cpp.

00063                             {
00064     return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR));
00065 }

SWDEPRECATED SWKey& SWModule::Key (  )  const [inline, inherited]
Deprecated:
Use getKey() instead.

Definition at line 235 of file swmodule.h.

00235 { return *getKey(); }

SWDEPRECATED char SWModule::Key ( const SWKey ikey  )  [inline, inherited]
Deprecated:
Use setKey() instead.

Definition at line 226 of file swmodule.h.

00226 { return setKey(ikey); }

SWDEPRECATED const char* SWModule::KeyText ( const char *  ikeytext = 0  )  [inline, inherited]

Sets/gets module KeyText

Deprecated:
Use getKeyText/setKey
Parameters:
ikeytext Value which to set keytext; [0]-only get
Returns:
pointer to keytext

Definition at line 243 of file swmodule.h.

00243 { if (ikeytext) setKey(ikeytext); return *getKey(); }

SWDEPRECATED const char* SWModule::Lang ( char *  imodlang = 0  )  [inline, inherited]

Definition at line 359 of file swmodule.h.

00359 { if (imodlang != 0) stdstr(&modlang, imodlang); return getLanguage(); }

long SWCacher::lastAccess (  )  [virtual, inherited]

Definition at line 43 of file swcacher.cpp.

00043                           {
00044     return 0;
00045 }

void zCom::linkEntry ( const SWKey sourceKey  )  [virtual]

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

Reimplemented from SWModule.

Definition at line 130 of file zcom.cpp.

00130                                        {
00131     VerseKey *destkey = &getVerseKey();
00132     const VerseKey *srckey = &getVerseKey(inkey);
00133 
00134     doLinkEntry(destkey->getTestament(), destkey->getTestamentIndex(), srckey->getTestamentIndex());
00135 
00136     if (inkey != srckey) // free our key if we created a VerseKey
00137         delete srckey;
00138 }

SWDEPRECATED char SWModule::Markup ( signed char  imarkup = -1  )  [inline, inherited]

Definition at line 351 of file swmodule.h.

00351 { char retVal = getMarkup(); if (imarkup != -1) markup = imarkup; return retVal; }

SWDEPRECATED const char* SWModule::Name ( const char *  imodname  )  [inline, inherited]

Sets module name

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

Definition at line 298 of file swmodule.h.

00298 { stdstr(&modname, imodname); return getName(); }

SWDEPRECATED const char* SWModule::Name (  )  const [inline, inherited]

Definition at line 291 of file swmodule.h.

00291 { return getName(); }

SWORD_NAMESPACE_START void SWSearchable::nullPercent ( char  percent,
void *  userData 
) [static, inherited]

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().

Definition at line 28 of file swsearchable.cpp.

00028 {}

virtual void SWModule::optionFilter ( SWBuf buf,
const SWKey key 
) const [inline, virtual, inherited]

OptionFilter a text buffer

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

Definition at line 621 of file swmodule.h.

00621                                                                   {
00622         filterBuffer(optionFilters, buf, key);
00623     }

char SWModule::popError (  )  [virtual, inherited]

Gets and clears error status

Returns:
error status

Definition at line 159 of file swmodule.cpp.

00160 {
00161     char retval = error;
00162 
00163     error = 0;
00164     return retval;
00165 }

void SWModule::prepText ( SWBuf buf  )  [static, protected, inherited]

Definition at line 1387 of file swmodule.cpp.

01387                                   {
01388     unsigned int to, from; 
01389     char space = 0, cr = 0, realdata = 0, nlcnt = 0;
01390     char *rawBuf = buf.getRawData();
01391     for (to = from = 0; rawBuf[from]; from++) {
01392         switch (rawBuf[from]) {
01393         case 10:
01394             if (!realdata)
01395                 continue;
01396             space = (cr) ? 0 : 1;
01397             cr = 0;
01398             nlcnt++;
01399             if (nlcnt > 1) {
01400 //              *to++ = nl;
01401                 rawBuf[to++] = 10;
01402 //              *to++ = nl[1];
01403 //              nlcnt = 0;
01404             }
01405             continue;
01406         case 13:
01407             if (!realdata)
01408                 continue;
01409 //          *to++ = nl[0];
01410             rawBuf[to++] = 10;
01411             space = 0;
01412             cr = 1;
01413             continue;
01414         }
01415         realdata = 1;
01416         nlcnt = 0;
01417         if (space) {
01418             space = 0;
01419             if (rawBuf[from] != ' ') {
01420                 rawBuf[to++] = ' ';
01421                 from--;
01422                 continue;
01423             }
01424         }
01425         rawBuf[to++] = rawBuf[from];
01426     }
01427     buf.setSize(to);
01428 
01429     while (to > 1) {            // remove trailing excess
01430         to--;
01431         if ((rawBuf[to] == 10) || (rawBuf[to] == ' '))
01432             buf.setSize(to);
01433         else break;
01434     }
01435 }

SWDEPRECATED void SWModule::processEntryAttributes ( bool  val  )  const [inline, inherited]

Definition at line 694 of file swmodule.h.

00694 { setProcessEntryAttributes(val); }

virtual void SWModule::rawFilter ( SWBuf buf,
const SWKey key 
) const [inline, virtual, inherited]

RawFilter a text buffer

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

Definition at line 600 of file swmodule.h.

00600                                                                {
00601         filterBuffer(rawFilters, buf, key);
00602     }

virtual void zCom::rawZFilter ( SWBuf buf,
char  direction = 0 
) const [inline, virtual]

Reimplemented from zVerse.

Definition at line 62 of file zcom.h.

00062 { rawFilter(buf, (SWKey *)(long)direction); }// hack, use key as direction for enciphering

SWDEPRECATED SWModule& SWModule::RemoveEncodingFilter ( SWFilter oldFilter  )  [inline, inherited]

Definition at line 540 of file swmodule.h.

00540 { return removeEncodingFilter(oldFilter); }

virtual SWModule& SWModule::removeEncodingFilter ( SWFilter oldFilter  )  [inline, virtual, inherited]

Removes an EncodingFilter from this module's encodingFilters queue

Parameters:
oldfilter the filter to remove
Returns:
*this

Definition at line 536 of file swmodule.h.

00536                                                                 {
00537         encodingFilters->remove(oldFilter);
00538         return *this;
00539     }

SWDEPRECATED SWModule& SWModule::RemoveRenderFilter ( SWFilter oldFilter  )  [inline, inherited]

Definition at line 494 of file swmodule.h.

00494 {   return removeRenderFilter(oldFilter); }

virtual SWModule& SWModule::removeRenderFilter ( SWFilter oldFilter  )  [inline, virtual, inherited]

Removes a RenderFilter from this module's renderFilters queue

Parameters:
oldfilter the filter to remove
Returns:
*this

Definition at line 490 of file swmodule.h.

00490                                                               {
00491         renderFilters->remove(oldFilter);
00492         return *this;
00493     }

virtual void SWModule::renderFilter ( SWBuf buf,
const SWKey key 
) const [inline, virtual, inherited]

RenderFilter run a buf through this module's Render Filters

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

Definition at line 515 of file swmodule.h.

00515                                                                   {
00516         filterBuffer(renderFilters, buf, key);
00517     }

SWDEPRECATED const char* SWModule::RenderText ( const char *  buf = 0,
int  len = -1,
bool  render = true 
) [inline, inherited]

Definition at line 645 of file swmodule.h.

00645 { return renderText(buf, len, render); }

const char * SWModule::renderText ( const SWKey tmpKey  )  [virtual, inherited]

Produces renderable text of the module entry at the supplied key

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

Definition at line 853 of file swmodule.cpp.

00853                                                      {
00854     SWKey *saveKey;
00855     const char *retVal;
00856 
00857     if (!key->isPersist()) {
00858         saveKey = createKey();
00859         *saveKey = *key;
00860     }
00861     else    saveKey = key;
00862 
00863     setKey(*tmpKey);
00864 
00865     retVal = renderText();
00866 
00867     setKey(*saveKey);
00868 
00869     if (!saveKey->isPersist())
00870         delete saveKey;
00871 
00872     return retVal;
00873 }

const char * SWModule::renderText ( const char *  buf = 0,
int  len = -1,
bool  render = true 
) [virtual, inherited]

Produces renderable text of the current module entry or supplied text

Parameters:
buf buffer to massage instead of current module entry; if buf is 0, the current module position text will be used
len max len to process
render for internal use
Returns:
result buffer

Definition at line 804 of file swmodule.cpp.

00804                                                                        {
00805     bool savePEA = isProcessEntryAttributes();
00806     if (!buf) {
00807         entryAttributes.clear();
00808     }
00809     else {
00810         setProcessEntryAttributes(false);
00811     }
00812 
00813     static SWBuf local;
00814     if (buf)
00815         local = buf;
00816 
00817     SWBuf &tmpbuf = (buf) ? local : getRawEntryBuf();
00818     SWKey *key = 0;
00819     static const char *null = "";
00820 
00821     if (tmpbuf) {
00822         unsigned long size = (len < 0) ? ((getEntrySize()<0) ? strlen(tmpbuf) : getEntrySize()) : len;
00823         if (size > 0) {
00824             key = (SWKey *)*this;
00825 
00826             optionFilter(tmpbuf, key);
00827     
00828             if (render) {
00829                 renderFilter(tmpbuf, key);
00830                 encodingFilter(tmpbuf, key);
00831             }
00832             else    stripFilter(tmpbuf, key);
00833         }
00834     }
00835     else {
00836         tmpbuf = null;
00837     }
00838 
00839     setProcessEntryAttributes(savePEA);
00840 
00841     return tmpbuf;
00842 }

SWDEPRECATED SWModule& SWModule::ReplaceEncodingFilter ( SWFilter oldFilter,
SWFilter newFilter 
) [inline, inherited]

Definition at line 555 of file swmodule.h.

00555 { return replaceEncodingFilter(oldFilter, newFilter); }

virtual SWModule& SWModule::replaceEncodingFilter ( SWFilter oldFilter,
SWFilter newFilter 
) [inline, virtual, inherited]

Replaces an EncodingFilter in this module's encodingfilters queue

Parameters:
oldfilter the filter to remove
newfilter the filter to add in its place
Returns:
*this

Definition at line 547 of file swmodule.h.

00547                                                                                       {
00548         FilterList::iterator iter;
00549         for (iter = encodingFilters->begin(); iter != encodingFilters->end(); iter++) {
00550             if (*iter == oldFilter)
00551                 *iter = newFilter;
00552         }
00553         return *this;
00554     }

SWDEPRECATED SWModule& SWModule::ReplaceRenderFilter ( SWFilter oldFilter,
SWFilter newFilter 
) [inline, inherited]

Definition at line 509 of file swmodule.h.

00509 { return replaceRenderFilter(oldFilter, newFilter); }

virtual SWModule& SWModule::replaceRenderFilter ( SWFilter oldFilter,
SWFilter newFilter 
) [inline, virtual, inherited]

Replaces a RenderFilter in this module's renderfilters queue

Parameters:
oldfilter the filter to remove
newfilter the filter to add in its place
Returns:
*this

Definition at line 501 of file swmodule.h.

00501                                                                                     {
00502         FilterList::iterator iter;
00503         for (iter = renderFilters->begin(); iter != renderFilters->end(); iter++) {
00504             if (*iter == oldFilter)
00505                 *iter = newFilter;
00506         }
00507         return *this;
00508     }

long SWCacher::resourceConsumption (  )  [virtual, inherited]

Reimplemented in FileMgr.

Definition at line 39 of file swcacher.cpp.

00039                                    {
00040     return 0;
00041 }

bool zCom::sameBlock ( VerseKey lastWriteKey,
VerseKey key 
) [private]

Definition at line 95 of file zcom.cpp.

00095                                                {
00096     if (k1->getTestament() != k2->getTestament())
00097         return false;
00098 
00099     switch (blockType) {
00100     case VERSEBLOCKS:
00101         if (k1->getVerse() != k2->getVerse())
00102             return false;
00103     case CHAPTERBLOCKS:
00104         if (k1->getChapter() != k2->getChapter())
00105             return false;
00106     case BOOKBLOCKS:
00107         if (k1->getBook() != k2->getBook())
00108             return false;
00109     }
00110     return true;
00111 }

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

Definition at line 389 of file swmodule.h.

00389 {   return search(istr, searchType, flags, scope, justCheckIfSupported, percent, percentUserData);  }

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

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 -3 - entryAttrib (eg. Word//Strongs/G1234/) -4 - Lucene
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

Implements SWSearchable.

Definition at line 366 of file swmodule.cpp.

00366                                                                                                                                                                      {
00367 
00368     listKey.ClearList();
00369     SWBuf term = istr;
00370     bool includeComponents = false; // for entryAttrib e.g., /Lemma.1/ 
00371 
00372 #ifdef USELUCENE
00373     SWBuf target = getConfigEntry("AbsoluteDataPath");
00374     if (!target.endsWith("/") && !target.endsWith("\\")) {
00375         target.append('/');
00376     }
00377     target.append("lucene");
00378 #endif
00379     if (justCheckIfSupported) {
00380         *justCheckIfSupported = (searchType >= -3);
00381 #ifdef USELUCENE
00382         if ((searchType == -4) && (IndexReader::indexExists(target.c_str()))) {
00383             *justCheckIfSupported = true;
00384         }
00385 #endif
00386         return listKey;
00387     }
00388     
00389     SWKey *saveKey = 0;
00390     SWKey *searchKey = 0;
00391     SWKey *resultKey = createKey();
00392     regex_t preg;
00393     vector<SWBuf> words;
00394     vector<SWBuf> window;
00395     const char *sres;
00396     terminateSearch = false;
00397     char perc = 1;
00398     bool savePEA = isProcessEntryAttributes();
00399 
00400     // determine if we might be doing special strip searches.  useful for knowing if we can use shortcuts
00401     bool specialStrips = (getConfigEntry("LocalStripFilter")
00402                        || (getConfig().has("GlobalOptionFilter", "UTF8GreekAccents"))
00403                        || (getConfig().has("GlobalOptionFilter", "UTF8HebrewPoints"))
00404                        || (getConfig().has("GlobalOptionFilter", "UTF8ArabicPoints"))
00405                        || (strchr(istr, '<')));
00406 
00407     setProcessEntryAttributes(searchType == -3);
00408     
00409 
00410     if (!key->isPersist()) {
00411         saveKey = createKey();
00412         *saveKey = *key;
00413     }
00414     else    saveKey = key;
00415 
00416     searchKey = (scope)?scope->clone():(key->isPersist())?key->clone():0;
00417     if (searchKey) {
00418         searchKey->setPersist(true);
00419         setKey(*searchKey);
00420     }
00421 
00422     (*percent)(perc, percentUserData);
00423 
00424     *this = BOTTOM;
00425     long highIndex = key->getIndex();
00426     if (!highIndex)
00427         highIndex = 1;      // avoid division by zero errors.
00428     *this = TOP;
00429     if (searchType >= 0) {
00430         flags |=searchType|REG_NOSUB|REG_EXTENDED;
00431         regcomp(&preg, istr, flags);
00432     }
00433 
00434     (*percent)(++perc, percentUserData);
00435 
00436 
00437 #ifdef USELUCENE
00438     if (searchType == -4) { // lucene
00439         
00440         lucene::index::IndexReader    *ir = 0;
00441         lucene::search::IndexSearcher *is = 0;
00442         Query                         *q  = 0;
00443         Hits                          *h  = 0;
00444         SWTRY {
00445             ir = IndexReader::open(target);
00446             is = new IndexSearcher(ir);
00447             (*percent)(10, percentUserData);
00448 
00449             const TCHAR *stopWords[] = { 0 };
00450             standard::StandardAnalyzer analyzer(stopWords);
00451             q = QueryParser::parse((wchar_t *)utf8ToWChar(istr).getRawData(), _T("content"), &analyzer);
00452             (*percent)(20, percentUserData);
00453             h = is->search(q);
00454             (*percent)(80, percentUserData);
00455 
00456             // iterate thru each good module position that meets the search
00457             bool checkBounds = getKey()->isBoundSet();
00458             for (unsigned long i = 0; i < (unsigned long)h->length(); i++) {
00459                 Document &doc = h->doc(i);
00460 
00461                 // set a temporary verse key to this module position
00462                 *resultKey = wcharToUTF8(doc.get(_T("key"))); //TODO Does a key always accept utf8?
00463 
00464                 // check to see if it sets ok (within our bounds) and if not, skip
00465                 if (checkBounds) {
00466                     *getKey() = *resultKey;
00467                     if (*getKey() != *resultKey) {
00468                         continue;
00469                     }
00470                 }
00471                 listKey << *resultKey;
00472                 listKey.GetElement()->userData = (__u64)((__u32)(h->score(i)*100));
00473             }
00474             (*percent)(98, percentUserData);
00475         }
00476         SWCATCH (...) {
00477             q = 0;
00478             // invalid clucene query
00479         }
00480         delete h;
00481         delete q;
00482 
00483         delete is;
00484         if (ir) {
00485             ir->close();
00486         }
00487     }
00488 #endif
00489 
00490     // some pre-loop processing
00491     switch (searchType) {
00492 
00493     // phrase
00494     case -1:
00495         // let's see if we're told to ignore case.  If so, then we'll touppstr our term
00496         if ((flags & REG_ICASE) == REG_ICASE) toupperstr(term);
00497         break;
00498 
00499     // multi-word
00500     case -2:
00501     case -5:
00502         // let's break the term down into our words vector
00503         while (1) {
00504             const char *word = term.stripPrefix(' ');
00505             if (!word) {
00506                 words.push_back(term);
00507                 break;
00508             }
00509             words.push_back(word);
00510         }
00511         if ((flags & REG_ICASE) == REG_ICASE) {
00512             for (unsigned int i = 0; i < words.size(); i++) {
00513                 toupperstr(words[i]);
00514             }
00515         }
00516         break;
00517 
00518     // entry attributes
00519     case -3:
00520         // let's break the attribute segs down.  We'll reuse our words vector for each segment
00521         while (1) {
00522             const char *word = term.stripPrefix('/');
00523             if (!word) {
00524                 words.push_back(term);
00525                 break;
00526             }
00527             words.push_back(word);
00528         }
00529         if ((words.size()>2) && words[2].endsWith(".")) {
00530             includeComponents = true;
00531             words[2]--;
00532         }
00533         break;
00534     }
00535 
00536 
00537     // our main loop to iterate the module and find the stuff
00538     perc = 5;
00539     (*percent)(perc, percentUserData);
00540 
00541     
00542     while ((searchType != -4) && !popError() && !terminateSearch) {
00543         long mindex = key->getIndex();
00544         float per = (float)mindex / highIndex;
00545         per *= 93;
00546         per += 5;
00547         char newperc = (char)per;
00548         if (newperc > perc) {
00549             perc = newperc;
00550             (*percent)(perc, percentUserData);
00551         }
00552         else if (newperc < perc) {
00553 #ifndef _MSC_VER
00554             std::cerr << "Serious error: new percentage complete is less than previous value\n";
00555             std::cerr << "index: " << (key->getIndex()) << "\n";
00556             std::cerr << "highIndex: " << highIndex << "\n";
00557             std::cerr << "newperc ==" << (int)newperc << "%" << "is smaller than\n";
00558             std::cerr << "perc == "  << (int )perc << "% \n";
00559 #endif
00560         }
00561         if (searchType >= 0) {
00562             if (!regexec(&preg,  stripText(), 0, 0, 0)) {
00563                 *resultKey = *getKey();
00564                 resultKey->clearBound();
00565                 listKey << *resultKey;
00566             }
00567         }
00568 
00569         // phrase
00570         else {
00571             SWBuf textBuf;
00572             switch (searchType) {
00573 
00574             // phrase
00575             case -1:
00576                 textBuf = stripText();
00577                 if ((flags & REG_ICASE) == REG_ICASE) toupperstr(textBuf);
00578                 sres = strstr(textBuf.c_str(), term.c_str());
00579                 if (sres) { //it's also in the stripText(), so we have a valid search result item now
00580                     *resultKey = *getKey();
00581                     resultKey->clearBound();
00582                     listKey << *resultKey;
00583                 }
00584                 break;
00585 
00586             // multiword
00587             case -2: { // enclose our allocations
00588                 int loopCount = 0;
00589                 unsigned int foundWords = 0;
00590                 do {
00591                     textBuf = ((loopCount == 0)&&(!specialStrips)) ? getRawEntry() : stripText();
00592                     foundWords = 0;
00593                     
00594                     for (unsigned int i = 0; i < words.size(); i++) {
00595                         if ((flags & REG_ICASE) == REG_ICASE) toupperstr(textBuf);
00596                         sres = strstr(textBuf.c_str(), words[i].c_str());
00597                         if (!sres) {
00598                             break; //for loop
00599                         }
00600                         foundWords++;
00601                     }
00602                     
00603                     loopCount++;
00604                 } while ( (loopCount < 2) && (foundWords == words.size()));
00605                 
00606                 if ((loopCount == 2) && (foundWords == words.size())) { //we found the right words in both raw and stripped text, which means it's a valid result item
00607                     *resultKey = *getKey();
00608                     resultKey->clearBound();
00609                     listKey << *resultKey;
00610                 }
00611                 }
00612                 break;
00613 
00614             // entry attributes
00615             case -3: {
00616                 renderText();   // force parse
00617                 AttributeTypeList &entryAttribs = getEntryAttributes();
00618                 AttributeTypeList::iterator i1Start, i1End;
00619                 AttributeList::iterator i2Start, i2End;
00620                 AttributeValue::iterator i3Start, i3End;
00621 
00622                 if ((words.size()) && (words[0].length())) {
00623 // cout << "Word: " << words[0] << endl;
00624                 for (i1Start = entryAttribs.begin(); i1Start != entryAttribs.end(); ++i1Start) {
00625 // cout << "stuff: " << i1Start->first.c_str() << endl;
00626                 }
00627                     i1Start = entryAttribs.find(words[0]);
00628                     i1End = i1Start;
00629                     if (i1End != entryAttribs.end()) {
00630                         i1End++;
00631                     }
00632                 }
00633                 else {
00634                     i1Start = entryAttribs.begin();
00635                     i1End   = entryAttribs.end();
00636                 }
00637                 for (;i1Start != i1End; i1Start++) {
00638                     if ((words.size()>1) && (words[1].length())) {
00639                         i2Start = i1Start->second.find(words[1]);
00640                         i2End = i2Start;
00641                         if (i2End != i1Start->second.end())
00642                             i2End++;
00643                     }
00644                     else {
00645                         i2Start = i1Start->second.begin();
00646                         i2End   = i1Start->second.end();
00647                     }
00648                     for (;i2Start != i2End; i2Start++) {
00649                         if ((words.size()>2) && (words[2].length()) && (!includeComponents)) {
00650                             i3Start = i2Start->second.find(words[2]);
00651                             i3End = i3Start;
00652                             if (i3End != i2Start->second.end())
00653                                 i3End++;
00654                         }
00655                         else {
00656                             i3Start = i2Start->second.begin();
00657                             i3End   = i2Start->second.end();
00658                         }
00659                         for (;i3Start != i3End; i3Start++) {
00660                             if ((words.size()>3) && (words[3].length())) {
00661                                 if (includeComponents) {
00662                                     SWBuf key = i3Start->first.c_str();
00663                                     key = key.stripPrefix('.', true);
00664                                     // we're iterating all 3 level keys, so be sure we match our
00665                                     // prefix (e.g., Lemma, Lemma.1, Lemma.2, etc.)
00666                                     if (key != words[2]) continue;
00667                                 }
00668                                 if (flags & SEARCHFLAG_MATCHWHOLEENTRY) {
00669                                     bool found = !(((flags & REG_ICASE) == REG_ICASE) ? sword::stricmp(i3Start->second.c_str(), words[3]) : strcmp(i3Start->second.c_str(), words[3]));
00670                                     sres = (found) ? i3Start->second.c_str() : 0;
00671                                 }
00672                                 else {
00673                                     sres = ((flags & REG_ICASE) == REG_ICASE) ? stristr(i3Start->second.c_str(), words[3]) : strstr(i3Start->second.c_str(), words[3]);
00674                                 }
00675                                 if (sres) {
00676                                     *resultKey = *getKey();
00677                                     resultKey->clearBound();
00678                                     listKey << *resultKey;
00679                                     break;
00680                                 }
00681                             }
00682                         }
00683                         if (i3Start != i3End)
00684                             break;
00685                     }
00686                     if (i2Start != i2End)
00687                         break;
00688                 }
00689                 break;
00690             }
00691             case -5:
00692                 AttributeList &words = getEntryAttributes()["Word"];
00693                 SWBuf kjvWord = "";
00694                 SWBuf bibWord = "";
00695                 for (AttributeList::iterator it = words.begin(); it != words.end(); it++) {
00696                     int parts = atoi(it->second["PartCount"]);
00697                     SWBuf lemma = "";
00698                     SWBuf morph = "";
00699                     for (int i = 1; i <= parts; i++) {
00700                         SWBuf key = "";
00701                         key = (parts == 1) ? "Lemma" : SWBuf().setFormatted("Lemma.%d", i).c_str();
00702                         AttributeValue::iterator li = it->second.find(key);
00703                         if (li != it->second.end()) {
00704                             if (i > 1) lemma += " ";
00705                             key = (parts == 1) ? "LemmaClass" : SWBuf().setFormatted("LemmaClass.%d", i).c_str();
00706                             AttributeValue::iterator lci = it->second.find(key);
00707                             if (lci != it->second.end()) {
00708                                 lemma += lci->second + ":";
00709                             }
00710                             lemma += li->second;
00711                         }
00712                         key = (parts == 1) ? "Morph" : SWBuf().setFormatted("Morph.%d", i).c_str();
00713                         li = it->second.find(key);
00714                         // silly.  sometimes morph counts don't equal lemma counts
00715                         if (i == 1 && parts != 1 && li == it->second.end()) {
00716                             li = it->second.find("Morph");
00717                         }
00718                         if (li != it->second.end()) {
00719                             if (i > 1) morph += " ";
00720                             key = (parts == 1) ? "MorphClass" : SWBuf().setFormatted("MorphClass.%d", i).c_str();
00721                             AttributeValue::iterator lci = it->second.find(key);
00722                             // silly.  sometimes morph counts don't equal lemma counts
00723                             if (i == 1 && parts != 1 && lci == it->second.end()) {
00724                                 lci = it->second.find("MorphClass");
00725                             }
00726                             if (lci != it->second.end()) {
00727                                 morph += lci->second + ":";
00728                             }
00729                             morph += li->second;
00730                         }
00731                         // TODO: add src tags and maybe other attributes
00732                     }
00733                     while (window.size() < (unsigned)flags) {
00734                         
00735                     }
00736                 }
00737                 break;
00738             } // end switch
00739         }
00740         (*this)++;
00741     }
00742     
00743 
00744     // cleaup work
00745     if (searchType >= 0)
00746         regfree(&preg);
00747 
00748     setKey(*saveKey);
00749 
00750     if (!saveKey->isPersist())
00751         delete saveKey;
00752 
00753     if (searchKey)
00754         delete searchKey;
00755     delete resultKey;
00756 
00757     listKey = TOP;
00758     setProcessEntryAttributes(savePEA);
00759 
00760 
00761     (*percent)(100, percentUserData);
00762 
00763 
00764     return listKey;
00765 }

void SWModule::setConfig ( ConfigEntMap config  )  [virtual, inherited]

Definition at line 913 of file swmodule.cpp.

00913                                              {
00914     this->config = config;
00915 }

void SWModule::setDisplay ( SWDisplay idisp  )  [virtual, inherited]

Sets display driver

Parameters:
idisp pointer to SWDisplay class to assign to this module

Definition at line 235 of file swmodule.cpp.

00235                                           {
00236     disp = idisp;
00237 }

void zCom::setEntry ( const char *  inbuf,
long  len = -1 
) [virtual]

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

Reimplemented from SWModule.

Definition at line 113 of file zcom.cpp.

00113                                                {
00114     VerseKey *key = &getVerseKey();
00115 
00116     // see if we've jumped across blocks since last write
00117     if (lastWriteKey) {
00118         if (!sameBlock(lastWriteKey, key)) {
00119             flushCache();
00120         }
00121         delete lastWriteKey;
00122     }
00123 
00124     doSetText(key->getTestament(), key->getTestamentIndex(), inbuf, len);
00125 
00126     lastWriteKey = (VerseKey *)key->clone();    // must delete
00127 }

void SWCom::setIndex ( long  iindex  )  [virtual, inherited]

Reimplemented from SWModule.

Definition at line 77 of file swcom.cpp.

00077                                 {
00078     VerseKey *key = &getVerseKey();
00079     key->setTestament(1);
00080     key->setIndex(iindex);
00081 
00082     if (key != this->key) {
00083         this->key->copyFrom(*key);
00084     }
00085 }

SWDEPRECATED char SWModule::SetKey ( const SWKey ikey  )  [inline, inherited]
Deprecated:
Use setKey() instead.

Definition at line 222 of file swmodule.h.

00222 { return setKey(ikey); }

SWDEPRECATED char SWModule::SetKey ( const SWKey ikey  )  [inline, inherited]
Deprecated:
Use setKey() instead.

Definition at line 218 of file swmodule.h.

00218 { return setKey(ikey); }

char SWModule::setKey ( const SWKey ikey  )  [inline, inherited]

Sets a key to this module for position to a particular record

Parameters:
ikey The SWKey which should be used as new key.
Returns:
Error status

Definition at line 214 of file swmodule.h.

00214 { return setKey(&ikey); }

char SWModule::setKey ( const SWKey ikey  )  [virtual, inherited]

Sets a key to this module for position to a particular record

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

Definition at line 271 of file swmodule.cpp.

00271                                        {
00272     SWKey *oldKey = 0;
00273 
00274     if (key) {
00275         if (!key->isPersist())  // if we have our own copy
00276             oldKey = key;
00277     }
00278 
00279     if (!ikey->isPersist()) {       // if we are to keep our own copy
00280          key = createKey();
00281         *key = *ikey;
00282     }
00283     else     key = (SWKey *)ikey;       // if we are to just point to an external key
00284 
00285     if (oldKey)
00286         delete oldKey;
00287 
00288     return 0;
00289 }

void SWModule::setPosition ( SW_POSITION  pos  )  [virtual, inherited]

Positions this modules to a logical position entry

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

Reimplemented in SWLD.

Definition at line 300 of file swmodule.cpp.

00300                                         {
00301     *key = p;
00302     char saveError = key->popError();
00303 
00304     switch (p) {
00305     case POS_TOP:
00306         (*this)++;
00307         (*this)--;
00308         break;
00309 
00310     case POS_BOTTOM:
00311         (*this)--;
00312         (*this)++;
00313         break;
00314     }
00315 
00316     error = saveError;
00317 }

virtual void SWModule::setProcessEntryAttributes ( bool  val  )  const [inline, virtual, inherited]

Processing Entry Attributes can be expensive. This method allows turning the processing off if they are not desired. Some internal engine processing turns them off (like searching) temporarily for optimization.

Definition at line 693 of file swmodule.h.

00693 { procEntAttr = val; }

virtual void SWModule::setSkipConsecutiveLinks ( bool  val  )  [inline, virtual, inherited]

Whether or not to only hit one entry when iterating encounters consecutive links when iterating

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

Definition at line 669 of file swmodule.h.

00669 { skipConsecutiveLinks = val; }

void SWModule::setType ( const char *  imodtype  )  [inline, inherited]

Definition at line 327 of file swmodule.h.

00327 { stdstr(&modtype, imodtype); }

virtual void SWModule::stripFilter ( SWBuf buf,
const SWKey key 
) const [inline, virtual, inherited]

StripFilter run a buf through this module's Strip Filters

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

Definition at line 591 of file swmodule.h.

00591                                                                  {
00592         filterBuffer(stripFilters, buf, key);
00593     }

SWDEPRECATED const char* SWModule::StripText ( const char *  buf = 0,
int  len = -1 
) [inline, inherited]

Definition at line 634 of file swmodule.h.

00634 { return stripText(buf, len); }

const char * SWModule::stripText ( const SWKey tmpKey  )  [virtual, inherited]

Produces plain text, without markup, of the module entry at the supplied key

Parameters:
tmpKey desired module entry
Returns:
result buffer

Definition at line 884 of file swmodule.cpp.

00884                                                    {
00885     SWKey *saveKey;
00886     const char *retVal;
00887 
00888     if (!key->isPersist()) {
00889         saveKey = createKey();
00890         *saveKey = *key;
00891     }
00892     else    saveKey = key;
00893 
00894     setKey(*tmpKey);
00895 
00896     retVal = stripText();
00897 
00898     setKey(*saveKey);
00899 
00900     if (!saveKey->isPersist())
00901         delete saveKey;
00902 
00903     return retVal;
00904 }

const char * SWModule::stripText ( const char *  buf = 0,
int  len = -1 
) [virtual, inherited]

Produces plain text, without markup, of the current module entry, or supplied text

Parameters:
buf buf to massage instead of current module entry; if buf is 0, the current text will be used
len max len to process
Returns:
result buffer

Definition at line 777 of file swmodule.cpp.

00777                                                         {
00778     return renderText(buf, len, false);
00779 }

SWDEPRECATED const char* SWModule::Type ( const char *  imodtype  )  [inline, inherited]

Sets module type

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

Definition at line 326 of file swmodule.h.

00326 { setType(imodtype); return getType(); }

SWDEPRECATED const char* SWModule::Type (  )  const [inline, inherited]

Definition at line 319 of file swmodule.h.

00319 { return getType(); }

void zVerse::zReadText ( char  testmt,
long  start,
unsigned short  size,
unsigned long  buffnum,
SWBuf buf 
) const [inherited]

Definition at line 205 of file zverse.cpp.

00205                                                                                                                 {
00206     __u32 ulCompOffset = 0;        // compressed buffer start
00207     __u32 ulCompSize   = 0;              // buffer size compressed
00208     __u32 ulUnCompSize = 0;           // buffer size uncompressed
00209 
00210     if (!testmt) {
00211         testmt = ((idxfp[0]) ? 1:2);
00212     }
00213     
00214     // assert we have and valid file descriptor
00215     if (compfp[testmt-1]->getFd() < 1)
00216         return;
00217     
00218     if (size && 
00219         !(((long) ulBuffNum == cacheBufIdx) && (testmt == cacheTestament) && (cacheBuf))) {
00220         //printf ("Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize);
00221 
00222         if (idxfp[testmt-1]->seek(ulBuffNum*12, SEEK_SET)!=(long) ulBuffNum*12)
00223         {
00224             printf ("Error seeking compressed file index\n");
00225             return;
00226         }
00227         if (idxfp[testmt-1]->read(&ulCompOffset, 4)<4)
00228         {
00229             printf ("Error reading ulCompOffset\n");
00230             return;
00231         }
00232         if (idxfp[testmt-1]->read(&ulCompSize, 4)<4)
00233         {
00234             printf ("Error reading ulCompSize\n");
00235             return;
00236         }
00237         if (idxfp[testmt-1]->read(&ulUnCompSize, 4)<4)
00238         {
00239             printf ("Error reading ulUnCompSize\n");
00240             return;
00241         }
00242 
00243         ulCompOffset  = swordtoarch32(ulCompOffset);
00244         ulCompSize  = swordtoarch32(ulCompSize);
00245         ulUnCompSize  = swordtoarch32(ulUnCompSize);
00246 
00247         if (textfp[testmt-1]->seek(ulCompOffset, SEEK_SET)!=(long)ulCompOffset)
00248         {
00249             printf ("Error: could not seek to right place in compressed text\n");
00250             return;
00251         }
00252         SWBuf pcCompText;
00253         pcCompText.setSize(ulCompSize+5);
00254 
00255         if (textfp[testmt-1]->read(pcCompText.getRawData(), ulCompSize)<(long)ulCompSize) {
00256             printf ("Error reading compressed text\n");
00257             return;
00258         }
00259         pcCompText.setSize(ulCompSize);
00260         rawZFilter(pcCompText, 0); // 0 = decipher
00261         
00262         unsigned long bufSize = ulCompSize;
00263         compressor->zBuf(&bufSize, pcCompText.getRawData());
00264 
00265         if (cacheBuf) {
00266             flushCache();
00267             free(cacheBuf);
00268         }
00269         
00270         unsigned long len = 0;
00271         compressor->Buf(0, &len);
00272         cacheBuf = (char *)calloc(len + 1, 1);
00273         memcpy(cacheBuf, compressor->Buf(), len);
00274         cacheBufSize = strlen(cacheBuf);  // TODO: can we just use len?
00275         cacheTestament = testmt;
00276         cacheBufIdx = ulBuffNum;
00277     }   
00278     
00279     inBuf = "";
00280     if ((size > 0) && cacheBuf && ((unsigned)start < cacheBufSize)) {
00281         inBuf.setFillByte(0);
00282         inBuf.setSize(size+1);
00283         strncpy(inBuf.getRawData(), &(cacheBuf[start]), size);
00284         inBuf.setSize(strlen(inBuf.c_str()));
00285     }
00286 }


Member Data Documentation

int zCom::blockType [private]

Definition at line 36 of file zcom.h.

char* zVerse::cacheBuf [mutable, protected, inherited]

Definition at line 32 of file zverse.h.

long zVerse::cacheBufIdx [mutable, protected, inherited]

Definition at line 35 of file zverse.h.

unsigned int zVerse::cacheBufSize [mutable, protected, inherited]

Definition at line 33 of file zverse.h.

char zVerse::cacheTestament [mutable, protected, inherited]

Definition at line 34 of file zverse.h.

FileDesc* zVerse::compfp[2] [protected, inherited]

Definition at line 27 of file zverse.h.

ConfigEntMap* SWModule::config [protected, inherited]

Definition at line 105 of file swmodule.h.

char SWModule::direction [protected, inherited]

Definition at line 121 of file swmodule.h.

bool zVerse::dirtyCache [mutable, protected, inherited]

Definition at line 36 of file zverse.h.

SWDisplay* SWModule::disp [protected, inherited]

this module's display object

Definition at line 126 of file swmodule.h.

char SWModule::encoding [protected, inherited]

Definition at line 123 of file swmodule.h.

FilterList* SWModule::encodingFilters [protected, inherited]

filters to be executed to decode text for display

Definition at line 144 of file swmodule.h.

AttributeTypeList SWModule::entryAttributes [mutable, protected, inherited]

Definition at line 106 of file swmodule.h.

SWBuf SWModule::entryBuf [mutable, protected, inherited]

Definition at line 129 of file swmodule.h.

long SWModule::entryIndex [mutable, protected, inherited]

Definition at line 147 of file swmodule.h.

int SWModule::entrySize [mutable, protected, inherited]

Definition at line 146 of file swmodule.h.

char SWModule::error [mutable, protected, inherited]

Definition at line 109 of file swmodule.h.

FileDesc* zVerse::idxfp[2] [protected, inherited]

Definition at line 25 of file zverse.h.

SWORD_NAMESPACE_START int zVerse::instance = 0 [static, protected, inherited]

Definition at line 23 of file zverse.h.

SWKey* SWModule::key [protected, inherited]

the current key

Definition at line 113 of file swmodule.h.

Definition at line 34 of file zcom.h.

ListKey SWModule::listKey [protected, inherited]

Definition at line 115 of file swmodule.h.

char SWModule::markup [protected, inherited]

Definition at line 122 of file swmodule.h.

char* SWModule::moddesc [protected, inherited]

Definition at line 117 of file swmodule.h.

char* SWModule::modlang [protected, inherited]

Definition at line 119 of file swmodule.h.

char* SWModule::modname [protected, inherited]

Definition at line 116 of file swmodule.h.

char* SWModule::modtype [protected, inherited]

Definition at line 118 of file swmodule.h.

char zVerse::nl [inherited]

Definition at line 45 of file zverse.h.

OptionFilterList* SWModule::optionFilters [protected, inherited]

filters to be executed to change markup to user prefs

Definition at line 141 of file swmodule.h.

ConfigEntMap SWModule::ownConfig [protected, inherited]

Definition at line 104 of file swmodule.h.

char* zVerse::path [protected, inherited]

Definition at line 28 of file zverse.h.

bool SWModule::procEntAttr [mutable, protected, inherited]

Definition at line 107 of file swmodule.h.

SWORD_NAMESPACE_START SWModule::StdOutDisplay SWModule::rawdisp [static, protected, inherited]

Definition at line 128 of file swmodule.h.

FilterList* SWModule::rawFilters [protected, inherited]

filters to be executed immediately upon fileread

Definition at line 135 of file swmodule.h.

FilterList* SWModule::renderFilters [protected, inherited]

filters to be executed to format for display

Definition at line 138 of file swmodule.h.

bool SWModule::skipConsecutiveLinks [protected, inherited]

Definition at line 110 of file swmodule.h.

FilterList* SWModule::stripFilters [protected, inherited]

filters to be executed to remove all markup (for searches)

Definition at line 132 of file swmodule.h.

bool SWModule::terminateSearch [inherited]

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 from another thread.

Definition at line 158 of file swmodule.h.

FileDesc* zVerse::textfp[2] [protected, inherited]

Definition at line 26 of file zverse.h.

const char zVerse::uniqueIndexID = {'X', 'r', 'v', 'c', 'b'} [static, inherited]

Definition at line 44 of file zverse.h.


The documentation for this class was generated from the following files:

Generated on 18 Mar 2013 for The SWORD Project by  doxygen 1.6.1