The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EchoMod Class Reference

#include <echomod.h>

+ Inheritance diagram for EchoMod:
+ Collaboration diagram for EchoMod:

Public Member Functions

virtual SWModuleaddEncodingFilter (SWFilter *newFilter)
 
SWDEPRECATED SWModuleAddEncodingFilter (SWFilter *newFilter)
 
virtual SWModuleaddOptionFilter (SWOptionFilter *newFilter)
 
SWDEPRECATED SWModuleAddOptionFilter (SWOptionFilter *newFilter)
 
virtual SWModuleaddRawFilter (SWFilter *newFilter)
 
SWDEPRECATED SWModuleAddRawFilter (SWFilter *newFilter)
 
virtual SWModuleaddRenderFilter (SWFilter *newFilter)
 
SWDEPRECATED SWModuleAddRenderFilter (SWFilter *newFilter)
 
virtual SWModuleaddStripFilter (SWFilter *newFilter)
 
SWDEPRECATED SWModuleAddStripFilter (SWFilter *newFilter)
 
virtual SWKeycreateKey () const
 
SWDEPRECATED 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
 
SWDEPRECATED const char * Description (const char *imoddesc)
 
SWDEPRECATED char Direction (signed char newdir=-1)
 
SWDEPRECATED SWDisplayDisp (SWDisplay *idisp=0)
 
virtual char display ()
 
SWDEPRECATED 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 (OptionFilterList *filters, SWBuf &buf, const SWKey *key) const
 
virtual void filterBuffer (FilterList *filters, SWBuf &buf, const SWKey *key) const
 
virtual void flush ()
 
virtual SWBuf getBibliography (unsigned char bibFormat=BIB_BIBTEX) const
 
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
 
virtual const OptionFilterListgetOptionFilters () 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 *) const
 
virtual bool hasSearchFramework ()
 
virtual void increment (int steps=1)
 
SWDEPRECATED long Index () const
 
SWDEPRECATED long Index (long iindex)
 
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 char Key (const SWKey &ikey)
 
SWDEPRECATED SWKeyKey () const
 
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
 
SWDEPRECATED const char * Name (const char *imodname)
 
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 SWModuleremoveEncodingFilter (SWFilter *oldFilter)
 
SWDEPRECATED SWModuleRemoveEncodingFilter (SWFilter *oldFilter)
 
virtual SWModuleremoveRenderFilter (SWFilter *oldFilter)
 
SWDEPRECATED SWModuleRemoveRenderFilter (SWFilter *oldFilter)
 
virtual void renderFilter (SWBuf &buf, const SWKey *key) const
 
SWBuf renderText (const char *buf, int len=-1, bool render=true) const
 
SWBuf renderText ()
 
SWDEPRECATED const char * RenderText (const char *buf=0, int len=-1, bool render=true)
 
SWBuf renderText (const SWKey *tmpKey)
 
virtual SWModulereplaceEncodingFilter (SWFilter *oldFilter, SWFilter *newFilter)
 
SWDEPRECATED SWModuleReplaceEncodingFilter (SWFilter *oldFilter, SWFilter *newFilter)
 
virtual SWModulereplaceRenderFilter (SWFilter *oldFilter, SWFilter *newFilter)
 
SWDEPRECATED SWModuleReplaceRenderFilter (SWFilter *oldFilter, SWFilter *newFilter)
 
virtual long resourceConsumption ()
 
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)
 
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 void setConfig (ConfigEntMap *config)
 
virtual void setDisplay (SWDisplay *idisp)
 
virtual void setEntry (const char *inbuf, long len=-1)
 
virtual void setIndex (long iindex)
 
virtual char setKey (const SWKey *ikey)
 
char setKey (const SWKey &ikey)
 
SWDEPRECATED char SetKey (const SWKey *ikey)
 
SWDEPRECATED char SetKey (const SWKey &ikey)
 
char setKeyText (const char *keyText)
 
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
 
virtual const char * stripText (const char *buf=0, int len=-1)
 
SWDEPRECATED const char * StripText (const char *buf=0, int len=-1)
 
virtual const char * stripText (const SWKey *tmpKey)
 
SWDEPRECATED const char * Type () const
 
SWDEPRECATED const char * Type (const char *imodtype)
 
virtual ~EchoMod ()
 

Static Public Member Functions

static signed char createModule (const char *path)
 
static void nullPercent (char percent, void *userData)
 

Public Attributes

bool terminateSearch
 

Static Public Attributes

static const signed int SEARCHFLAG_MATCHWHOLEENTRY = 4096
 
static const signed int SEARCHFLAG_STRICTBOUNDARIES = 8192
 
static const signed int SEARCHTYPE_ENTRYATTR = -3
 
static const signed int SEARCHTYPE_EXTERNAL = -4
 
static const signed int SEARCHTYPE_MULTIWORD = -2
 
static const signed int SEARCHTYPE_PHRASE = -1
 
static const signed int SEARCHTYPE_REGEX = 0
 

Protected Member Functions

const VerseKeygetVerseKey (const SWKey *key=0) const
 
VerseKeygetVerseKey (SWKey *key=0)
 
const VerseKeygetVerseKeyConst (const SWKey *key=0) const
 

Static Protected Member Functions

static void prepText (SWBuf &buf)
 

Protected Attributes

ConfigEntMapconfig
 
char direction
 
SWDisplaydisp
 
char encoding
 
FilterListencodingFilters
 
AttributeTypeList entryAttributes
 
SWBuf entryBuf
 
long entryIndex
 
int entrySize
 
char error
 
SWKeykey
 
ListKey listKey
 
char markup
 
char * moddesc
 
char * modlang
 
char * modname
 
char * modtype
 
OptionFilterListoptionFilters
 
ConfigEntMap ownConfig
 
bool procEntAttr
 
FilterListrawFilters
 
FilterListrenderFilters
 
bool skipConsecutiveLinks
 
FilterListstripFilters
 

Static Protected Attributes

static StdOutDisplay rawdisp
 

Detailed Description

Definition at line 33 of file echomod.h.

Constructor & Destructor Documentation

SWORD_NAMESPACE_START EchoMod::EchoMod ( )

Definition at line 29 of file echomod.cpp.

