#include <echomod.h>


Public Member Functions | |
| SWDEPRECATED SWModule & | AddEncodingFilter (SWFilter *newFilter) |
| virtual SWModule & | addEncodingFilter (SWFilter *newFilter) |
| SWDEPRECATED SWModule & | AddOptionFilter (SWOptionFilter *newFilter) |
| virtual SWModule & | addOptionFilter (SWOptionFilter *newFilter) |
| SWDEPRECATED SWModule & | AddRawFilter (SWFilter *newFilter) |
| virtual SWModule & | addRawFilter (SWFilter *newfilter) |
| SWDEPRECATED SWModule & | AddRenderFilter (SWFilter *newFilter) |
| virtual SWModule & | addRenderFilter (SWFilter *newFilter) |
| SWDEPRECATED SWModule & | AddStripFilter (SWFilter *newFilter) |
| virtual SWModule & | addStripFilter (SWFilter *newFilter) |
| SWDEPRECATED SWKey * | CreateKey () const |
| virtual SWKey * | createKey () 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 SWDisplay * | Disp (SWDisplay *idisp=0) |
| SWDEPRECATED char | Display () |
| virtual char | display () |
| EchoMod () | |
| 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 |
| virtual void | flush () |
| virtual const ConfigEntMap & | getConfig () const |
| virtual const char * | getConfigEntry (const char *key) const |
| const char * | getDescription () const |
| virtual char | getDirection () const |
| virtual SWDisplay * | getDisplay () const |
| char | getEncoding () const |
| virtual AttributeTypeList & | getEntryAttributes () const |
| virtual int | getEntrySize () const |
| virtual long | getIndex () const |
| virtual SWKey * | getKey () const |
| virtual const char * | getKeyText () const |
| const char * | getLanguage () const |
| char | getMarkup () const |
| const char * | getName () const |
| const char * | getRawEntry () const |
| virtual SWBuf & | getRawEntryBuf () const |
| virtual const FilterList & | getRenderFilters () const |
| virtual const char * | getRenderHeader () const |
| SWDEPRECATED bool | getSkipConsecutiveLinks () |
| const char * | getType () const |
| virtual bool | hasEntry (const SWKey *) const |
| virtual bool | hasSearchFramework () |
| virtual void | increment (int steps=1) |
| SWDEPRECATED long | Index (long iindex) |
| SWDEPRECATED long | Index () const |
| virtual bool | isLinked (const SWKey *, const SWKey *) 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 SWKey & | Key () 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 *sourceKey) |
| 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 |
| SWDEPRECATED SWModule & | RemoveEncodingFilter (SWFilter *oldFilter) |
| virtual SWModule & | removeEncodingFilter (SWFilter *oldFilter) |
| SWDEPRECATED SWModule & | RemoveRenderFilter (SWFilter *oldFilter) |
| virtual SWModule & | removeRenderFilter (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 SWModule & | ReplaceEncodingFilter (SWFilter *oldFilter, SWFilter *newFilter) |
| virtual SWModule & | replaceEncodingFilter (SWFilter *oldFilter, SWFilter *newFilter) |
| SWDEPRECATED SWModule & | ReplaceRenderFilter (SWFilter *oldFilter, SWFilter *newFilter) |
| virtual SWModule & | replaceRenderFilter (SWFilter *oldFilter, SWFilter *newFilter) |
| virtual long | resourceConsumption () |
| SWDEPRECATED ListKey & | Search (const char *istr, int searchType=0, int flags=0, SWKey *scope=0, bool *justCheckIfSupported=0, void(*percent)(char, void *)=&nullPercent, void *percentUserData=0) |
| virtual ListKey & | search (const char *istr, int searchType=0, int flags=0, SWKey *scope=0, bool *justCheckIfSupported=0, void(*percent)(char, void *)=&nullPercent, void *percentUserData=0) |
| virtual 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 |
| virtual | ~EchoMod () |
Static Public Member Functions | |
| static signed char | createModule (const char *path) |
| static void | nullPercent (char percent, void *userData) |
Public Attributes | |
| bool | terminateSearch |
Protected Member Functions | |
| VerseKey & | getVerseKey (const SWKey *key=0) const |
Static Protected Member Functions | |
| static void | prepText (SWBuf &buf) |
Protected Attributes | |
| ConfigEntMap * | config |
| char | direction |
| SWDisplay * | disp |
| char | encoding |
| FilterList * | encodingFilters |
| AttributeTypeList | entryAttributes |
| SWBuf | entryBuf |
| long | entryIndex |
| int | entrySize |
| char | error |
| SWKey * | key |
| ListKey | listKey |
| char | markup |
| char * | moddesc |
| char * | modlang |
| char * | modname |
| char * | modtype |
| OptionFilterList * | optionFilters |
| ConfigEntMap | ownConfig |
| bool | procEntAttr |
| FilterList * | rawFilters |
| FilterList * | renderFilters |
| bool | skipConsecutiveLinks |
| FilterList * | stripFilters |
Static Protected Attributes | |
| static StdOutDisplay | rawdisp |
Definition at line 32 of file echomod.h.
| SWORD_NAMESPACE_START EchoMod::EchoMod | ( | ) |
Definition at line 27 of file echomod.cpp.
00027 : SWText("echomod", "Echos back key") 00028 { 00029 }
| EchoMod::~EchoMod | ( | ) | [virtual] |
Definition at line 32 of file echomod.cpp.
Definition at line 530 of file swmodule.h.
00530 { return addEncodingFilter(newFilter); }
Adds an EncodingFilter to this module's
| newfilter | the filter to add |
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.)
| newfilter | the filter to add |
Definition at line 611 of file swmodule.h.
00611 { 00612 optionFilters->push_back(newFilter); 00613 return *this; 00614 }
Definition at line 585 of file swmodule.h.
00585 { return addRawFilter(newFilter); }
Adds a RawFilter to this module's rawFilters queue
| newFilter | the filter to add |
Definition at line 581 of file swmodule.h.
00581 { 00582 rawFilters->push_back(newfilter); 00583 return *this; 00584 }
Definition at line 476 of file swmodule.h.
00476 { return addRenderFilter(newFilter); }
Adds a RenderFilter to this module's renderFilters queue. Render Filters are called when the module is asked to produce renderable text.
| newfilter | the filter to add |
Definition at line 472 of file swmodule.h.
00472 { 00473 renderFilters->push_back(newFilter); 00474 return *this; 00475 }
Definition at line 575 of file swmodule.h.
00575 { return addStripFilter(newFilter); }
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).
| newfilter | the filter to add |
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 * SWText::createKey | ( | ) | const [virtual, inherited] |
Create the correct key (VerseKey) for use with SWText
Reimplemented from SWModule.
Definition at line 64 of file swtext.cpp.
00064 { 00065 VerseKey *vk = new VerseKey(); 00066 00067 vk->setVersificationSystem(versification); 00068 00069 return vk; 00070 }
| signed char SWModule::createModule | ( | const char * | path | ) | [static, inherited] |
Creates a new, empty module
| path | path where to create the new module |
Reimplemented in RawFiles, RawGenBook, RawLD, RawLD4, and zLD.
Definition at line 1368 of file swmodule.cpp.
| 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 }
| void SWModule::decrement | ( | int | steps = 1 |
) | [virtual, inherited] |
| virtual void SWModule::deleteEntry | ( | ) | [inline, virtual, inherited] |
Delete current module entry - only if module isWritable()
Reimplemented in RawCom, RawCom4, RawFiles, RawGenBook, RawLD, RawLD4, RawText, RawText4, zCom, zLD, and zText.
Definition at line 433 of file swmodule.h.
| 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
| imoddesc | Value which to set moddesc; [0]-only get |
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; }
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
Definition at line 245 of file swmodule.cpp.
| 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
| 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
| 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
| 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.
| void SWCacher::flush | ( | ) | [virtual, inherited] |
| 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.
| const char * SWModule::getDescription | ( | ) | const [inherited] |
Gets module description
Definition at line 191 of file swmodule.cpp.
00191 { 00192 return moddesc; 00193 }
| char SWModule::getDirection | ( | ) | const [virtual, inherited] |
Sets/gets module direction
| newdir | Value which to set direction; [-1]-only get |
Definition at line 217 of file swmodule.cpp.
00217 { 00218 return direction; 00219 }
| SWDisplay * SWModule::getDisplay | ( | ) | const [virtual, inherited] |
Gets display driver
Definition at line 231 of file swmodule.cpp.
00231 { 00232 return disp; 00233 }
| char SWModule::getEncoding | ( | ) | const [inline, inherited] |
Sets/gets module encoding
| enc | Value which to set encoding; [-1]-only get |
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] |
Definition at line 199 of file swmodule.h.
00199 { return entrySize; }
| long SWText::getIndex | ( | ) | const [virtual, inherited] |
Reimplemented from SWModule.
Definition at line 73 of file swtext.cpp.
00073 { 00074 VerseKey *key = &getVerseKey(); 00075 entryIndex = key->getIndex(); 00076 00077 return entryIndex; 00078 }
| SWKey * SWModule::getKey | ( | ) | const [virtual, inherited] |
Gets the current module key
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
| imodlang | Value which to set modlang; [0]-only get |
Definition at line 358 of file swmodule.h.
00358 { return modlang; }
| char SWModule::getMarkup | ( | ) | const [inline, inherited] |
Sets/gets module markup
| markup | Value which to set markup; [-1]-only get |
Definition at line 350 of file swmodule.h.
00350 { return markup; }
| const char * SWModule::getName | ( | ) | const [inherited] |
Gets module name
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 & EchoMod::getRawEntryBuf | ( | ) | const [virtual] |
This function is reimplemented by the different kinds of module objects
Implements SWModule.
Definition at line 36 of file echomod.cpp.
| virtual const FilterList& SWModule::getRenderFilters | ( | ) | const [inline, virtual, inherited] |
Retrieves a container of render filters associated with this module.
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
Definition at line 205 of file swmodule.cpp.
00205 { 00206 return modtype; 00207 }
Definition at line 92 of file swtext.cpp.
00092 { 00093 const SWKey *thisKey = keyToConvert ? keyToConvert : this->key; 00094 00095 VerseKey *key = 0; 00096 // see if we have a VerseKey * or decendant 00097 SWTRY { 00098 key = SWDYNAMIC_CAST(VerseKey, thisKey); 00099 } 00100 SWCATCH ( ... ) { } 00101 if (!key) { 00102 ListKey *lkTest = 0; 00103 SWTRY { 00104 lkTest = SWDYNAMIC_CAST(ListKey, thisKey); 00105 } 00106 SWCATCH ( ... ) { } 00107 if (lkTest) { 00108 SWTRY { 00109 key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement()); 00110 } 00111 SWCATCH ( ... ) { } 00112 } 00113 } 00114 if (!key) { 00115 VerseKey *retKey = (tmpSecond) ? tmpVK1 : tmpVK2; 00116 tmpSecond = !tmpSecond; 00117 retKey->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName()); 00118 (*retKey) = *(thisKey); 00119 return (*retKey); 00120 } 00121 else return *key; 00122 }
| virtual bool SWModule::hasEntry | ( | const SWKey * | ) | const [inline, virtual, inherited] |
Reimplemented in RawCom, RawCom4, RawGenBook, RawText, RawText4, SWLD, zCom, and zText.
Definition at line 678 of file swmodule.h.
| 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 SWModule::increment | ( | int | steps = 1 |
) | [virtual, inherited] |
| SWDEPRECATED long SWModule::Index | ( | long | iindex | ) | [inline, inherited] |
Definition at line 260 of file swmodule.h.
| SWDEPRECATED long SWModule::Index | ( | ) | const [inline, inherited] |
Definition at line 258 of file swmodule.h.
00258 { return getIndex(); }
| 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.
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] |
Definition at line 187 of file swmodule.h.
| virtual bool SWModule::isWritable | ( | ) | const [inline, virtual, inherited] |
| SWDEPRECATED SWKey& SWModule::Key | ( | ) | const [inline, inherited] |
Definition at line 235 of file swmodule.h.
00235 { return *getKey(); }
| SWDEPRECATED char SWModule::Key | ( | const SWKey & | ikey | ) | [inline, inherited] |
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
| ikeytext | Value which to set keytext; [0]-only get |
Definition at line 243 of file swmodule.h.
| 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.
| void SWModule::linkEntry | ( | const SWKey * | sourceKey | ) | [virtual, inherited] |
Link the current module entry to another module entry - only if module isWritable()
Reimplemented in RawCom, RawCom4, RawFiles, RawGenBook, RawLD, RawLD4, RawText, RawText4, zCom, zLD, and zText.
Definition at line 1375 of file swmodule.cpp.
| SWDEPRECATED char SWModule::Markup | ( | signed char | imarkup = -1 |
) | [inline, inherited] |
Definition at line 351 of file swmodule.h.
| SWDEPRECATED const char* SWModule::Name | ( | const char * | imodname | ) | [inline, inherited] |
Sets module name
| imodname | Value which to set modname; [0]-only get |
Definition at line 298 of file swmodule.h.
| 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.
| virtual void SWModule::optionFilter | ( | SWBuf & | buf, | |
| const SWKey * | key | |||
| ) | const [inline, virtual, inherited] |
OptionFilter a text buffer
| 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] |
| 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
| 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 }
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
| oldfilter | the filter to remove |
Definition at line 536 of file swmodule.h.
00536 { 00537 encodingFilters->remove(oldFilter); 00538 return *this; 00539 }
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
| oldfilter | the filter to remove |
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
| 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
| tmpKey | key to use to grab text |
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
| 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 |
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
| oldfilter | the filter to remove | |
| newfilter | the filter to add in its place |
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
| oldfilter | the filter to remove | |
| newfilter | the filter to add in its place |
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.
| 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
| 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. |
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.
| void SWModule::setDisplay | ( | SWDisplay * | idisp | ) | [virtual, inherited] |
Sets display driver
| idisp | pointer to SWDisplay class to assign to this module |
Definition at line 235 of file swmodule.cpp.
00235 { 00236 disp = idisp; 00237 }
| void SWModule::setEntry | ( | const char * | inbuf, | |
| long | len = -1 | |||
| ) | [virtual, inherited] |
Modify the current module entry text - only if module isWritable()
Reimplemented in RawCom, RawCom4, RawFiles, RawGenBook, RawLD, RawLD4, RawText, RawText4, zCom, zLD, and zText.
Definition at line 1372 of file swmodule.cpp.
| void SWText::setIndex | ( | long | iindex | ) | [virtual, inherited] |
Reimplemented from SWModule.
Definition at line 80 of file swtext.cpp.
00080 { 00081 VerseKey *key = &getVerseKey(); 00082 00083 key->setTestament(1); 00084 key->setIndex(iindex); 00085 00086 if (key != this->key) { 00087 this->key->copyFrom(*key); 00088 } 00089 }
| SWDEPRECATED char SWModule::SetKey | ( | const SWKey & | ikey | ) | [inline, inherited] |
Definition at line 222 of file swmodule.h.
00222 { return setKey(ikey); }
| SWDEPRECATED char SWModule::SetKey | ( | const SWKey * | ikey | ) | [inline, inherited] |
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
| ikey | The SWKey which should be used as new key. |
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
| ikey | key with which to set this module |
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
| pos | position (e.g. TOP, BOTTOM) |
Reimplemented in SWLD.
Definition at line 300 of file swmodule.cpp.
| 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
| 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.
| virtual void SWModule::stripFilter | ( | SWBuf & | buf, | |
| const SWKey * | key | |||
| ) | const [inline, virtual, inherited] |
StripFilter run a buf through this module's Strip Filters
| 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.
| const char * SWModule::stripText | ( | const SWKey * | tmpKey | ) | [virtual, inherited] |
Produces plain text, without markup, of the module entry at the supplied key
| tmpKey | desired module entry |
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
| buf | buf to massage instead of current module entry; if buf is 0, the current text will be used | |
| len | max len to process |
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
| imodtype | Value which to set modtype; [0]-only get |
Definition at line 326 of file swmodule.h.
| SWDEPRECATED const char* SWModule::Type | ( | ) | const [inline, inherited] |
Definition at line 319 of file swmodule.h.
00319 { return getType(); }
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.
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.
SWKey* SWModule::key [protected, inherited] |
the current key
Definition at line 113 of file swmodule.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.
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.
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.
1.6.1