29  : SWText("echomod", "Echos back key")
30 {
31 }
SWText(const char *imodname=0, const char *imoddesc=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: swtext.cpp:40
EchoMod::~EchoMod ( )
virtual

Definition at line 34 of file echomod.cpp.

34  {
35 }

Member Function Documentation

virtual SWModule& SWModule::addEncodingFilter ( SWFilter newFilter)
inlinevirtualinherited

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
newFilterthe filter to add
Returns
*this

Definition at line 627 of file swmodule.h.

627  {
628  encodingFilters->push_back(newFilter);
629  return *this;
630  }
FilterList * encodingFilters
Definition: swmodule.h:155
SWDEPRECATED SWModule& SWModule::AddEncodingFilter ( SWFilter newFilter)
inlineinherited
Deprecated:
Use addEncodingFilter

Definition at line 634 of file swmodule.h.

634 { return addEncodingFilter(newFilter); }
virtual SWModule & addEncodingFilter(SWFilter *newFilter)
Definition: swmodule.h:627
virtual SWModule& SWModule::addOptionFilter ( SWOptionFilter newFilter)
inlinevirtualinherited

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
newFilterthe filter to add
Returns
*this

Definition at line 727 of file swmodule.h.

727  {
728  optionFilters->push_back(newFilter);
729  return *this;
730  }
OptionFilterList * optionFilters
Definition: swmodule.h:152
SWDEPRECATED SWModule& SWModule::AddOptionFilter ( SWOptionFilter newFilter)
inlineinherited
Deprecated:
Use addOptionFilter

Definition at line 734 of file swmodule.h.

734 { return addOptionFilter(newFilter); }
virtual SWModule & addOptionFilter(SWOptionFilter *newFilter)
Definition: swmodule.h:727
virtual SWModule& SWModule::addRawFilter ( SWFilter newFilter)
inlinevirtualinherited

Adds a RawFilter to this module's rawFilters queue

Parameters
newFilterthe filter to add
Returns
*this

Definition at line 694 of file swmodule.h.

694  {
695  rawFilters->push_back(newFilter);
696  return *this;
697  }
FilterList * rawFilters
Definition: swmodule.h:146
SWDEPRECATED SWModule& SWModule::AddRawFilter ( SWFilter newFilter)
inlineinherited
Deprecated:
Use addRawFilter

Definition at line 701 of file swmodule.h.

701 { return addRawFilter(newFilter); }
virtual SWModule & addRawFilter(SWFilter *newFilter)
Definition: swmodule.h:694
virtual SWModule& SWModule::addRenderFilter ( SWFilter newFilter)
inlinevirtualinherited

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

Parameters
newFilterthe filter to add
Returns
*this

Definition at line 564 of file swmodule.h.

564  {
565  renderFilters->push_back(newFilter);
566  return *this;
567  }
FilterList * renderFilters
Definition: swmodule.h:149
SWDEPRECATED SWModule& SWModule::AddRenderFilter ( SWFilter newFilter)
inlineinherited
Deprecated:
Use addRenderFilter

Definition at line 571 of file swmodule.h.

571 { return addRenderFilter(newFilter); }
virtual SWModule & addRenderFilter(SWFilter *newFilter)
Definition: swmodule.h:564
virtual SWModule& SWModule::addStripFilter ( SWFilter newFilter)
inlinevirtualinherited

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
newFilterthe filter to add
Returns
*this

Definition at line 681 of file swmodule.h.

681  {
682  stripFilters->push_back(newFilter);
683  return *this;
684  }
FilterList * stripFilters
Definition: swmodule.h:143
SWDEPRECATED SWModule& SWModule::AddStripFilter ( SWFilter newFilter)
inlineinherited
Deprecated:
Use addStripFilter

Definition at line 688 of file swmodule.h.

688 { return addStripFilter(newFilter); }
virtual SWModule & addStripFilter(SWFilter *newFilter)
Definition: swmodule.h:681
SWKey * SWText::createKey ( ) const
virtualinherited

Create the correct key (VerseKey) for use with SWText

Reimplemented from SWModule.

Definition at line 67 of file swtext.cpp.

67  {
68  VerseKey *vk = new VerseKey();
69 
71 
72  return vk;
73 }
char * versification
Definition: swtext.h:43
virtual void setVersificationSystem(const char *name)
Definition: versekey.cpp:298
SWDEPRECATED SWKey* SWModule::CreateKey ( ) const
inlineinherited
Deprecated:
Use createKey

Definition at line 492 of file swmodule.h.

492 { return createKey(); }
virtual SWKey * createKey() const
Definition: swmodule.cpp:173
signed char SWModule::createModule ( const char *  path)
staticinherited

Creates a new, empty module

Parameters
pathpath where to create the new module
Returns
error

Definition at line 1676 of file swmodule.cpp.

1676  {
1677  return -1;
1678 }
signed char SWModule::createSearchFramework ( void(*)(char, void *)  percent = &nullPercent,
void *  percentUserData = 0 
)
virtualinherited

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

Reimplemented from SWSearchable.

Definition at line 1193 of file swmodule.cpp.

1193  {
1194 
1195 #if defined USELUCENE || defined USEXAPIAN
1196  SWBuf target = getConfigEntry("AbsoluteDataPath");
1197  if (!target.endsWith("/") && !target.endsWith("\\")) {
1198  target.append('/');
1199  }
1200 #if defined USEXAPIAN
1201  target.append("xapian");
1202 #elif defined USELUCENE
1203  const int MAX_CONV_SIZE = 1024 * 1024;
1204  target.append("lucene");
1205 #endif
1206  int status = FileMgr::createParent(target+"/dummy");
1207  if (status) return -1;
1208 
1209  SWKey *saveKey = 0;
1210  SWKey *searchKey = 0;
1211  SWKey textkey;
1212  SWBuf c;
1213 
1214 
1215  // turn all filters to default values
1216  StringList filterSettings;
1217  for (OptionFilterList::iterator filter = optionFilters->begin(); filter != optionFilters->end(); filter++) {
1218  filterSettings.push_back((*filter)->getOptionValue());
1219  (*filter)->setOptionValue(*((*filter)->getOptionValues().begin()));
1220 
1221  if ( (!strcmp("Greek Accents", (*filter)->getOptionName())) ||
1222  (!strcmp("Hebrew Vowel Points", (*filter)->getOptionName())) ||
1223  (!strcmp("Arabic Vowel Points", (*filter)->getOptionName()))
1224  ) {
1225  (*filter)->setOptionValue("Off");
1226  }
1227  }
1228 
1229 
1230  // be sure we give CLucene enough file handles
1232 
1233  // save key information so as not to disrupt original
1234  // module position
1235  if (!key->isPersist()) {
1236  saveKey = createKey();
1237  *saveKey = *key;
1238  }
1239  else saveKey = key;
1240 
1241  searchKey = (key->isPersist())?key->clone():0;
1242  if (searchKey) {
1243  searchKey->setPersist(1);
1244  setKey(*searchKey);
1245  }
1246 
1247  bool includeKeyInSearch = getConfig().has("SearchOption", "IncludeKeyInSearch");
1248 
1249  // lets create or open our search index
1250 #if defined USEXAPIAN
1251  Xapian::WritableDatabase database(target.c_str(), Xapian::DB_CREATE_OR_OPEN);
1252  Xapian::TermGenerator termGenerator;
1253  SWTRY {
1254  termGenerator.set_stemmer(Xapian::Stem(getLanguage()));
1255  } SWCATCH(...) {}
1256 
1257 #elif defined USELUCENE
1258  RAMDirectory *ramDir = 0;
1259  IndexWriter *coreWriter = 0;
1260  IndexWriter *fsWriter = 0;
1261  Directory *d = 0;
1262 
1263  const TCHAR *stopWords[] = { 0 };
1264  standard::StandardAnalyzer *an = new standard::StandardAnalyzer(stopWords);
1265 
1266  ramDir = new RAMDirectory();
1267  coreWriter = new IndexWriter(ramDir, an, true);
1268  coreWriter->setMaxFieldLength(MAX_CONV_SIZE);
1269 #endif
1270 
1271 
1272 
1273 
1274  char perc = 1;
1275  VerseKey *vkcheck = 0;
1276  vkcheck = SWDYNAMIC_CAST(VerseKey, key);
1277  VerseKey *chapMax = 0;
1278  if (vkcheck) chapMax = (VerseKey *)vkcheck->clone();
1279 
1280  TreeKeyIdx *tkcheck = 0;
1281  tkcheck = SWDYNAMIC_CAST(TreeKeyIdx, key);
1282 
1283 
1284  *this = BOTTOM;
1285  long highIndex = key->getIndex();
1286  if (!highIndex)
1287  highIndex = 1; // avoid division by zero errors.
1288 
1289  bool savePEA = isProcessEntryAttributes();
1291 
1292  // prox chapter blocks
1293  // position module at the beginning
1294  *this = TOP;
1295 
1296  SWBuf proxBuf;
1297  SWBuf proxLem;
1298  SWBuf proxMorph;
1299  SWBuf strong;
1300  SWBuf morph;
1301 
1302  char err = popError();
1303  while (!err) {
1304  long mindex = key->getIndex();
1305 
1306  proxBuf = "";
1307  proxLem = "";
1308  proxMorph = "";
1309 
1310  // computer percent complete so we can report to our progress callback
1311  float per = (float)mindex / highIndex;
1312  // between 5%-98%
1313  per *= 93; per += 5;
1314  char newperc = (char)per;
1315  if (newperc > perc) {
1316  perc = newperc;
1317  (*percent)(perc, percentUserData);
1318  }
1319 
1320  // get "content" field
1321  const char *content = stripText();
1322 
1323  bool good = false;
1324 
1325  // start out entry
1326 #if defined USEXAPIAN
1327  Xapian::Document doc;
1328  termGenerator.set_document(doc);
1329 #elif defined USELUCENE
1330  Document *doc = new Document();
1331 #endif
1332  // get "key" field
1333  SWBuf keyText = (vkcheck) ? vkcheck->getOSISRef() : getKeyText();
1334  if (content && *content) {
1335  good = true;
1336 
1337 
1338  // build "strong" field
1339  AttributeTypeList::iterator words;
1340  AttributeList::iterator word;
1341  AttributeValue::iterator strongVal;
1342  AttributeValue::iterator morphVal;
1343 
1344  strong="";
1345  morph="";
1346  words = getEntryAttributes().find("Word");
1347  if (words != getEntryAttributes().end()) {
1348  for (word = words->second.begin();word != words->second.end(); word++) {
1349  int partCount = atoi(word->second["PartCount"]);
1350  if (!partCount) partCount = 1;
1351  for (int i = 0; i < partCount; i++) {
1352  SWBuf tmp = "Lemma";
1353  if (partCount > 1) tmp.appendFormatted(".%d", i+1);
1354  strongVal = word->second.find(tmp);
1355  if (strongVal != word->second.end()) {
1356  // cheeze. skip empty article tags that weren't assigned to any text
1357  if (strongVal->second == "G3588") {
1358  if (word->second.find("Text") == word->second.end())
1359  continue; // no text? let's skip
1360  }
1361  strong.append(strongVal->second);
1362  morph.append(strongVal->second);
1363  morph.append('@');
1364  SWBuf tmp = "Morph";
1365  if (partCount > 1) tmp.appendFormatted(".%d", i+1);
1366  morphVal = word->second.find(tmp);
1367  if (morphVal != word->second.end()) {
1368  morph.append(morphVal->second);
1369  }
1370  strong.append(' ');
1371  morph.append(' ');
1372  }
1373  }
1374  }
1375  }
1376 
1377 #if defined USEXAPIAN
1378  doc.set_data(keyText.c_str());
1379 #elif defined USELUCENE
1380  doc->add(*_CLNEW Field(_T("key"), (wchar_t *)utf8ToWChar(keyText).getRawData(), Field::STORE_YES | Field::INDEX_UNTOKENIZED));
1381 #endif
1382 
1383  if (includeKeyInSearch) {
1384  c = keyText;
1385  c += " ";
1386  c += content;
1387  content = c.c_str();
1388  }
1389 
1390 #if defined USEXAPIAN
1391  termGenerator.index_text(content);
1392  termGenerator.index_text(content, 1, "C");
1393 #elif defined USELUCENE
1394  doc->add(*_CLNEW Field(_T("content"), (wchar_t *)utf8ToWChar(content).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
1395 #endif
1396 
1397  if (strong.length() > 0) {
1398 #if defined USEXAPIAN
1399  termGenerator.index_text(strong.c_str(), 1, "L");
1400  termGenerator.index_text(morph.c_str(), 1, "M");
1401 #elif defined USELUCENE
1402  doc->add(*_CLNEW Field(_T("lemma"), (wchar_t *)utf8ToWChar(strong).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
1403  doc->add(*_CLNEW Field(_T("morph"), (wchar_t *)utf8ToWChar(morph).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
1404 #endif
1405 //printf("setting fields (%s).\ncontent: %s\nlemma: %s\n", (const char *)*key, content, strong.c_str());
1406  }
1407 
1408 //printf("setting fields (%s).\n", (const char *)*key);
1409 //fflush(stdout);
1410  }
1411  // don't write yet, cuz we have to see if we're the first of a prox block (5:1 or chapter5/verse1
1412 
1413  // for VerseKeys use chapter
1414  if (vkcheck) {
1415  *chapMax = *vkcheck;
1416  // we're the first verse in a chapter
1417  if (vkcheck->getVerse() == 1) {
1418  *chapMax = MAXVERSE;
1419  VerseKey saveKey = *vkcheck;
1420  while ((!err) && (*vkcheck <= *chapMax)) {
1421 //printf("building proxBuf from (%s).\nproxBuf.c_str(): %s\n", (const char *)*key, proxBuf.c_str());
1422 //printf("building proxBuf from (%s).\n", (const char *)*key);
1423 
1424  content = stripText();
1425  if (content && *content) {
1426  // build "strong" field
1427  strong = "";
1428  morph = "";
1429  AttributeTypeList::iterator words;
1430  AttributeList::iterator word;
1431  AttributeValue::iterator strongVal;
1432  AttributeValue::iterator morphVal;
1433 
1434  words = getEntryAttributes().find("Word");
1435  if (words != getEntryAttributes().end()) {
1436  for (word = words->second.begin();word != words->second.end(); word++) {
1437  int partCount = atoi(word->second["PartCount"]);
1438  if (!partCount) partCount = 1;
1439  for (int i = 0; i < partCount; i++) {
1440  SWBuf tmp = "Lemma";
1441  if (partCount > 1) tmp.appendFormatted(".%d", i+1);
1442  strongVal = word->second.find(tmp);
1443  if (strongVal != word->second.end()) {
1444  // cheeze. skip empty article tags that weren't assigned to any text
1445  if (strongVal->second == "G3588") {
1446  if (word->second.find("Text") == word->second.end())
1447  continue; // no text? let's skip
1448  }
1449  strong.append(strongVal->second);
1450  morph.append(strongVal->second);
1451  morph.append('@');
1452  SWBuf tmp = "Morph";
1453  if (partCount > 1) tmp.appendFormatted(".%d", i+1);
1454  morphVal = word->second.find(tmp);
1455  if (morphVal != word->second.end()) {
1456  morph.append(morphVal->second);
1457  }
1458  strong.append(' ');
1459  morph.append(' ');
1460  }
1461  }
1462  }
1463  }
1464  proxBuf += content;
1465  proxBuf.append(' ');
1466  proxLem += strong;
1467  proxMorph += morph;
1468  if (proxLem.length()) {
1469  proxLem.append("\n");
1470  proxMorph.append("\n");
1471  }
1472  }
1473  (*this)++;
1474  err = popError();
1475  }
1476  err = 0;
1477  *vkcheck = saveKey;
1478  }
1479  }
1480 
1481  // for TreeKeys use siblings if we have no children
1482  else if (tkcheck) {
1483  if (!tkcheck->hasChildren()) {
1484  if (!tkcheck->previousSibling()) {
1485  do {
1486 //printf("building proxBuf from (%s).\n", (const char *)*key);
1487 //fflush(stdout);
1488 
1489  content = stripText();
1490  if (content && *content) {
1491  // build "strong" field
1492  strong = "";
1493  morph = "";
1494  AttributeTypeList::iterator words;
1495  AttributeList::iterator word;
1496  AttributeValue::iterator strongVal;
1497  AttributeValue::iterator morphVal;
1498 
1499  words = getEntryAttributes().find("Word");
1500  if (words != getEntryAttributes().end()) {
1501  for (word = words->second.begin();word != words->second.end(); word++) {
1502  int partCount = atoi(word->second["PartCount"]);
1503  if (!partCount) partCount = 1;
1504  for (int i = 0; i < partCount; i++) {
1505  SWBuf tmp = "Lemma";
1506  if (partCount > 1) tmp.appendFormatted(".%d", i+1);
1507  strongVal = word->second.find(tmp);
1508  if (strongVal != word->second.end()) {
1509  // cheeze. skip empty article tags that weren't assigned to any text
1510  if (strongVal->second == "G3588") {
1511  if (word->second.find("Text") == word->second.end())
1512  continue; // no text? let's skip
1513  }
1514  strong.append(strongVal->second);
1515  morph.append(strongVal->second);
1516  morph.append('@');
1517  SWBuf tmp = "Morph";
1518  if (partCount > 1) tmp.appendFormatted(".%d", i+1);
1519  morphVal = word->second.find(tmp);
1520  if (morphVal != word->second.end()) {
1521  morph.append(morphVal->second);
1522  }
1523  strong.append(' ');
1524  morph.append(' ');
1525  }
1526  }
1527  }
1528  }
1529 
1530  proxBuf += content;
1531  proxBuf.append(' ');
1532  proxLem += strong;
1533  proxMorph += morph;
1534  if (proxLem.length()) {
1535  proxLem.append("\n");
1536  proxMorph.append("\n");
1537  }
1538  }
1539  } while (tkcheck->nextSibling());
1540  tkcheck->parent();
1541  tkcheck->firstChild();
1542  }
1543  else tkcheck->nextSibling(); // reposition from our previousSibling test
1544  }
1545  }
1546 
1547  if (proxBuf.length() > 0) {
1548 
1549 #if defined USEXAPIAN
1550  termGenerator.index_text(proxBuf.c_str(), 1, "P");
1551 #elif defined USELUCENE
1552  doc->add(*_CLNEW Field(_T("prox"), (wchar_t *)utf8ToWChar(proxBuf).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED));
1553 #endif
1554  good = true;
1555  }
1556  if (proxLem.length() > 0) {
1557 #if defined USEXAPIAN
1558  termGenerator.index_text(proxLem.c_str(), 1, "PL");
1559  termGenerator.index_text(proxMorph.c_str(), 1, "PM");
1560 #elif defined USELUCENE
1561  doc->add(*_CLNEW Field(_T("proxlem"), (wchar_t *)utf8ToWChar(proxLem).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED) );
1562  doc->add(*_CLNEW Field(_T("proxmorph"), (wchar_t *)utf8ToWChar(proxMorph).getRawData(), Field::STORE_NO | Field::INDEX_TOKENIZED) );
1563 #endif
1564  good = true;
1565  }
1566  if (good) {
1567 //printf("writing (%s).\n", (const char *)*key);
1568 //fflush(stdout);
1569 #if defined USEXAPIAN
1570  SWBuf idTerm;
1571  idTerm.setFormatted("Q%ld", key->getIndex());
1572  doc.add_boolean_term(idTerm.c_str());
1573  database.replace_document(idTerm.c_str(), doc);
1574 #elif defined USELUCENE
1575  coreWriter->addDocument(doc);
1576 #endif
1577  }
1578 #if defined USEXAPIAN
1579 #elif defined USELUCENE
1580  delete doc;
1581 #endif
1582 
1583  (*this)++;
1584  err = popError();
1585  }
1586 
1587  // Optimizing automatically happens with the call to addIndexes
1588  //coreWriter->optimize();
1589 #if defined USEXAPIAN
1590 #elif defined USELUCENE
1591  coreWriter->close();
1592 
1593 #ifdef CLUCENE2
1594  d = FSDirectory::getDirectory(target.c_str());
1595 #endif
1596  if (IndexReader::indexExists(target.c_str())) {
1597 #ifndef CLUCENE2
1598  d = FSDirectory::getDirectory(target.c_str(), false);
1599 #endif
1600  if (IndexReader::isLocked(d)) {
1601  IndexReader::unlock(d);
1602  }
1603  fsWriter = new IndexWriter( d, an, false);
1604  }
1605  else {
1606 #ifndef CLUCENE2
1607  d = FSDirectory::getDirectory(target.c_str(), true);
1608 #endif
1609  fsWriter = new IndexWriter(d, an, true);
1610  }
1611 
1612  Directory *dirs[] = { ramDir, 0 };
1613 #ifdef CLUCENE2
1614  lucene::util::ConstValueArray< lucene::store::Directory *>dirsa(dirs, 1);
1615  fsWriter->addIndexes(dirsa);
1616 #else
1617  fsWriter->addIndexes(dirs);
1618 #endif
1619  fsWriter->close();
1620 
1621  delete ramDir;
1622  delete coreWriter;
1623  delete fsWriter;
1624  delete an;
1625 #endif
1626 
1627  // reposition module back to where it was before we were called
1628  setKey(*saveKey);
1629 
1630  if (!saveKey->isPersist())
1631  delete saveKey;
1632 
1633  if (searchKey)
1634  delete searchKey;
1635 
1636  delete chapMax;
1637 
1638  setProcessEntryAttributes(savePEA);
1639 
1640  // reset option filters back to original values
1641  StringList::iterator origVal = filterSettings.begin();
1642  for (OptionFilterList::iterator filter = optionFilters->begin(); filter != optionFilters->end(); filter++) {
1643  (*filter)->setOptionValue(*origVal++);
1644  }
1645 
1646  return 0;
1647 #else
1648  return SWSearchable::createSearchFramework(percent, percentUserData);
1649 #endif
1650 }
#define TOP
Definition: swkey.h:68
const char * getLanguage() const
Definition: swmodule.h:437
SWBuf & appendFormatted(const char *format,...)
Definition: swbuf.cpp:81
virtual SWKey * clone() const
Definition: versekey.cpp:278
Definition: swbuf.h:47
unsigned long length() const
Definition: swbuf.h:197
#define MAXVERSE
Definition: versekey.h:43
virtual const char * getConfigEntry(const char *key) const
Definition: swmodule.cpp:1159
#define BOTTOM
Definition: swkey.h:69
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
SWBuf utf8ToWChar(const char *buf)
Definition: utilstr.cpp:239
#define SWTRY
Definition: defs.h:57
bool endsWith(const SWBuf &postfix) const
Definition: swbuf.h:501
virtual signed char createSearchFramework(void(*percent)(char, void *)=&nullPercent, void *percentUserData=0)
virtual bool previousSibling()
Definition: treekeyidx.cpp:178
virtual SWKey * clone() const
Definition: swkey.cpp:75
virtual bool nextSibling()
Definition: treekeyidx.cpp:168
void setPersist(bool ipersist)
Definition: swkey.cpp:135
bool isPersist() const
Definition: swkey.cpp:99
#define SWCATCH(x)
Definition: defs.h:58
const char * c_str() const
Definition: swbuf.h:158
std::list< SWBuf > StringList
Definition: swmodule.cpp:91
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
virtual void flush()
Definition: filemgr.cpp:657
virtual bool parent()
Definition: treekeyidx.cpp:148
virtual int getVerse() const
Definition: versekey.cpp:1534
virtual const char * getOSISRef() const
Definition: versekey.cpp:1810
virtual char popError()
Definition: swmodule.cpp:185
#define SWDYNAMIC_CAST(className, object)
Definition: defs.h:47
virtual bool hasChildren()
Definition: treekeyidx.cpp:198
static int createParent(const char *pName)
Definition: filemgr.cpp:426
virtual bool isProcessEntryAttributes() const
Definition: swmodule.h:832
virtual AttributeTypeList & getEntryAttributes() const
Definition: swmodule.h:817
virtual void setProcessEntryAttributes(bool val) const
Definition: swmodule.h:824
virtual const char * getKeyText() const
Definition: swmodule.h:304
virtual const char * stripText(const char *buf=0, int len=-1)
Definition: swmodule.cpp:990
SWKey * key
Definition: swmodule.h:124
OptionFilterList * optionFilters
Definition: swmodule.h:152
virtual SWKey * createKey() const
Definition: swmodule.cpp:173
SWBuf & setFormatted(const char *format,...)
Definition: swbuf.cpp:50
Definition: swkey.h:77
virtual long getIndex() const
Definition: swkey.h:229
virtual bool firstChild()
Definition: treekeyidx.cpp:158
virtual const ConfigEntMap & getConfig() const
Definition: swmodule.h:219
static FileMgr * getSystemFileMgr()
Definition: filemgr.cpp:101
void SWModule::decrement ( int  steps = 1)
virtualinherited

Decrements module key a number of entries

Parameters
stepsNumber of entries to jump backward

Reimplemented in zText, zText4, zCom, zCom4, RawLD, RawLD4, RawCom, RawCom4, RawText4, zLD, and RawText.

Definition at line 369 of file swmodule.cpp.

369  {
370  (*key) -= steps;
371  error = key->popError();
372 }
char error
Definition: swmodule.h:120
virtual char popError()
Definition: swkey.cpp:147
SWKey * key
Definition: swmodule.h:124
virtual void SWModule::deleteEntry ( )
inlinevirtualinherited

Delete current module entry - only if module isWritable()

Reimplemented in RawFiles, zText, zText4, zCom, zCom4, RawLD, RawLD4, zLD, RawGenBook, RawCom, RawCom4, RawText4, and RawText.

Definition at line 525 of file swmodule.h.

525 {}
void SWModule::deleteSearchFramework ( )
virtualinherited

Reimplemented from SWSearchable.

Definition at line 1178 of file swmodule.cpp.

1178  {
1179 #ifdef USELUCENE
1180  SWBuf target = getConfigEntry("AbsoluteDataPath");
1181  if (!target.endsWith("/") && !target.endsWith("\\")) {
1182  target.append('/');
1183  }
1184  target.append("lucene");
1185 
1186  FileMgr::removeDir(target.c_str());
1187 #else
1189 #endif
1190 }
static int removeDir(const char *targetDir)
Definition: filemgr.cpp:639
Definition: swbuf.h:47
virtual void deleteSearchFramework()
virtual const char * getConfigEntry(const char *key) const
Definition: swmodule.cpp:1159
bool endsWith(const SWBuf &postfix) const
Definition: swbuf.h:501
const char * c_str() const
Definition: swbuf.h:158
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
SWDEPRECATED const char* SWModule::Description ( ) const
inlineinherited
Deprecated:
Use getDescription

Definition at line 373 of file swmodule.h.

373 { return getDescription(); }
const char * getDescription() const
Definition: swmodule.cpp:218
SWDEPRECATED const char* SWModule::Description ( const char *  imoddesc)
inlineinherited

Sets module description

Deprecated:
Use getDescription
Parameters
imoddescValue which to set moddesc; [0]-only get
Returns
pointer to moddesc

Definition at line 381 of file swmodule.h.

381 { stdstr(&moddesc, imoddesc); return getDescription(); }
char * moddesc
Definition: swmodule.h:128
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
const char * getDescription() const
Definition: swmodule.cpp:218
SWDEPRECATED char SWModule::Direction ( signed char  newdir = -1)
inlineinherited
Deprecated:
Use getDirection

Definition at line 411 of file swmodule.h.

411 { char retVal = getDirection(); if (newdir != -1) return direction = newdir; return retVal; }
virtual char getDirection() const
Definition: swmodule.cpp:244
char direction
Definition: swmodule.h:132
SWDEPRECATED SWDisplay* SWModule::Disp ( SWDisplay idisp = 0)
inlineinherited
Deprecated:
Use get/setDisplay() instead.

Definition at line 345 of file swmodule.h.

345 { if (idisp) setDisplay(idisp); return getDisplay(); }
virtual void setDisplay(SWDisplay *idisp)
Definition: swmodule.cpp:262
virtual SWDisplay * getDisplay() const
Definition: swmodule.cpp:258
char SWModule::display ( )
virtualinherited

Calls this module's display object and passes itself

Returns
error status

Definition at line 272 of file swmodule.cpp.

272  {
273  disp->display(*this);
274  return 0;
275 }
SWDisplay * disp
Definition: swmodule.h:137
virtual char display(SWModule &imodule)=0
SWDEPRECATED char SWModule::Display ( )
inlineinherited
Deprecated:
Use display

Definition at line 328 of file swmodule.h.

328 { return display(); }
virtual char display()
Definition: swmodule.cpp:272
SWDEPRECATED char SWModule::Encoding ( signed char  enc = -1)
inlineinherited
Deprecated:
Use getEncoding

Definition at line 421 of file swmodule.h.

421 { char retVal = getEncoding(); if (enc != -1) encoding = enc; return retVal; }
char encoding
Definition: swmodule.h:134
char getEncoding() const
Definition: swmodule.h:417
virtual void SWModule::encodingFilter ( SWBuf buf,
const SWKey key 
) const
inlinevirtualinherited

encodingFilter run a buf through this module's Encoding Filters

Parameters
bufthe buffer to filter
keykey location from where this buffer was extracted

Definition at line 671 of file swmodule.h.

671  {
672  filterBuffer(encodingFilters, buf, key);
673  }
virtual void filterBuffer(OptionFilterList *filters, SWBuf &buf, const SWKey *key) const
Definition: swmodule.cpp:1657
FilterList * encodingFilters
Definition: swmodule.h:155
virtual SWDEPRECATED char SWModule::Error ( )
inlinevirtualinherited
Deprecated:
Use popError instead.

Definition at line 208 of file swmodule.h.

208 { return popError(); }
virtual char popError()
Definition: swmodule.cpp:185
void SWModule::filterBuffer ( OptionFilterList filters,
SWBuf buf,
const SWKey key 
) const
virtualinherited

OptionFilterBuffer a text buffer

Parameters
filtersthe FilterList of filters to iterate
bufthe buffer to filter
keykey location from where this buffer was extracted

Definition at line 1657 of file swmodule.cpp.

1657  {
1658  OptionFilterList::iterator it;
1659  for (it = filters->begin(); it != filters->end(); it++) {
1660  (*it)->processText(buf, key, this);
1661  }
1662 }
void SWModule::filterBuffer ( FilterList filters,
SWBuf buf,
const SWKey key 
) const
virtualinherited

FilterBuffer a text buffer

Parameters
filtersthe FilterList of filters to iterate
bufthe buffer to filter
keykey location from where this buffer was extracted

Definition at line 1669 of file swmodule.cpp.

1669  {
1670  FilterList::iterator it;
1671  for (it = filters->begin(); it != filters->end(); it++) {
1672  (*it)->processText(buf, key, this);
1673  }
1674 }
void SWCacher::flush ( )
virtualinherited

Reimplemented in FileMgr, zText, zText4, zCom, zCom4, and zLD.

Definition at line 39 of file swcacher.cpp.

39  {
40 }
SWBuf SWModule::getBibliography ( unsigned char  bibFormat = BIB_BIBTEX) const
virtualinherited

Returns bibliographic data for a module in the requested format

Parameters
bibFormatformat of the bibliographic data
Returns
bibliographic data in the requested format as a string (BibTeX by default)

Definition at line 1149 of file swmodule.cpp.

1149  {
1150  SWBuf s;
1151  switch (bibFormat) {
1152  case BIB_BIBTEX:
1153  s.append("@Book {").append(modname).append(", Title = \"").append(moddesc).append("\", Publisher = \"CrossWire Bible Society\"}");
1154  break;
1155  }
1156  return s;
1157 }
Definition: swbuf.h:47
char * modname
Definition: swmodule.h:127
char * moddesc
Definition: swmodule.h:128
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
virtual const ConfigEntMap& SWModule::getConfig ( ) const
inlinevirtualinherited

Definition at line 219 of file swmodule.h.

219 { return *config; }
ConfigEntMap * config
Definition: swmodule.h:116
const char * SWModule::getConfigEntry ( const char *  key) const
virtualinherited

Gets a configuration property about a module. These entries are primarily pulled from the module's .conf file, but also includes some virtual entries such as: PrefixPath - the absolute filesystem path to the sword module repository location where this module is located. AbsoluteDataPath - the full path to the root folder where the module data is stored.

Definition at line 1159 of file swmodule.cpp.

1159  {
1160  ConfigEntMap::iterator it = config->find(key);
1161  return (it != config->end()) ? it->second.c_str() : 0;
1162 }
ConfigEntMap * config
Definition: swmodule.h:116
SWKey * key
Definition: swmodule.h:124
const char * SWModule::getDescription ( ) const
inherited

Gets module description

Returns
pointer to moddesc

Definition at line 218 of file swmodule.cpp.

218  {
219  return moddesc;
220 }
char * moddesc
Definition: swmodule.h:128
char SWModule::getDirection ( ) const
virtualinherited

Sets/gets module direction

Returns
new direction

Definition at line 244 of file swmodule.cpp.

244  {
245  return direction;
246 }
char direction
Definition: swmodule.h:132
SWDisplay * SWModule::getDisplay ( ) const
virtualinherited

Gets display driver

Returns
pointer to SWDisplay class for this module

Definition at line 258 of file swmodule.cpp.

258  {
259  return disp;
260 }
SWDisplay * disp
Definition: swmodule.h:137
char SWModule::getEncoding ( ) const
inlineinherited

Gets module encoding

Returns
Encoding

Definition at line 417 of file swmodule.h.

417 { return encoding; }
char encoding
Definition: swmodule.h:134
virtual AttributeTypeList& SWModule::getEntryAttributes ( ) const
inlinevirtualinherited

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 817 of file swmodule.h.

817 { return entryAttributes; }
AttributeTypeList entryAttributes
Definition: swmodule.h:117
virtual int SWModule::getEntrySize ( ) const
inlinevirtualinherited
Returns
The size of the text entry for the module's current key position.

Definition at line 243 of file swmodule.h.

243 { return entrySize; }
int entrySize
Definition: swmodule.h:157
long SWText::getIndex ( ) const
virtualinherited

Reimplemented from SWModule.

Definition at line 76 of file swtext.cpp.

76  {
77  const VerseKey *key = &getVerseKey();
78  entryIndex = key->getIndex();
79 
80  return entryIndex;
81 }
const VerseKey & getVerseKey(const SWKey *key=0) const
Definition: swtext.h:46
SWKey * key
Definition: swmodule.h:124
long entryIndex
Definition: swmodule.h:158
virtual long getIndex() const
Definition: versekey.cpp:1681
SWKey * SWModule::getKey ( ) const
virtualinherited

Gets the current module key

Returns
the current key of this module

Definition at line 284 of file swmodule.cpp.

284  {
285  return key;
286 }
SWKey * key
Definition: swmodule.h:124
virtual const char* SWModule::getKeyText ( ) const
inlinevirtualinherited

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

Reimplemented in SWLD.

Definition at line 304 of file swmodule.h.

304  {
305  return *getKey();
306  }
virtual SWKey * getKey() const
Definition: swmodule.cpp:284
const char* SWModule::getLanguage ( ) const
inlineinherited

Gets module language

Returns
pointer to modlang

Definition at line 437 of file swmodule.h.

437 { return modlang; }
char * modlang
Definition: swmodule.h:130
char SWModule::getMarkup ( ) const
inlineinherited

Gets module markup

Returns
Markup

Definition at line 427 of file swmodule.h.

427 { return markup; }
char markup
Definition: swmodule.h:133
const char * SWModule::getName ( ) const
inherited

Gets module name

Returns
pointer to modname

Definition at line 204 of file swmodule.cpp.

204  {
205  return modname;
206 }
char * modname
Definition: swmodule.h:127
virtual const OptionFilterList& SWModule::getOptionFilters ( ) const
inlinevirtualinherited

Definition at line 736 of file swmodule.h.

736 { return *optionFilters; }
OptionFilterList * optionFilters
Definition: swmodule.h:152
const char* SWModule::getRawEntry ( ) const
inlineinherited

Definition at line 500 of file swmodule.h.

500 { return getRawEntryBuf().c_str(); }
const char * c_str() const
Definition: swbuf.h:158
virtual SWBuf & getRawEntryBuf() const =0
SWBuf & EchoMod::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 38 of file echomod.cpp.

39 {
40  static SWBuf retVal;
41  retVal = *key;
42  return retVal;
43 }
Definition: swbuf.h:47
SWKey * key
Definition: swmodule.h:124
virtual const FilterList& SWModule::getRenderFilters ( ) const
inlinevirtualinherited

Retrieves a container of render filters associated with this module.

Returns
container of render filters

Definition at line 577 of file swmodule.h.

577  {
578  return *renderFilters;
579  }
FilterList * renderFilters
Definition: swmodule.h:149
const char * SWModule::getRenderHeader ( ) const
virtualinherited

Produces any header data which might be useful which is 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 1002 of file swmodule.cpp.

1002  {
1003  FilterList::const_iterator first = getRenderFilters().begin();
1004  if (first != getRenderFilters().end()) {
1005  return (*first)->getHeader();
1006  }
1007  return "";
1008 }
virtual const FilterList & getRenderFilters() const
Definition: swmodule.h:577
SWDEPRECATED bool SWModule::getSkipConsecutiveLinks ( )
inlineinherited
Deprecated:
Use isSkipConsecutiveLinks

Definition at line 806 of file swmodule.h.

806 { return isSkipConsecutiveLinks(); }
virtual bool isSkipConsecutiveLinks()
Definition: swmodule.h:802
const char * SWModule::getType ( ) const
inherited

Gets module type

Returns
pointer to modtype

Definition at line 232 of file swmodule.cpp.

232  {
233  return modtype;
234 }
char * modtype
Definition: swmodule.h:129
const VerseKey& SWText::getVerseKey ( const SWKey key = 0) const
inlineprotectedinherited

Definition at line 46 of file swtext.h.

46 { return getVerseKeyConst(key); }
const VerseKey & getVerseKeyConst(const SWKey *key=0) const
Definition: swtext.cpp:95
VerseKey & SWText::getVerseKey ( SWKey key = 0)
protectedinherited

Definition at line 128 of file swtext.cpp.

128  {
129  SWKey *thisKey = keyToConvert ? keyToConvert : this->key;
130 
131  VerseKey *key = 0;
132  // see if we have a VerseKey * or decendant
133  SWTRY {
134  key = SWDYNAMIC_CAST(VerseKey, thisKey);
135  }
136  SWCATCH ( ... ) { }
137  if (!key) {
138  ListKey *lkTest = 0;
139  SWTRY {
140  lkTest = SWDYNAMIC_CAST(ListKey, thisKey);
141  }
142  SWCATCH ( ... ) { }
143  if (lkTest) {
144  SWTRY {
145  key = SWDYNAMIC_CAST(VerseKey, lkTest->getElement());
146  }
147  SWCATCH ( ... ) { }
148  }
149  }
150  if (!key) {
151  VerseKey *retKey = (tmpSecond) ? tmpVK1 : tmpVK2;
152  tmpSecond = !tmpSecond;
153  retKey->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName());
154  (*retKey) = *(thisKey);
155  return (*retKey);
156  }
157  else return *key;
158 }
#define SWTRY
Definition: defs.h:57
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
#define SWCATCH(x)
Definition: defs.h:58
VerseKey * tmpVK1
Definition: swtext.h:40
VerseKey * tmpVK2
Definition: swtext.h:41
static LocaleMgr * getSystemLocaleMgr()
Definition: localemgr.cpp:54
#define SWDYNAMIC_CAST(className, object)
Definition: defs.h:47
SWKey * key
Definition: swmodule.h:124
Definition: swkey.h:77
bool tmpSecond
Definition: swtext.h:42
void setLocale(const char *name)
Definition: swkey.h:225
const VerseKey & SWText::getVerseKeyConst ( const SWKey key = 0) const
protectedinherited

Definition at line 95 of file swtext.cpp.

95  {
96  const SWKey *thisKey = keyToConvert ? keyToConvert : this->key;
97 
98  const VerseKey *key = 0;
99  // see if we have a VerseKey * or decendant
100  SWTRY {
101  key = SWDYNAMIC_CAST(const VerseKey, thisKey);
102  }
103  SWCATCH ( ... ) { }
104  if (!key) {
105  const ListKey *lkTest = 0;
106  SWTRY {
107  lkTest = SWDYNAMIC_CAST(const ListKey, thisKey);
108  }
109  SWCATCH ( ... ) { }
110  if (lkTest) {
111  SWTRY {
112  key = SWDYNAMIC_CAST(const VerseKey, lkTest->getElement());
113  }
114  SWCATCH ( ... ) { }
115  }
116  }
117  if (!key) {
118  VerseKey *retKey = (tmpSecond) ? tmpVK1 : tmpVK2;
119  tmpSecond = !tmpSecond;
120  retKey->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName());
121  (*retKey) = *(thisKey);
122  return (*retKey);
123  }
124  else return *key;
125 }
#define SWTRY
Definition: defs.h:57
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
#define SWCATCH(x)
Definition: defs.h:58
VerseKey * tmpVK1
Definition: swtext.h:40
VerseKey * tmpVK2
Definition: swtext.h:41
static LocaleMgr * getSystemLocaleMgr()
Definition: localemgr.cpp:54
#define SWDYNAMIC_CAST(className, object)
Definition: defs.h:47
SWKey * key
Definition: swmodule.h:124
Definition: swkey.h:77
bool tmpSecond
Definition: swtext.h:42
void setLocale(const char *name)
Definition: swkey.h:225
virtual bool SWModule::hasEntry ( const SWKey ) const
inlinevirtualinherited

Reimplemented in zText, zText4, zCom, zCom4, SWLD, RawGenBook, RawCom, RawCom4, RawText4, and RawText.

Definition at line 809 of file swmodule.h.

809 { return false; }
bool SWModule::hasSearchFramework ( )
virtualinherited

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

Reimplemented from SWSearchable.

Definition at line 1170 of file swmodule.cpp.

1170  {
1171 #ifdef USELUCENE
1172  return true;
1173 #else
1175 #endif
1176 }
virtual bool hasSearchFramework()
Definition: swsearchable.h:89
void SWModule::increment ( int  steps = 1)
virtualinherited

Increments module key a number of entries

Parameters
stepsNumber of entries to jump forward

Reimplemented in zText, zText4, zCom, zCom4, RawLD, RawLD4, RawCom, RawCom4, RawText4, zLD, and RawText.

Definition at line 355 of file swmodule.cpp.

355  {
356  (*key) += steps;
357  error = key->popError();
358 }
char error
Definition: swmodule.h:120
virtual char popError()
Definition: swkey.cpp:147
SWKey * key
Definition: swmodule.h:124
SWDEPRECATED long SWModule::Index ( ) const
inlineinherited
Deprecated:
Use getIndex()

Definition at line 314 of file swmodule.h.

314 { return getIndex(); }
virtual long getIndex() const
Definition: swmodule.h:309
SWDEPRECATED long SWModule::Index ( long  iindex)
inlineinherited
Deprecated:
Use setIndex(...)

Definition at line 318 of file swmodule.h.

318 { setIndex(iindex); return getIndex(); }
virtual void setIndex(long iindex)
Definition: swmodule.h:310
virtual long getIndex() const
Definition: swmodule.h:309
virtual bool SWModule::isLinked ( const SWKey ,
const SWKey  
) const
inlinevirtualinherited

Reimplemented in zText, zText4, zCom, zCom4, RawCom, RawCom4, RawText4, and RawText.

Definition at line 808 of file swmodule.h.

808 { return false; }
virtual bool SWModule::isProcessEntryAttributes ( ) const
inlinevirtualinherited

Whether or not we're processing Entry Attributes

Definition at line 832 of file swmodule.h.

832 { return procEntAttr; }
bool procEntAttr
Definition: swmodule.h:118
bool SWSearchable::isSearchOptimallySupported ( const char *  istr,
int  searchType,
int  flags,
SWKey scope 
)
virtualinherited

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

52  {
53  bool retVal = false;
54  search(istr, searchType, flags, scope, &retVal);
55  return retVal;
56 }
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)=0
virtual bool SWModule::isSkipConsecutiveLinks ( )
inlinevirtualinherited

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

Definition at line 802 of file swmodule.h.

802 { return skipConsecutiveLinks; }
bool skipConsecutiveLinks
Definition: swmodule.h:121
virtual bool SWModule::isUnicode ( ) const
inlinevirtualinherited
Returns
True if this module is encoded in Unicode, otherwise returns false.

Definition at line 213 of file swmodule.h.

213 { return (encoding == (char)ENC_UTF8 || encoding == (char)ENC_SCSU); }
char encoding
Definition: swmodule.h:134
virtual bool SWModule::isWritable ( ) const
inlinevirtualinherited

Is the module writable? :)

Returns
yes or no

Reimplemented in zText, zText4, zCom, zCom4, RawLD, RawLD4, RawFiles, RawGenBook, RawCom, RawCom4, zLD, RawText4, and RawText.

Definition at line 506 of file swmodule.h.

506 { return false; }
SWDEPRECATED char SWModule::Key ( const SWKey ikey)
inlineinherited
Deprecated:
Use setKey() instead.

Definition at line 280 of file swmodule.h.

280 { return setKey(ikey); }
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
SWDEPRECATED SWKey& SWModule::Key ( ) const
inlineinherited
Deprecated:
Use getKey() instead.

Definition at line 289 of file swmodule.h.

289 { return *getKey(); }
virtual SWKey * getKey() const
Definition: swmodule.cpp:284
SWDEPRECATED const char* SWModule::KeyText ( const char *  ikeytext = 0)
inlineinherited

Sets/gets module KeyText

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

Definition at line 297 of file swmodule.h.

297 { if (ikeytext) setKey(ikeytext); return *getKey(); }
virtual SWKey * getKey() const
Definition: swmodule.cpp:284
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
SWDEPRECATED const char* SWModule::Lang ( char *  imodlang = 0)
inlineinherited
Deprecated:
Use getLanguage

Definition at line 441 of file swmodule.h.

441 { if (imodlang != 0) stdstr(&modlang, imodlang); return getLanguage(); }
const char * getLanguage() const
Definition: swmodule.h:437
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
char * modlang
Definition: swmodule.h:130
long SWCacher::lastAccess ( )
virtualinherited

Definition at line 46 of file swcacher.cpp.

46  {
47  return 0;
48 }
void SWModule::linkEntry ( const SWKey sourceKey)
virtualinherited

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

Reimplemented in RawFiles, zText, zText4, zCom, zCom4, RawLD, RawLD4, zLD, RawGenBook, RawCom, RawCom4, RawText4, and RawText.

Definition at line 1683 of file swmodule.cpp.

1683  {
1684 }
SWDEPRECATED char SWModule::Markup ( signed char  imarkup = -1)
inlineinherited
Deprecated:
Use getMarkup

Definition at line 431 of file swmodule.h.

431 { char retVal = getMarkup(); if (imarkup != -1) markup = imarkup; return retVal; }
char getMarkup() const
Definition: swmodule.h:427
char markup
Definition: swmodule.h:133
SWDEPRECATED const char* SWModule::Name ( ) const
inlineinherited
Deprecated:
Use getName

Definition at line 355 of file swmodule.h.

355 { return getName(); }
const char * getName() const
Definition: swmodule.cpp:204
SWDEPRECATED const char* SWModule::Name ( const char *  imodname)
inlineinherited

Sets module name

Deprecated:
Use getName
Parameters
imodnameValue which to set modname; [0]-only get
Returns
pointer to modname

Definition at line 363 of file swmodule.h.

363 { stdstr(&modname, imodname); return getName(); }
const char * getName() const
Definition: swmodule.cpp:204
char * modname
Definition: swmodule.h:127
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
SWORD_NAMESPACE_START void SWSearchable::nullPercent ( char  percent,
void *  userData 
)
staticinherited

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

31 {}
virtual void SWModule::optionFilter ( SWBuf buf,
const SWKey key 
) const
inlinevirtualinherited

OptionFilter a text buffer

Parameters
bufthe buffer to filter
keykey location from where this buffer was extracted

Definition at line 742 of file swmodule.h.

742  {
743  filterBuffer(optionFilters, buf, key);
744  }
virtual void filterBuffer(OptionFilterList *filters, SWBuf &buf, const SWKey *key) const
Definition: swmodule.cpp:1657
OptionFilterList * optionFilters
Definition: swmodule.h:152
char SWModule::popError ( )
virtualinherited

Gets and clears error status

Returns
error status

Definition at line 185 of file swmodule.cpp.

186 {
187  char retval = error;
188 
189  error = 0;
190  if (!retval) retval = key->popError();
191  return retval;
192 }
char error
Definition: swmodule.h:120
virtual char popError()
Definition: swkey.cpp:147
SWKey * key
Definition: swmodule.h:124
void SWModule::prepText ( SWBuf buf)
staticprotectedinherited

Definition at line 1695 of file swmodule.cpp.

1695  {
1696  unsigned int to, from;
1697  char space = 0, cr = 0, realdata = 0, nlcnt = 0;
1698  char *rawBuf = buf.getRawData();
1699  for (to = from = 0; rawBuf[from]; from++) {
1700  switch (rawBuf[from]) {
1701  case 10:
1702  if (!realdata)
1703  continue;
1704  space = (cr) ? 0 : 1;
1705  cr = 0;
1706  nlcnt++;
1707  if (nlcnt > 1) {
1708 // *to++ = nl;
1709  rawBuf[to++] = 10;
1710 // *to++ = nl[1];
1711 // nlcnt = 0;
1712  }
1713  continue;
1714  case 13:
1715  if (!realdata)
1716  continue;
1717 // *to++ = nl[0];
1718  rawBuf[to++] = 10;
1719  space = 0;
1720  cr = 1;
1721  continue;
1722  }
1723  realdata = 1;
1724  nlcnt = 0;
1725  if (space) {
1726  space = 0;
1727  if (rawBuf[from] != ' ') {
1728  rawBuf[to++] = ' ';
1729  from--;
1730  continue;
1731  }
1732  }
1733  rawBuf[to++] = rawBuf[from];
1734  }
1735  buf.setSize(to);
1736 
1737  while (to > 1) { // remove trailing excess
1738  to--;
1739  if ((rawBuf[to] == 10) || (rawBuf[to] == ' '))
1740  buf.setSize(to);
1741  else break;
1742  }
1743 }
char * getRawData()
Definition: swbuf.h:379
void setSize(unsigned long len)
Definition: swbuf.h:255
SWDEPRECATED void SWModule::processEntryAttributes ( bool  val) const
inlineinherited
Deprecated:
Use setProcessEntryAttributes

Definition at line 828 of file swmodule.h.

virtual void setProcessEntryAttributes(bool val) const
Definition: swmodule.h:824
virtual void SWModule::rawFilter ( SWBuf buf,
const SWKey key 
) const
inlinevirtualinherited

RawFilter a text buffer

Parameters
bufthe buffer to filter
keykey location from where this buffer was extracted

Definition at line 716 of file swmodule.h.

716  {
717  filterBuffer(rawFilters, buf, key);
718  }
FilterList * rawFilters
Definition: swmodule.h:146
virtual void filterBuffer(OptionFilterList *filters, SWBuf &buf, const SWKey *key) const
Definition: swmodule.cpp:1657
virtual SWModule& SWModule::removeEncodingFilter ( SWFilter oldFilter)
inlinevirtualinherited

Removes an EncodingFilter from this module's encodingFilters queue

Parameters
oldFilterthe filter to remove
Returns
*this

Definition at line 640 of file swmodule.h.

640  {
641  encodingFilters->remove(oldFilter);
642  return *this;
643  }
FilterList * encodingFilters
Definition: swmodule.h:155
SWDEPRECATED SWModule& SWModule::RemoveEncodingFilter ( SWFilter oldFilter)
inlineinherited
Deprecated:
Use removeEncodingFilter

Definition at line 647 of file swmodule.h.

647 { return removeEncodingFilter(oldFilter); }
virtual SWModule & removeEncodingFilter(SWFilter *oldFilter)
Definition: swmodule.h:640
virtual SWModule& SWModule::removeRenderFilter ( SWFilter oldFilter)
inlinevirtualinherited

Removes a RenderFilter from this module's renderFilters queue

Parameters
oldFilterthe filter to remove
Returns
*this

Definition at line 585 of file swmodule.h.

585  {
586  renderFilters->remove(oldFilter);
587  return *this;
588  }
FilterList * renderFilters
Definition: swmodule.h:149
SWDEPRECATED SWModule& SWModule::RemoveRenderFilter ( SWFilter oldFilter)
inlineinherited
Deprecated:
Use removeRenderFilter

Definition at line 592 of file swmodule.h.

592 { return removeRenderFilter(oldFilter); }
virtual SWModule & removeRenderFilter(SWFilter *oldFilter)
Definition: swmodule.h:585
virtual void SWModule::renderFilter ( SWBuf buf,
const SWKey key 
) const
inlinevirtualinherited

RenderFilter run a buf through this module's Render Filters

Parameters
bufthe buffer to filter
keykey location from where this buffer was extracted

Definition at line 616 of file swmodule.h.

616  {
617  filterBuffer(renderFilters, buf, key);
618  }
FilterList * renderFilters
Definition: swmodule.h:149
virtual void filterBuffer(OptionFilterList *filters, SWBuf &buf, const SWKey *key) const
Definition: swmodule.cpp:1657
SWBuf SWModule::renderText ( const char *  buf,
int  len = -1,
bool  render = true 
) const
inherited

Produces renderable text of the current module entry or supplied text

Parameters
bufbuffer to massage instead of current module entry; if buf is 0, the current module position text will be used
lenmax len to process
renderfor internal use
Returns
result buffer

Definition at line 1038 of file swmodule.cpp.

1038  {
1039  bool savePEA = isProcessEntryAttributes();
1040  if (!buf) {
1041  entryAttributes.clear();
1042  }
1043  else {
1045  }
1046 
1047  SWBuf local;
1048  if (buf)
1049  local = buf;
1050 
1051  SWBuf &tmpbuf = (buf) ? local : getRawEntryBuf();
1052  SWKey *key = 0;
1053  static const char *null = "";
1054 
1055  if (tmpbuf) {
1056  unsigned long size = (len < 0) ? ((getEntrySize()<0) ? strlen(tmpbuf) : getEntrySize()) : len;
1057  if (size > 0) {
1058  key = this->getKey();
1059 
1060  optionFilter(tmpbuf, key);
1061 
1062  if (render) {
1063  renderFilter(tmpbuf, key);
1064  encodingFilter(tmpbuf, key);
1065  }
1066  else stripFilter(tmpbuf, key);
1067  }
1068  }
1069  else {
1070  tmpbuf = null;
1071  }
1072 
1073  setProcessEntryAttributes(savePEA);
1074 
1075  return tmpbuf;
1076 }
virtual void renderFilter(SWBuf &buf, const SWKey *key) const
Definition: swmodule.h:616
Definition: swbuf.h:47
virtual void optionFilter(SWBuf &buf, const SWKey *key) const
Definition: swmodule.h:742
virtual SWKey * getKey() const
Definition: swmodule.cpp:284
virtual int getEntrySize() const
Definition: swmodule.h:243
virtual void encodingFilter(SWBuf &buf, const SWKey *key) const
Definition: swmodule.h:671
AttributeTypeList entryAttributes
Definition: swmodule.h:117
virtual SWBuf & getRawEntryBuf() const =0
virtual bool isProcessEntryAttributes() const
Definition: swmodule.h:832
virtual void setProcessEntryAttributes(bool val) const
Definition: swmodule.h:824
int size
Definition: regex.c:5043
SWKey * key
Definition: swmodule.h:124
Definition: swkey.h:77
virtual void stripFilter(SWBuf &buf, const SWKey *key) const
Definition: swmodule.h:707
SWBuf SWModule::renderText ( )
inherited

Definition at line 1017 of file swmodule.cpp.

1017  {
1018  return renderText((const char *)0);
1019 }
SWBuf renderText()
Definition: swmodule.cpp:1017
SWDEPRECATED const char* SWModule::RenderText ( const char *  buf = 0,
int  len = -1,
bool  render = true 
)
inlineinherited
Deprecated:
Use renderText

Definition at line 773 of file swmodule.h.

773 { return renderText(buf, len, render); }
SWBuf renderText()
Definition: swmodule.cpp:1017
SWBuf SWModule::renderText ( const SWKey tmpKey)
inherited

Produces renderable text of the module entry at the supplied key

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

Definition at line 1087 of file swmodule.cpp.

1087  {
1088  SWKey *saveKey;
1089  const char *retVal;
1090 
1091  if (!key->isPersist()) {
1092  saveKey = createKey();
1093  *saveKey = *key;
1094  }
1095  else saveKey = key;
1096 
1097  setKey(*tmpKey);
1098 
1099  retVal = renderText();
1100 
1101  setKey(*saveKey);
1102 
1103  if (!saveKey->isPersist())
1104  delete saveKey;
1105 
1106  return retVal;
1107 }
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
bool isPersist() const
Definition: swkey.cpp:99
SWKey * key
Definition: swmodule.h:124
virtual SWKey * createKey() const
Definition: swmodule.cpp:173
Definition: swkey.h:77
SWBuf renderText()
Definition: swmodule.cpp:1017
virtual SWModule& SWModule::replaceEncodingFilter ( SWFilter oldFilter,
SWFilter newFilter 
)
inlinevirtualinherited

Replaces an EncodingFilter in this module's encodingfilters queue

Parameters
oldFilterthe filter to remove
newFilterthe filter to add in its place
Returns
*this

Definition at line 654 of file swmodule.h.

654  {
655  FilterList::iterator iter;
656  for (iter = encodingFilters->begin(); iter != encodingFilters->end(); iter++) {
657  if (*iter == oldFilter)
658  *iter = newFilter;
659  }
660  return *this;
661  }
FilterList * encodingFilters
Definition: swmodule.h:155
SWDEPRECATED SWModule& SWModule::ReplaceEncodingFilter ( SWFilter oldFilter,
SWFilter newFilter 
)
inlineinherited
Deprecated:
Use replaceEncodingFilter

Definition at line 665 of file swmodule.h.

665 { return replaceEncodingFilter(oldFilter, newFilter); }
virtual SWModule & replaceEncodingFilter(SWFilter *oldFilter, SWFilter *newFilter)
Definition: swmodule.h:654
virtual SWModule& SWModule::replaceRenderFilter ( SWFilter oldFilter,
SWFilter newFilter 
)
inlinevirtualinherited

Replaces a RenderFilter in this module's renderfilters queue

Parameters
oldFilterthe filter to remove
newFilterthe filter to add in its place
Returns
*this

Definition at line 599 of file swmodule.h.

599  {
600  FilterList::iterator iter;
601  for (iter = renderFilters->begin(); iter != renderFilters->end(); iter++) {
602  if (*iter == oldFilter)
603  *iter = newFilter;
604  }
605  return *this;
606  }
FilterList * renderFilters
Definition: swmodule.h:149
SWDEPRECATED SWModule& SWModule::ReplaceRenderFilter ( SWFilter oldFilter,
SWFilter newFilter 
)
inlineinherited
Deprecated:
Use replaceRenderFilter

Definition at line 610 of file swmodule.h.

610 { return replaceRenderFilter(oldFilter, newFilter); }
virtual SWModule & replaceRenderFilter(SWFilter *oldFilter, SWFilter *newFilter)
Definition: swmodule.h:599
long SWCacher::resourceConsumption ( )
virtualinherited

Reimplemented in FileMgr.

Definition at line 42 of file swcacher.cpp.

42  {
43  return 0;
44 }
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 
)
virtualinherited

Searches a module

Parameters
istrstring for which to search
searchTypetype of search to perform SEARCHTYPE_REGEX - regex; (for backward compat, if > 0 then used as additional REGEX FLAGS) SEARCHTYPE_PHRASE - phrase SEARCHTYPE_MULTIWORD - multiword SEARCHTYPE_ENTRYATTR - entryAttrib (eg. Word//Lemma./G1234/) (Lemma with dot means check components (Lemma.[1-9]) also) SEARCHTYPE_EXTERNAL - Use External Search Framework (CLucene, Xapian, etc.) -5 - multilemma window; set 'flags' param to window size (NOT DONE)
flagsbitwise options flags for search. Each search type supports different options. REG_ICASE - perform case insensitive search. Supported by most all search types SEARCHFLAG_* - SWORD-specific search flags for various search types. See SWModule::SEARCHFLAG_ consts
scopeKey containing the scope. VerseKey or ListKey are useful here.
justCheckIfSupportedIf set, don't search but instead set this variable to true/false if the requested search is supported,
percentCallback function to get the current search status in %.
percentUserDataAnything that you might want to send to the precent callback function.
Returns
ListKey set to entry keys that match

Implements SWSearchable.

Definition at line 397 of file swmodule.cpp.

397  {
398 
399  listKey.clear();
400  SWBuf term = istr;
401  bool includeComponents = false; // for entryAttrib e.g., /Lemma.1/
402 
403  // this only works for 1 or 2 verses right now, and for some search types (regex and multi word).
404  // future plans are to extend functionality
405  // By default SWORD defaults to allowing searches to cross the artificial boundaries of verse markers
406  // Searching are done in a sliding window of 2 verses right now.
407  // To turn this off, include SEARCHFLAG_STRICTBOUNDARIES in search flags
408  int windowSize = 2;
409  if ((flags & SEARCHFLAG_STRICTBOUNDARIES) && (searchType == SEARCHTYPE_MULTIWORD || searchType > 0)) {
410  // remove custom SWORD flag to prevent possible overlap with unknown regex option
412  windowSize = 1;
413  }
414 
415  SWBuf target = getConfigEntry("AbsoluteDataPath");
416  if (!target.endsWith("/") && !target.endsWith("\\")) {
417  target.append('/');
418  }
419 #if defined USEXAPIAN
420  target.append("xapian");
421 #elif defined USELUCENE
422  target.append("lucene");
423 #endif
424  if (justCheckIfSupported) {
425  *justCheckIfSupported = (searchType >= SEARCHTYPE_ENTRYATTR);
426 #if defined USEXAPIAN
427  if ((searchType == SEARCHTYPE_EXTERNAL) && (FileMgr::existsDir(target))) {
428  *justCheckIfSupported = true;
429  }
430 #elif defined USELUCENE
431  if ((searchType == SEARCHTYPE_EXTERNAL) && (IndexReader::indexExists(target.c_str()))) {
432  *justCheckIfSupported = true;
433  }
434 #endif
435  return listKey;
436  }
437 
438  SWKey *saveKey = 0;
439  SWKey *searchKey = 0;
440  SWKey *resultKey = createKey();
441  SWKey *lastKey = createKey();
442  VerseKey *vkCheck = SWDYNAMIC_CAST(VerseKey, resultKey);
443  SWBuf lastBuf = "";
444 
445 #ifdef USECXX11REGEX
446  std::locale oldLocale;
447  std::locale::global(std::locale("en_US.UTF-8"));
448 
449  std::regex preg;
450 #elif defined(USEICUREGEX)
451  icu::RegexMatcher *matcher = 0;
452 #else
453  regex_t preg;
454 #endif
455 
456  vector<SWBuf> words;
457  vector<SWBuf> window;
458  const char *sres;
459  terminateSearch = false;
460  char perc = 1;
461  bool savePEA = isProcessEntryAttributes();
462 
463  // determine if we might be doing special strip searches. useful for knowing if we can use shortcuts
464  bool specialStrips = (getConfigEntry("LocalStripFilter")
465  || (getConfig().has("GlobalOptionFilter", "UTF8GreekAccents"))
466  || (getConfig().has("GlobalOptionFilter", "UTF8HebrewPoints"))
467  || (getConfig().has("GlobalOptionFilter", "UTF8ArabicPoints"))
468  || (strchr(istr, '<')));
469 
471 
472 
473  if (!key->isPersist()) {
474  saveKey = createKey();
475  *saveKey = *key;
476  }
477  else saveKey = key;
478 
479  searchKey = (scope)?scope->clone():(key->isPersist())?key->clone():0;
480  if (searchKey) {
481  searchKey->setPersist(true);
482  setKey(*searchKey);
483  }
484 
485  (*percent)(perc, percentUserData);
486 
487  *this = BOTTOM;
488  long highIndex = key->getIndex();
489  if (!highIndex)
490  highIndex = 1; // avoid division by zero errors.
491  *this = TOP;
492  if (searchType >= 0) {
493 #ifdef USECXX11REGEX
494  preg = std::regex((SWBuf(".*")+istr+".*").c_str(), std::regex_constants::extended | searchType | flags);
495 #elif defined(USEICUREGEX)
496  UErrorCode status = U_ZERO_ERROR;
497  matcher = new icu::RegexMatcher(istr, searchType | flags, status);
498  if (U_FAILURE(status)) {
499  SWLog::getSystemLog()->logError("Error compiling Regex: %d", status);
500  return listKey;
501  }
502 
503 #else
504  flags |=searchType|REG_NOSUB|REG_EXTENDED;
505  int err = regcomp(&preg, istr, flags);
506  if (err) {
507  SWLog::getSystemLog()->logError("Error compiling Regex: %d", err);
508  return listKey;
509  }
510 #endif
511  }
512 
513  (*percent)(++perc, percentUserData);
514 
515 
516 #if defined USEXAPIAN || defined USELUCENE
517  (*percent)(10, percentUserData);
518  if (searchType == SEARCHTYPE_EXTERNAL) { // indexed search
519 #if defined USEXAPIAN
520  SWTRY {
521  Xapian::Database database(target.c_str());
522  Xapian::QueryParser queryParser;
523  queryParser.set_default_op(Xapian::Query::OP_AND);
524  SWTRY {
525  queryParser.set_stemmer(Xapian::Stem(getLanguage()));
526  } SWCATCH(...) {}
527  queryParser.set_stemming_strategy(queryParser.STEM_SOME);
528  queryParser.add_prefix("content", "C");
529  queryParser.add_prefix("lemma", "L");
530  queryParser.add_prefix("morph", "M");
531  queryParser.add_prefix("prox", "P");
532  queryParser.add_prefix("proxlem", "PL");
533  queryParser.add_prefix("proxmorph", "PM");
534 
535 #elif defined USELUCENE
536 
537  lucene::index::IndexReader *ir = 0;
538  lucene::search::IndexSearcher *is = 0;
539  Query *q = 0;
540  Hits *h = 0;
541  SWTRY {
542  ir = IndexReader::open(target);
543  is = new IndexSearcher(ir);
544  const TCHAR *stopWords[] = { 0 };
545  standard::StandardAnalyzer analyzer(stopWords);
546 #endif
547 
548  // parse the query
549 #if defined USEXAPIAN
550  Xapian::Query q = queryParser.parse_query(istr);
551  Xapian::Enquire enquire = Xapian::Enquire(database);
552 #elif defined USELUCENE
553  q = QueryParser::parse((wchar_t *)utf8ToWChar(istr).getRawData(), _T("content"), &analyzer);
554 #endif
555  (*percent)(20, percentUserData);
556 
557  // perform the search
558 #if defined USEXAPIAN
559  enquire.set_query(q);
560  Xapian::MSet h = enquire.get_mset(0, 99999);
561 #elif defined USELUCENE
562  h = is->search(q);
563 #endif
564  (*percent)(80, percentUserData);
565 
566  // iterate thru each good module position that meets the search
567  bool checkBounds = getKey()->isBoundSet();
568 #if defined USEXAPIAN
569  Xapian::MSetIterator i;
570  for (i = h.begin(); i != h.end(); ++i) {
571 // cout << "Document ID " << *i << "\t";
572  SW_u64 score = i.get_percent();
573  Xapian::Document doc = i.get_document();
574  *resultKey = doc.get_data().c_str();
575 #elif defined USELUCENE
576  for (unsigned long i = 0; i < (unsigned long)h->length(); i++) {
577  Document &doc = h->doc(i);
578  // set a temporary verse key to this module position
579  *resultKey = wcharToUTF8(doc.get(_T("key"))); //TODO Does a key always accept utf8?
580  SW_u64 score = (SW_u64)((SW_u32)(h->score(i) * 100));
581 #endif
582 
583  // check to see if it sets ok (within our bounds) and if not, skip
584  if (checkBounds) {
585  *getKey() = *resultKey;
586  if (*getKey() != *resultKey) {
587  continue;
588  }
589  }
590  listKey << *resultKey;
591  listKey.getElement()->userData = score;
592  }
593  (*percent)(98, percentUserData);
594  }
595  SWCATCH (...) {
596 #if defined USEXAPIAN
597 #elif defined USELUCENE
598  q = 0;
599 #endif
600  // invalid clucene query
601  }
602 #if defined USEXAPIAN
603 #elif defined USELUCENE
604  delete h;
605  delete q;
606 
607  delete is;
608  if (ir) {
609  ir->close();
610  }
611 #endif
612  }
613 #endif
614 
615  // some pre-loop processing
616  switch (searchType) {
617 
618  case SEARCHTYPE_PHRASE:
619  // let's see if we're told to ignore case. If so, then we'll touppstr our term
620  if ((flags & REG_ICASE) == REG_ICASE) term.toUpper();
621  break;
622 
624  case -5:
625  // let's break the term down into our words vector
626  while (1) {
627  const char *word = term.stripPrefix(' ');
628  if (!word) {
629  words.push_back(term);
630  break;
631  }
632  words.push_back(word);
633  }
634  if ((flags & REG_ICASE) == REG_ICASE) {
635  for (unsigned int i = 0; i < words.size(); i++) {
636  words[i].toUpper();
637  }
638  }
639  break;
640 
641  // entry attributes
643  // let's break the attribute segs down. We'll reuse our words vector for each segment
644  while (1) {
645  const char *word = term.stripPrefix('/');
646  if (!word) {
647  words.push_back(term);
648  break;
649  }
650  words.push_back(word);
651  }
652  if ((words.size()>2) && words[2].endsWith(".")) {
653  includeComponents = true;
654  words[2]--;
655  }
656  break;
657  }
658 
659 
660  // our main loop to iterate the module and find the stuff
661  perc = 5;
662  (*percent)(perc, percentUserData);
663 
664 
665  while ((searchType != SEARCHTYPE_EXTERNAL) && !popError() && !terminateSearch) {
666  long mindex = key->getIndex();
667  float per = (float)mindex / highIndex;
668  per *= 93;
669  per += 5;
670  char newperc = (char)per;
671  if (newperc > perc) {
672  perc = newperc;
673  (*percent)(perc, percentUserData);
674  }
675  else if (newperc < perc) {
677  "Serious error: new percentage complete is less than previous value\nindex: %d\nhighIndex: %d\nnewperc == %d%% is smaller than\nperc == %d%%",
678  key->getIndex(), highIndex, (int)newperc, (int )perc);
679  }
680 
681  // regex
682  if (searchType >= 0) {
683  SWBuf textBuf = stripText();
684 #ifdef USECXX11REGEX
685  if (std::regex_match(std::string(textBuf.c_str()), preg)) {
686 #elif defined(USEICUREGEX)
687  icu::UnicodeString stringToTest = textBuf.c_str();
688  matcher->reset(stringToTest);
689 
690  if (matcher->find()) {
691 #else
692  if (!regexec(&preg, textBuf, 0, 0, 0)) {
693 #endif
694  *resultKey = *getKey();
695  resultKey->clearBounds();
696  listKey << *resultKey;
697  lastBuf = "";
698  }
699 #ifdef USECXX11REGEX
700  else if (std::regex_match(std::string((lastBuf + ' ' + textBuf).c_str()), preg)) {
701 #elif defined(USEICUREGEX)
702  else {
703  stringToTest = (lastBuf + ' ' + textBuf).c_str();
704  matcher->reset(stringToTest);
705 
706  if (matcher->find()) {
707 #else
708  else if (!regexec(&preg, lastBuf + ' ' + textBuf, 0, 0, 0)) {
709 #endif
710  lastKey->clearBounds();
711  if (vkCheck) {
712  resultKey->clearBounds();
713  *resultKey = *getKey();
714  vkCheck->setUpperBound(resultKey);
715  vkCheck->setLowerBound(lastKey);
716  }
717  else {
718  *resultKey = *lastKey;
719  resultKey->clearBounds();
720  }
721  listKey << *resultKey;
722  lastBuf = (windowSize > 1) ? textBuf.c_str() : "";
723  }
724  else {
725  lastBuf = (windowSize > 1) ? textBuf.c_str() : "";
726  }
727 #if defined(USEICUREGEX)
728  }
729 #endif
730  }
731 
732  else {
733  SWBuf textBuf;
734  switch (searchType) {
735 
736  case SEARCHTYPE_PHRASE: {
737  textBuf = stripText();
738  if ((flags & REG_ICASE) == REG_ICASE) textBuf.toUpper();
739  sres = strstr(textBuf.c_str(), term.c_str());
740  if (sres) { //it's also in the stripText(), so we have a valid search result item now
741  *resultKey = *getKey();
742  resultKey->clearBounds();
743  listKey << *resultKey;
744  }
745  break;
746  }
747 
748  case SEARCHTYPE_MULTIWORD: { // enclose our allocations
749  int stripped = 0;
750  int multiVerse = 0;
751  unsigned int foundWords = 0;
752  textBuf = getRawEntry();
753  SWBuf testBuf;
754 
755  // Here we loop twice, once for the current verse, to see if we have a simple match within our verse.
756  // This always takes precedence over a windowed search. If we match a window, but also one verse within
757  // our window matches by itself, prefer the single verse as the hit address-- the larger window is not needed.
758  //
759  // The second loop includes our current verse within the context of the sliding window
760  // Currrently that window size is set to 2 verses, but future plans include allowing this to be configurable
761  //
762  do {
763  // Herein lies optimization.
764  //
765  // First we check getRawEntry because it's the fastest;
766  // it might return false positives because all the markup is include, but is the quickest
767  // way to eliminate a verse. If it passes, then we do the real work to strip the markup and
768  // really test the verse for our keywords.
769  //
770  stripped = 0;
771  do {
772  if (stripped||specialStrips||multiVerse) {
773  testBuf = multiVerse ? lastBuf + ' ' + textBuf : textBuf;
774  if (stripped) testBuf = stripText(testBuf);
775  }
776  else testBuf.setSize(0);
777  foundWords = 0;
778 
779  if ((flags & REG_ICASE) == REG_ICASE) testBuf.size() ? testBuf.toUpper() : textBuf.toUpper();
780  for (unsigned int i = 0; i < words.size(); i++) {
781  sres = strstr(testBuf.size() ? testBuf.c_str() : textBuf.c_str(), words[i].c_str());
782  if (!sres) {
783  break; //for loop
784  }
785  foundWords++;
786  }
787 
788  ++stripped;
789  } while ( (stripped < 2) && (foundWords == words.size()));
790  ++multiVerse;
791  } while ((windowSize > 1) && (multiVerse < 2) && (stripped != 2 || foundWords != words.size()));
792 
793  if ((stripped == 2) && (foundWords == words.size())) { //we found the right words in both raw and stripped text, which means it's a valid result item
794  lastKey->clearBounds();
795  resultKey->clearBounds();
796  *resultKey = (multiVerse > 1 && !vkCheck) ? *lastKey : *getKey();
797  if (multiVerse > 1 && vkCheck) {
798  vkCheck->setUpperBound(resultKey);
799  vkCheck->setLowerBound(lastKey);
800  }
801  else {
802  resultKey->clearBounds();
803  }
804  listKey << *resultKey;
805  lastBuf = "";
806  // if we're searching windowSize > 1 and we had a hit which required the current verse
807  // let's start the next window with our current verse in case we have another hit adjacent
808  if (multiVerse == 2) {
809  lastBuf = textBuf;
810  }
811  }
812  else {
813  lastBuf = (windowSize > 1) ? textBuf.c_str() : "";
814  }
815  }
816  break;
817 
818  case SEARCHTYPE_ENTRYATTR: {
819  renderText(); // force parse
820  AttributeTypeList &entryAttribs = getEntryAttributes();
821  AttributeTypeList::iterator i1Start, i1End;
822  AttributeList::iterator i2Start, i2End;
823  AttributeValue::iterator i3Start, i3End;
824 
825  if ((words.size()) && (words[0].length())) {
826 // cout << "Word: " << words[0] << endl;
827  for (i1Start = entryAttribs.begin(); i1Start != entryAttribs.end(); ++i1Start) {
828 // cout << "stuff: " << i1Start->first.c_str() << endl;
829  }
830  i1Start = entryAttribs.find(words[0]);
831  i1End = i1Start;
832  if (i1End != entryAttribs.end()) {
833  i1End++;
834  }
835  }
836  else {
837  i1Start = entryAttribs.begin();
838  i1End = entryAttribs.end();
839  }
840  for (;i1Start != i1End; i1Start++) {
841  if ((words.size()>1) && (words[1].length())) {
842  i2Start = i1Start->second.find(words[1]);
843  i2End = i2Start;
844  if (i2End != i1Start->second.end())
845  i2End++;
846  }
847  else {
848  i2Start = i1Start->second.begin();
849  i2End = i1Start->second.end();
850  }
851  for (;i2Start != i2End; i2Start++) {
852  if ((words.size()>2) && (words[2].length()) && (!includeComponents)) {
853  i3Start = i2Start->second.find(words[2]);
854  i3End = i3Start;
855  if (i3End != i2Start->second.end())
856  i3End++;
857  }
858  else {
859  i3Start = i2Start->second.begin();
860  i3End = i2Start->second.end();
861  }
862  for (;i3Start != i3End; i3Start++) {
863  if ((words.size()>3) && (words[3].length())) {
864  if (includeComponents) {
865  SWBuf key = i3Start->first.c_str();
866  key = key.stripPrefix('.', true);
867  // we're iterating all 3 level keys, so be sure we match our
868  // prefix (e.g., Lemma, Lemma.1, Lemma.2, etc.)
869  if (key != words[2]) continue;
870  }
871  if (flags & SEARCHFLAG_MATCHWHOLEENTRY) {
872  bool found = !(((flags & REG_ICASE) == REG_ICASE) ? sword::stricmp(i3Start->second.c_str(), words[3]) : strcmp(i3Start->second.c_str(), words[3]));
873  sres = (found) ? i3Start->second.c_str() : 0;
874  }
875  else {
876  sres = ((flags & REG_ICASE) == REG_ICASE) ? stristr(i3Start->second.c_str(), words[3]) : strstr(i3Start->second.c_str(), words[3]);
877  }
878  if (sres) {
879  *resultKey = *getKey();
880  resultKey->clearBounds();
881  listKey << *resultKey;
882  break;
883  }
884  }
885  }
886  if (i3Start != i3End)
887  break;
888  }
889  if (i2Start != i2End)
890  break;
891  }
892  break;
893  }
894  // NOT DONE
895  case -5:
896  AttributeList &words = getEntryAttributes()["Word"];
897  SWBuf kjvWord = "";
898  SWBuf bibWord = "";
899  for (AttributeList::iterator it = words.begin(); it != words.end(); it++) {
900  int parts = atoi(it->second["PartCount"]);
901  SWBuf lemma = "";
902  SWBuf morph = "";
903  for (int i = 1; i <= parts; i++) {
904  SWBuf key = "";
905  key = (parts == 1) ? "Lemma" : SWBuf().setFormatted("Lemma.%d", i).c_str();
906  AttributeValue::iterator li = it->second.find(key);
907  if (li != it->second.end()) {
908  if (i > 1) lemma += " ";
909  key = (parts == 1) ? "LemmaClass" : SWBuf().setFormatted("LemmaClass.%d", i).c_str();
910  AttributeValue::iterator lci = it->second.find(key);
911  if (lci != it->second.end()) {
912  lemma += lci->second + ":";
913  }
914  lemma += li->second;
915  }
916  key = (parts == 1) ? "Morph" : SWBuf().setFormatted("Morph.%d", i).c_str();
917  li = it->second.find(key);
918  // silly. sometimes morph counts don't equal lemma counts
919  if (i == 1 && parts != 1 && li == it->second.end()) {
920  li = it->second.find("Morph");
921  }
922  if (li != it->second.end()) {
923  if (i > 1) morph += " ";
924  key = (parts == 1) ? "MorphClass" : SWBuf().setFormatted("MorphClass.%d", i).c_str();
925  AttributeValue::iterator lci = it->second.find(key);
926  // silly. sometimes morph counts don't equal lemma counts
927  if (i == 1 && parts != 1 && lci == it->second.end()) {
928  lci = it->second.find("MorphClass");
929  }
930  if (lci != it->second.end()) {
931  morph += lci->second + ":";
932  }
933  morph += li->second;
934  }
935  // TODO: add src tags and maybe other attributes
936  }
937  while (window.size() < (unsigned)flags) {
938 
939  }
940  }
941  break;
942  } // end switch
943  }
944  *lastKey = *getKey();
945  (*this)++;
946  }
947 
948 
949  // cleaup work
950  if (searchType >= 0) {
951 #ifdef USECXX11REGEX
952  std::locale::global(oldLocale);
953 #elif defined(USEICUREGEX)
954  delete matcher;
955 #else
956  regfree(&preg);
957 #endif
958  }
959 
960  setKey(*saveKey);
961 
962  if (!saveKey->isPersist())
963  delete saveKey;
964 
965  if (searchKey)
966  delete searchKey;
967  delete resultKey;
968  delete lastKey;
969 
970  listKey = TOP;
971  setProcessEntryAttributes(savePEA);
972 
973 
974  (*percent)(100, percentUserData);
975 
976 
977  return listKey;
978 }
virtual bool isBoundSet() const
Definition: swkey.h:189
ListKey listKey
Definition: swmodule.h:126
#define TOP
Definition: swkey.h:68
const char * getLanguage() const
Definition: swmodule.h:437
Definition: swbuf.h:47
static signed char existsDir(const char *ipath, const char *idirName=0)
Definition: filemgr.cpp:357
virtual const char * getConfigEntry(const char *key) const
Definition: swmodule.cpp:1159
static SWLog * getSystemLog()
Definition: swlog.cpp:53
std::map< SWBuf, AttributeList, std::less< SWBuf > > AttributeTypeList
Definition: swmodule.h:75
SWBuf wcharToUTF8(const wchar_t *buf)
Definition: utilstr.cpp:263
#define BOTTOM
Definition: swkey.h:69
virtual SWKey * getKey() const
Definition: swmodule.cpp:284
size_t length
Definition: regex.c:7928
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
virtual void clear()
Definition: listkey.cpp:87
SWBuf utf8ToWChar(const char *buf)
Definition: utilstr.cpp:239
#define SWTRY
Definition: defs.h:57
#define REG_ICASE
Definition: regex.h:261
bool endsWith(const SWBuf &postfix) const
Definition: swbuf.h:501
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
virtual SWKey * getElement(int pos=-1)
Definition: listkey.cpp:270
virtual SWKey * clone() const
Definition: swkey.cpp:75
void setLowerBound(const VerseKey &lb)
Definition: versekey.cpp:1112
virtual void clearBounds() const
Definition: swkey.h:190
void setPersist(bool ipersist)
Definition: swkey.cpp:135
bool isPersist() const
Definition: swkey.cpp:99
static const signed int SEARCHTYPE_MULTIWORD
Definition: swmodule.h:173
#define SWCATCH(x)
Definition: defs.h:58
const char * stristr(const char *s1, const char *s2)
Definition: utilstr.cpp:145
const char * c_str() const
Definition: swbuf.h:158
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
if(cflags &REG_ICASE)
Definition: regex.c:8096
static const signed int SEARCHTYPE_EXTERNAL
Definition: swmodule.h:175
virtual char popError()
Definition: swmodule.cpp:185
#define REG_EXTENDED
Definition: regex.h:257
#define SWDYNAMIC_CAST(className, object)
Definition: defs.h:47
void setUpperBound(const VerseKey &ub)
Definition: versekey.cpp:1135
unsigned long size() const
Definition: swbuf.h:185
const char * stripPrefix(char separator, bool endOfStringAsSeparator=false)
Definition: swbuf.h:457
virtual bool isProcessEntryAttributes() const
Definition: swmodule.h:832
virtual AttributeTypeList & getEntryAttributes() const
Definition: swmodule.h:817
virtual void setProcessEntryAttributes(bool val) const
Definition: swmodule.h:824
unsigned long long SW_u64
Definition: sysdata.h:56
SWBuf & toUpper()
Definition: swbuf.cpp:132
virtual const char * stripText(const char *buf=0, int len=-1)
Definition: swmodule.cpp:990
int regex_t * preg
Definition: regex.c:8079
void logError(const char *fmt,...) const
Definition: swlog.cpp:87
#define REG_NOSUB
Definition: regex.h:270
unsigned int SW_u32
Definition: sysdata.h:41
static const signed int SEARCHFLAG_MATCHWHOLEENTRY
Definition: swmodule.h:165
SW_u64 userData
Definition: swkey.h:115
SWKey * key
Definition: swmodule.h:124
virtual SWKey * createKey() const
Definition: swmodule.cpp:173
const char * string
Definition: regex.c:5014
SWBuf & setFormatted(const char *format,...)
Definition: swbuf.cpp:50
Definition: swkey.h:77
const char * getRawEntry() const
Definition: swmodule.h:500
virtual long getIndex() const
Definition: swkey.h:229
bool terminateSearch
Definition: swmodule.h:181
std::map< SWBuf, AttributeValue, std::less< SWBuf > > AttributeList
Definition: swmodule.h:74
void setSize(unsigned long len)
Definition: swbuf.h:255
virtual const ConfigEntMap & getConfig() const
Definition: swmodule.h:219
SWBuf renderText()
Definition: swmodule.cpp:1017
static const signed int SEARCHTYPE_PHRASE
Definition: swmodule.h:172
static const signed int SEARCHTYPE_ENTRYATTR
Definition: swmodule.h:174
static const signed int SEARCHFLAG_STRICTBOUNDARIES
Definition: swmodule.h:169
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 
)
inlineinherited
Deprecated:
Use search

Definition at line 478 of file swmodule.h.

478 { return search(istr, searchType, flags, scope, justCheckIfSupported, percent, percentUserData); }
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)
Definition: swmodule.cpp:397
void SWModule::setConfig ( ConfigEntMap config)
virtualinherited

Definition at line 1165 of file swmodule.cpp.

1165  {
1166  this->config = config;
1167 }
ConfigEntMap * config
Definition: swmodule.h:116
void SWModule::setDisplay ( SWDisplay idisp)
virtualinherited

Sets display driver

Parameters
idisppointer to SWDisplay class to assign to this module

Definition at line 262 of file swmodule.cpp.

262  {
263  disp = idisp;
264 }
SWDisplay * disp
Definition: swmodule.h:137
void SWModule::setEntry ( const char *  inbuf,
long  len = -1 
)
virtualinherited

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

Reimplemented in zText, zText4, RawFiles, zCom, zCom4, RawLD, RawLD4, zLD, RawGenBook, RawCom, RawCom4, RawText4, and RawText.

Definition at line 1680 of file swmodule.cpp.

1680  {
1681 }
void SWText::setIndex ( long  iindex)
virtualinherited

Reimplemented from SWModule.

Definition at line 83 of file swtext.cpp.

83  {
84  VerseKey *key = &getVerseKey();
85 
86  key->setTestament(1);
87  key->setIndex(iindex);
88 
89  if (key != this->key) {
90  this->key->copyFrom(*key);
91  }
92 }
virtual void setIndex(long iindex)
Definition: versekey.cpp:1718
virtual void copyFrom(const SWKey &ikey)
Definition: versekey.cpp:239
virtual void setTestament(char itestament)
Definition: versekey.cpp:1548
const VerseKey & getVerseKey(const SWKey *key=0) const
Definition: swtext.h:46
SWKey * key
Definition: swmodule.h:124
char SWModule::setKey ( const SWKey ikey)
virtualinherited

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

Parameters
ikeykey with which to set this module
Returns
error status

Definition at line 298 of file swmodule.cpp.

298  {
299  SWKey *oldKey = 0;
300 
301  if (key) {
302  if (!key->isPersist()) // if we have our own copy
303  oldKey = key;
304  }
305 
306  if (!ikey->isPersist()) { // if we are to keep our own copy
307  key = createKey();
308  *key = *ikey;
309  }
310  else key = (SWKey *)ikey; // if we are to just point to an external key
311 
312  if (oldKey)
313  delete oldKey;
314 
315  return error = key->getError();
316 }
char error
Definition: swmodule.h:120
bool isPersist() const
Definition: swkey.cpp:99
SWKey * key
Definition: swmodule.h:124
virtual char getError() const
Definition: swkey.h:164
virtual SWKey * createKey() const
Definition: swmodule.cpp:173
Definition: swkey.h:77
char SWModule::setKey ( const SWKey ikey)
inlineinherited

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

Parameters
ikeyThe SWKey which should be used as new key.
Returns
Error status

Definition at line 267 of file swmodule.h.

267 { return setKey(&ikey); }
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
SWDEPRECATED char SWModule::SetKey ( const SWKey ikey)
inlineinherited
Deprecated:
Use setKey() instead.

Definition at line 272 of file swmodule.h.

272 { return setKey(ikey); }
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
SWDEPRECATED char SWModule::SetKey ( const SWKey ikey)
inlineinherited
Deprecated:
Use setKey() instead.

Definition at line 276 of file swmodule.h.

276 { return setKey(ikey); }
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
char SWModule::setKeyText ( const char *  keyText)
inlineinherited

Sets this module's key to provided keyText without disturbing any settings on the a key itself This is simply a shortcut for the common module->getKey()->setText(keyText);

Parameters
keyTextkey with which to set this module
Returns
error status

Definition at line 260 of file swmodule.h.

260 { getKey()->setText(keyText); return key->getError(); }
virtual void setText(const char *ikey)
Definition: swkey.cpp:162
virtual SWKey * getKey() const
Definition: swmodule.cpp:284
SWKey * key
Definition: swmodule.h:124
virtual char getError() const
Definition: swkey.h:164
void SWModule::setPosition ( SW_POSITION  pos)
virtualinherited

Positions this modules to a logical position entry

Parameters
posposition (e.g. TOP, BOTTOM)

Reimplemented in SWLD.

Definition at line 327 of file swmodule.cpp.

327  {
328  *key = p;
329  char saveError = key->popError();
330 
331  switch (p) {
332  case POS_TOP:
333  this->increment();
334  this->decrement();
335  break;
336 
337  case POS_BOTTOM:
338  this->decrement();
339  this->increment();
340  break;
341  }
342 
343  error = saveError;
344 }
char error
Definition: swmodule.h:120
#define POS_TOP
Definition: swkey.h:65
virtual void decrement(int steps=1)
Definition: swmodule.cpp:369
virtual void increment(int steps=1)
Definition: swmodule.cpp:355
virtual char popError()
Definition: swkey.cpp:147
#define POS_BOTTOM
Definition: swkey.h:66
SWKey * key
Definition: swmodule.h:124
virtual void SWModule::setProcessEntryAttributes ( bool  val) const
inlinevirtualinherited

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 824 of file swmodule.h.

824 { procEntAttr = val; }
bool procEntAttr
Definition: swmodule.h:118
virtual void SWModule::setSkipConsecutiveLinks ( bool  val)
inlinevirtualinherited

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 797 of file swmodule.h.

797 { skipConsecutiveLinks = val; }
bool skipConsecutiveLinks
Definition: swmodule.h:121
void SWModule::setType ( const char *  imodtype)
inlineinherited

Sets module type

Parameters
imodtypeValue which to set modtype; [0]-only get

Definition at line 397 of file swmodule.h.

397 { stdstr(&modtype, imodtype); }
char * modtype
Definition: swmodule.h:129
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
virtual void SWModule::stripFilter ( SWBuf buf,
const SWKey key 
) const
inlinevirtualinherited

StripFilter run a buf through this module's Strip Filters

Parameters
bufthe buffer to filter
keykey location from where this buffer was extracted

Definition at line 707 of file swmodule.h.

707  {
708  filterBuffer(stripFilters, buf, key);
709  }
FilterList * stripFilters
Definition: swmodule.h:143
virtual void filterBuffer(OptionFilterList *filters, SWBuf &buf, const SWKey *key) const
Definition: swmodule.cpp:1657
const char * SWModule::stripText ( const char *  buf = 0,
int  len = -1 
)
virtualinherited

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

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

Definition at line 990 of file swmodule.cpp.

990  {
991  static SWBuf local;
992  local = renderText(buf, len, false);
993  return local.c_str();
994 }
Definition: swbuf.h:47
const char * c_str() const
Definition: swbuf.h:158
SWBuf renderText()
Definition: swmodule.cpp:1017
SWDEPRECATED const char* SWModule::StripText ( const char *  buf = 0,
int  len = -1 
)
inlineinherited
Deprecated:
Use stripText

Definition at line 758 of file swmodule.h.

758 { return stripText(buf, len); }
virtual const char * stripText(const char *buf=0, int len=-1)
Definition: swmodule.cpp:990
const char * SWModule::stripText ( const SWKey tmpKey)
virtualinherited

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

Parameters
tmpKeydesired module entry
Returns
result buffer

Definition at line 1118 of file swmodule.cpp.

1118  {
1119  SWKey *saveKey;
1120  const char *retVal;
1121 
1122  if (!key->isPersist()) {
1123  saveKey = createKey();
1124  *saveKey = *key;
1125  }
1126  else saveKey = key;
1127 
1128  setKey(*tmpKey);
1129 
1130  retVal = stripText();
1131 
1132  setKey(*saveKey);
1133 
1134  if (!saveKey->isPersist())
1135  delete saveKey;
1136 
1137  return retVal;
1138 }
virtual char setKey(const SWKey *ikey)
Definition: swmodule.cpp:298
bool isPersist() const
Definition: swkey.cpp:99
virtual const char * stripText(const char *buf=0, int len=-1)
Definition: swmodule.cpp:990
SWKey * key
Definition: swmodule.h:124
virtual SWKey * createKey() const
Definition: swmodule.cpp:173
Definition: swkey.h:77
SWDEPRECATED const char* SWModule::Type ( ) const
inlineinherited
Deprecated:
Use getType

Definition at line 391 of file swmodule.h.

391 { return getType(); }
const char * getType() const
Definition: swmodule.cpp:232
SWDEPRECATED const char* SWModule::Type ( const char *  imodtype)
inlineinherited
Deprecated:
Use setType / getType

Definition at line 401 of file swmodule.h.

401 { setType(imodtype); return getType(); }
const char * getType() const
Definition: swmodule.cpp:232
void setType(const char *imodtype)
Definition: swmodule.h:397

Member Data Documentation

ConfigEntMap* SWModule::config
protectedinherited

Definition at line 116 of file swmodule.h.

char SWModule::direction
protectedinherited

Definition at line 132 of file swmodule.h.

SWDisplay* SWModule::disp
protectedinherited

this module's display object

Definition at line 137 of file swmodule.h.

char SWModule::encoding
protectedinherited

Definition at line 134 of file swmodule.h.

FilterList* SWModule::encodingFilters
protectedinherited

filters to be executed to decode text for display

Definition at line 155 of file swmodule.h.

AttributeTypeList SWModule::entryAttributes
mutableprotectedinherited

Definition at line 117 of file swmodule.h.

SWBuf SWModule::entryBuf
mutableprotectedinherited

Definition at line 140 of file swmodule.h.

long SWModule::entryIndex
mutableprotectedinherited

Definition at line 158 of file swmodule.h.

int SWModule::entrySize
mutableprotectedinherited

Definition at line 157 of file swmodule.h.

char SWModule::error
mutableprotectedinherited

Definition at line 120 of file swmodule.h.

SWKey* SWModule::key
protectedinherited

the current key

Definition at line 124 of file swmodule.h.

ListKey SWModule::listKey
protectedinherited

Definition at line 126 of file swmodule.h.

char SWModule::markup
protectedinherited

Definition at line 133 of file swmodule.h.

char* SWModule::moddesc
protectedinherited

Definition at line 128 of file swmodule.h.

char* SWModule::modlang
protectedinherited

Definition at line 130 of file swmodule.h.

char* SWModule::modname
protectedinherited

Definition at line 127 of file swmodule.h.

char* SWModule::modtype
protectedinherited

Definition at line 129 of file swmodule.h.

OptionFilterList* SWModule::optionFilters
protectedinherited

filters to be executed to change markup to user prefs

Definition at line 152 of file swmodule.h.

ConfigEntMap SWModule::ownConfig
protectedinherited

Definition at line 115 of file swmodule.h.

bool SWModule::procEntAttr
mutableprotectedinherited

Definition at line 118 of file swmodule.h.

SWORD_NAMESPACE_START SWModule::StdOutDisplay SWModule::rawdisp
staticprotectedinherited

Definition at line 139 of file swmodule.h.

FilterList* SWModule::rawFilters
protectedinherited

filters to be executed immediately upon fileread

Definition at line 146 of file swmodule.h.

FilterList* SWModule::renderFilters
protectedinherited

filters to be executed to format for display

Definition at line 149 of file swmodule.h.

const signed int SWModule::SEARCHFLAG_MATCHWHOLEENTRY = 4096
staticinherited

Definition at line 165 of file swmodule.h.

const signed int SWModule::SEARCHFLAG_STRICTBOUNDARIES = 8192
staticinherited

Definition at line 169 of file swmodule.h.

const signed int SWModule::SEARCHTYPE_ENTRYATTR = -3
staticinherited

Definition at line 174 of file swmodule.h.

const signed int SWModule::SEARCHTYPE_EXTERNAL = -4
staticinherited

Definition at line 175 of file swmodule.h.

const signed int SWModule::SEARCHTYPE_MULTIWORD = -2
staticinherited

Definition at line 173 of file swmodule.h.

const signed int SWModule::SEARCHTYPE_PHRASE = -1
staticinherited

Definition at line 172 of file swmodule.h.

const signed int SWModule::SEARCHTYPE_REGEX = 0
staticinherited

Definition at line 171 of file swmodule.h.

bool SWModule::skipConsecutiveLinks
protectedinherited

Definition at line 121 of file swmodule.h.

FilterList* SWModule::stripFilters
protectedinherited

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

Definition at line 143 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 181 of file swmodule.h.


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