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

#include <ztext.h>

+ Inheritance diagram for zText:
+ Collaboration diagram for zText:

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 ()
 
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
 
void findOffset (char testmt, long idxoff, long *start, unsigned short *size, unsigned long *buffnum) 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 *k) const
 
virtual bool hasSearchFramework ()
 
virtual void increment (int steps=1)
 
SWDEPRECATED long Index () const
 
SWDEPRECATED long Index (long iindex)
 
virtual bool isLinked (const SWKey *k1, const SWKey *k2) const
 
virtual bool isProcessEntryAttributes () const
 
virtual bool isSearchOptimallySupported (const char *istr, int searchType, int flags, SWKey *scope)
 
virtual bool isSkipConsecutiveLinks ()
 
virtual bool isUnicode () const
 
virtual bool isWritable () const
 
SWDEPRECATED 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 *linkKey)
 
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 void rawZFilter (SWBuf &buf, char direction=0) 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)
 
void zReadText (char testmt, long start, unsigned short size, unsigned long buffnum, SWBuf &buf) const
 
 zText (const char *ipath, const char *iname=0, const char *idesc=0, int blockType=CHAPTERBLOCKS, SWCompress *icomp=0, SWDisplay *idisp=0, SWTextEncoding encoding=ENC_UNKNOWN, SWTextDirection dir=DIRECTION_LTR, SWTextMarkup markup=FMT_UNKNOWN, const char *ilang=0, const char *versification="KJV")
 
virtual ~zText ()
 

Static Public Member Functions

static char createModule (const char *path, int blockBound, const char *v11n="KJV")
 
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
 
static const char uniqueIndexID [] = {'X', 'r', 'v', 'c', 'b'}
 

Protected Member Functions

void doLinkEntry (char testmt, long destidxoff, long srcidxoff)
 
void doSetText (char testmt, long idxoff, const char *buf, long len=0)
 
void flushCache () const
 
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

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

Static Protected Attributes

static int instance = 0
 
static StdOutDisplay rawdisp
 

Private Member Functions

bool sameBlock (VerseKey *lastWriteKey, VerseKey *key)
 

Private Attributes

int blockType
 
VerseKeylastWriteKey
 

Detailed Description

Definition at line 39 of file ztext.h.

Constructor & Destructor Documentation

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

Definition at line 46 of file ztext.cpp.

47  : zVerse(ipath, FileMgr::RDWR, iblockType, icomp), SWText(iname, idesc, idisp, enc, dir, mark, ilang, versification) {
48  blockType = iblockType;
49  lastWriteKey = 0;
50 }
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
static unsigned int RDWR
Definition: filemgr.h:76
VerseKey * lastWriteKey
Definition: ztext.h:42
int blockType
Definition: ztext.h:44
char * versification
Definition: swtext.h:43
zVerse(const char *ipath, int fileMode=-1, int blockType=CHAPTERBLOCKS, SWCompress *icomp=0)
Definition: zverse.cpp:63
zText::~zText ( )
virtual

Definition at line 57 of file ztext.cpp.

58 {
59  flushCache();
60 
61  if (lastWriteKey)
62  delete lastWriteKey;
63 
64 }
VerseKey * lastWriteKey
Definition: ztext.h:42
void flushCache() const
Definition: zverse.cpp:339

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
static char zText::createModule ( const char *  path,
int  blockBound,
const char *  v11n = "KJV" 
)
inlinestatic

Definition at line 62 of file ztext.h.

62  {
63  return zVerse::createModule(path, blockBound, v11n);
64  }
SWBuf v11n
Definition: osis2mod.cpp:107
static char createModule(const char *path, int blockBound, const char *v11n="KJV")
Definition: zverse.cpp:426
char * path
Definition: zverse.h:46
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
virtual void zText::decrement ( int  steps = 1)
inlinevirtual

Decrements module key a number of entries

Parameters
stepsNumber of entries to jump backward

Reimplemented from SWModule.

Definition at line 58 of file ztext.h.

58 { increment(-steps); }
virtual void increment(int steps=1)
Definition: ztext.cpp:160
void zText::deleteEntry ( )
virtual

Delete current module entry - only if module isWritable()

Reimplemented from SWModule.

Definition at line 145 of file ztext.cpp.

145  {
146 
147  VerseKey &key = getVerseKey();
148 
149  doSetText(key.getTestament(), key.getTestamentIndex(), "");
150 }
void doSetText(char testmt, long idxoff, const char *buf, long len=0)
Definition: zverse.cpp:299
const VerseKey & getVerseKey(const SWKey *key=0) const
Definition: swtext.h:46
virtual long getTestamentIndex() const
Definition: versekey.cpp:1704
SWKey * key
Definition: swmodule.h:124
virtual char getTestament() const
Definition: versekey.cpp:1498
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
void zVerse::doLinkEntry ( char  testmt,
long  destidxoff,
long  srcidxoff 
)
protectedinherited

Definition at line 394 of file zverse.cpp.

394  {
395  SW_s32 bufidx;
396  SW_s32 start;
397  SW_u16 size;
398 
399  destidxoff *= 10;
400  srcidxoff *= 10;
401 
402  if (!testmt)
403  testmt = ((idxfp[1]) ? 1:2);
404 
405  // get source
406  compfp[testmt-1]->seek(srcidxoff, SEEK_SET);
407  compfp[testmt-1]->read(&bufidx, 4);
408  compfp[testmt-1]->read(&start, 4);
409  compfp[testmt-1]->read(&size, 2);
410 
411  // write dest
412  compfp[testmt-1]->seek(destidxoff, SEEK_SET);
413  compfp[testmt-1]->write(&bufidx, 4);
414  compfp[testmt-1]->write(&start, 4);
415  compfp[testmt-1]->write(&size, 2);
416 }
long seek(long offset, int whence)
Definition: filemgr.cpp:143
signed int SW_s32
Definition: sysdata.h:40
long write(const void *buf, long count)
Definition: filemgr.cpp:153
unsigned short SW_u16
Definition: sysdata.h:38
#define SEEK_SET
Definition: zconf.h:244
int size
Definition: regex.c:5043
FileDesc * compfp[2]
Definition: zverse.h:45
long read(void *buf, long count)
Definition: filemgr.cpp:148
FileDesc * idxfp[2]
Definition: zverse.h:43
void zVerse::doSetText ( char  testmt,
long  idxoff,
const char *  buf,
long  len = 0 
)
protectedinherited

Definition at line 299 of file zverse.cpp.

299  {
300 
301  len = (len < 0) ? strlen(buf) : len;
302  if (!testmt)
303  testmt = ((idxfp[0]) ? 1:2);
304  if ((!dirtyCache) || (cacheBufIdx < 0)) {
305  cacheBufIdx = idxfp[testmt-1]->seek(0, SEEK_END) / 12;
306  cacheTestament = testmt;
307  if (cacheBuf)
308  free(cacheBuf);
309  cacheBuf = (char *)calloc(len + 1, 1);
310  }
311  else cacheBuf = (char *)((cacheBuf)?realloc(cacheBuf, strlen(cacheBuf)+(len + 1)):calloc((len + 1), 1));
312 
313  dirtyCache = true;
314 
315  SW_u32 start;
316  SW_u16 size;
317  SW_u32 outBufIdx = (SW_u32)cacheBufIdx;
318 
319  idxoff *= 10;
320  size = len;
321 
322  start = (SW_u32)strlen(cacheBuf);
323 
324  if (!size)
325  start = outBufIdx = 0;
326 
327  outBufIdx = archtosword32(outBufIdx);
328  start = archtosword32(start);
329  size = archtosword16(size);
330 
331  compfp[testmt-1]->seek(idxoff, SEEK_SET);
332  compfp[testmt-1]->write(&outBufIdx, 4);
333  compfp[testmt-1]->write(&start, 4);
334  compfp[testmt-1]->write(&size, 2);
335  strcat(cacheBuf, buf);
336 }
long seek(long offset, int whence)
Definition: filemgr.cpp:143
#define archtosword32(x)
Definition: sysdata.h:97
char cacheTestament
Definition: zverse.h:52
char * cacheBuf
Definition: zverse.h:50
bool dirtyCache
Definition: zverse.h:54
#define SEEK_END
Definition: zconf.h:246
long cacheBufIdx
Definition: zverse.h:53
long write(const void *buf, long count)
Definition: filemgr.cpp:153
free(preg->fastmap)
char * realloc()
unsigned short SW_u16
Definition: sysdata.h:38
#define SEEK_SET
Definition: zconf.h:244
int size
Definition: regex.c:5043
FileDesc * compfp[2]
Definition: zverse.h:45
unsigned int SW_u32
Definition: sysdata.h:41
#define archtosword16(x)
Definition: sysdata.h:96
FileDesc * idxfp[2]
Definition: zverse.h:43
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 zVerse::findOffset ( char  testmt,
long  idxoff,
long *  start,
unsigned short *  size,
unsigned long *  buffnum 
) const
inherited

Definition at line 150 of file zverse.cpp.

151 {
152  SW_u32 ulBuffNum = 0; // buffer number
153  SW_u32 ulVerseStart = 0; // verse offset within buffer
154  SW_u16 usVerseSize = 0; // verse size
155  // set start to offset in
156  // set size to
157  // set
158  *start = *size = *buffnum = 0;
159  //fprintf(stderr, "Finding offset %ld\n", idxoff);
160  idxoff *= 10;
161  if (!testmt) {
162  testmt = ((idxfp[0]) ? 1:2);
163  }
164 
165  // assert we have and valid file descriptor
166  if (compfp[testmt-1]->getFd() < 1)
167  return;
168 
169  long newOffset = compfp[testmt-1]->seek(idxoff, SEEK_SET);
170  if (newOffset == idxoff) {
171  if (compfp[testmt-1]->read(&ulBuffNum, 4) != 4) {
172  fprintf(stderr, "Error reading ulBuffNum\n");
173  return;
174  }
175  }
176  else return;
177 
178  if (compfp[testmt-1]->read(&ulVerseStart, 4) < 2)
179  {
180  fprintf(stderr, "Error reading ulVerseStart\n");
181  return;
182  }
183  if (compfp[testmt-1]->read(&usVerseSize, 2) < 2)
184  {
185  fprintf(stderr, "Error reading usVerseSize\n");
186  return;
187  }
188 
189  *buffnum = swordtoarch32(ulBuffNum);
190  *start = swordtoarch32(ulVerseStart);
191  *size = swordtoarch16(usVerseSize);
192 
193 }
long seek(long offset, int whence)
Definition: filemgr.cpp:143
#define swordtoarch32(x)
Definition: sysdata.h:94
unsigned short SW_u16
Definition: sysdata.h:38
#define SEEK_SET
Definition: zconf.h:244
int size
Definition: regex.c:5043
FileDesc * compfp[2]
Definition: zverse.h:45
#define swordtoarch16(x)
Definition: sysdata.h:93
unsigned int SW_u32
Definition: sysdata.h:41
FileDesc * idxfp[2]
Definition: zverse.h:43
virtual void zText::flush ( )
inlinevirtual

Reimplemented from SWCacher.

Definition at line 74 of file ztext.h.

74 { flushCache(); }
void flushCache() const
Definition: zverse.cpp:339
void zVerse::flushCache ( ) const
protectedinherited

Definition at line 339 of file zverse.cpp.

339  {
340  if (dirtyCache) {
341  SW_u32 idxoff;
342  SW_u32 start, outstart;
343  SW_u32 size, outsize;
344  SW_u32 zsize, outzsize;
345 
346  idxoff = (SW_u32)cacheBufIdx * 12;
347  if (cacheBuf) {
348  size = outsize = zsize = outzsize = (SW_u32)strlen(cacheBuf);
349  if (size) {
350  // if (compressor) {
351  // delete compressor;
352  // compressor = new LZSSCompress();
353  // }
355  unsigned long tmpSize;
356  compressor->getCompressedBuf(&tmpSize);
357  outzsize = zsize = (SW_u32)tmpSize;
358 
359  SWBuf buf;
360  buf.setSize(zsize + 5);
361  memcpy(buf.getRawData(), compressor->getCompressedBuf(&tmpSize), tmpSize);
362  outzsize = zsize = (SW_u32)tmpSize;
363  buf.setSize(zsize);
364  rawZFilter(buf, 1); // 1 = encipher
365 
366  start = outstart = (SW_u32)textfp[cacheTestament - 1]->seek(0, SEEK_END);
367 
368  outstart = archtosword32(start);
369  outsize = archtosword32(size);
370  outzsize = archtosword32(zsize);
371 
372  textfp[cacheTestament-1]->write(buf, zsize);
373 
374  idxfp[cacheTestament-1]->seek(idxoff, SEEK_SET);
375  idxfp[cacheTestament-1]->write(&outstart, 4);
376  idxfp[cacheTestament-1]->write(&outzsize, 4);
377  idxfp[cacheTestament-1]->write(&outsize, 4);
378  }
379  free(cacheBuf);
380  cacheBuf = 0;
381  }
382  dirtyCache = false;
383  }
384 }
SWCompress * compressor
Definition: zverse.h:38
FileDesc * textfp[2]
Definition: zverse.h:44
long seek(long offset, int whence)
Definition: filemgr.cpp:143
Definition: swbuf.h:47
#define archtosword32(x)
Definition: sysdata.h:97
char cacheTestament
Definition: zverse.h:52
char * cacheBuf
Definition: zverse.h:50
bool dirtyCache
Definition: zverse.h:54
#define SEEK_END
Definition: zconf.h:246
long cacheBufIdx
Definition: zverse.h:53
virtual char * getCompressedBuf(unsigned long *len=0)
Definition: swcomprs.cpp:111
long write(const void *buf, long count)
Definition: filemgr.cpp:153
virtual void setUncompressedBuf(const char *buf=0, unsigned long *len=0)
Definition: swcomprs.cpp:75
char * getRawData()
Definition: swbuf.h:379
free(preg->fastmap)
virtual void rawZFilter(SWBuf &buf, char direction=0) const
Definition: zverse.h:70
#define SEEK_SET
Definition: zconf.h:244
int size
Definition: regex.c:5043
unsigned int SW_u32
Definition: sysdata.h:41
FileDesc * idxfp[2]
Definition: zverse.h:43
void setSize(unsigned long len)
Definition: swbuf.h:255
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 & zText::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 76 of file ztext.cpp.

76  {
77  long start = 0;
78  unsigned short size = 0;
79  unsigned long buffnum = 0;
80  const VerseKey &key = getVerseKey();
81 
82  findOffset(key.getTestament(), key.getTestamentIndex(), &start, &size, &buffnum);
83  entrySize = size; // support getEntrySize call
84 
85  entryBuf = "";
86 
87  zReadText(key.getTestament(), start, size, buffnum, entryBuf);
88  rawFilter(entryBuf, &key);
89 
90 // if (!isUnicode())
92 
93  return entryBuf;
94 }
static void prepText(SWBuf &buf)
Definition: swmodule.cpp:1695
virtual void rawFilter(SWBuf &buf, const SWKey *key) const
Definition: swmodule.h:716
void zReadText(char testmt, long start, unsigned short size, unsigned long buffnum, SWBuf &buf) const
Definition: zverse.cpp:206
void findOffset(char testmt, long idxoff, long *start, unsigned short *size, unsigned long *buffnum) const
Definition: zverse.cpp:150
int entrySize
Definition: swmodule.h:157
const VerseKey & getVerseKey(const SWKey *key=0) const
Definition: swtext.h:46
int size
Definition: regex.c:5043
SWBuf entryBuf
Definition: swmodule.h:140
virtual long getTestamentIndex() const
Definition: versekey.cpp:1704
SWKey * key
Definition: swmodule.h:124
virtual char getTestament() const
Definition: versekey.cpp:1498
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
bool zText::hasEntry ( const SWKey k) const
virtual

Reimplemented from SWModule.

Definition at line 212 of file ztext.cpp.

212  {
213  long start;
214  unsigned short size;
215  unsigned long buffnum;
216  const VerseKey *vk = &getVerseKey(k);
217 
218  findOffset(vk->getTestament(), vk->getTestamentIndex(), &start, &size, &buffnum);
219  return size;
220 }
void findOffset(char testmt, long idxoff, long *start, unsigned short *size, unsigned long *buffnum) const
Definition: zverse.cpp:150
const VerseKey & getVerseKey(const SWKey *key=0) const
Definition: swtext.h:46
int size
Definition: regex.c:5043
virtual long getTestamentIndex() const
Definition: versekey.cpp:1704
virtual char getTestament() const
Definition: versekey.cpp:1498
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 zText::increment ( int  steps = 1)
virtual

Increments module key a number of entries

Parameters
stepsNumber of entries to jump forward

Reimplemented from SWModule.

Definition at line 160 of file ztext.cpp.

160  {
161  long start;
162  unsigned short size;
163  unsigned long buffnum;
164  VerseKey *tmpkey = &getVerseKey();
165 
166  findOffset(tmpkey->getTestament(), tmpkey->getTestamentIndex(), &start, &size, &buffnum);
167 
168  SWKey lastgood = *tmpkey;
169  while (steps) {
170  long laststart = start;
171  unsigned short lastsize = size;
172  SWKey lasttry = *tmpkey;
173  (steps > 0) ? ++(*key) : --(*key);
174  tmpkey = &getVerseKey();
175 
176  if ((error = key->popError())) {
177  *key = lastgood;
178  break;
179  }
180  long index = tmpkey->getTestamentIndex();
181  findOffset(tmpkey->getTestament(), index, &start, &size, &buffnum);
182 
183  if (
184  (
185  ((laststart != start) || (lastsize != size)) // we're a different entry
186 // && (start > 0)
187  && (size) // and we actually have a size
188  )
190  ) { // or we don't want to skip consecutive links
191  steps += (steps < 0) ? 1 : -1;
192  lastgood = *tmpkey;
193  }
194  }
195  error = (error) ? KEYERR_OUTOFBOUNDS : 0;
196 }
char error
Definition: swmodule.h:120
void findOffset(char testmt, long idxoff, long *start, unsigned short *size, unsigned long *buffnum) const
Definition: zverse.cpp:150
bool skipConsecutiveLinks
Definition: swmodule.h:121
#define KEYERR_OUTOFBOUNDS
Definition: swkey.h:35
virtual char popError()
Definition: swkey.cpp:147
const VerseKey & getVerseKey(const SWKey *key=0) const
Definition: swtext.h:46
int size
Definition: regex.c:5043
virtual long getTestamentIndex() const
Definition: versekey.cpp:1704
SWKey * key
Definition: swmodule.h:124
Definition: swkey.h:77
virtual char getTestament() const
Definition: versekey.cpp:1498
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
bool zText::isLinked ( const SWKey k1,
const SWKey k2 
) const
virtual

Reimplemented from SWModule.

Definition at line 199 of file ztext.cpp.

199  {
200  long start1, start2;
201  unsigned short size1, size2;
202  unsigned long buffnum1, buffnum2;
203  const VerseKey *vk1 = &getVerseKey(k1);
204  const VerseKey *vk2 = &getVerseKey(k2);
205  if (vk1->getTestament() != vk2->getTestament()) return false;
206 
207  findOffset(vk1->getTestament(), vk1->getTestamentIndex(), &start1, &size1, &buffnum1);
208  findOffset(vk2->getTestament(), vk2->getTestamentIndex(), &start2, &size2, &buffnum2);
209  return start1 == start2 && buffnum1 == buffnum2;
210 }
int size2
Definition: regex.c:5079
void findOffset(char testmt, long idxoff, long *start, unsigned short *size, unsigned long *buffnum) const
Definition: zverse.cpp:150
const VerseKey & getVerseKey(const SWKey *key=0) const
Definition: swtext.h:46
virtual long getTestamentIndex() const
Definition: versekey.cpp:1704
int size1
Definition: regex.c:5079
virtual char getTestament() const
Definition: versekey.cpp:1498
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
bool zText::isWritable ( ) const
virtual

Is the module writable? :)

Returns
yes or no

Reimplemented from SWModule.

Definition at line 67 of file ztext.cpp.

67 { return ((idxfp[0]->getFd() > 0) && ((idxfp[0]->mode & FileMgr::RDWR) == FileMgr::RDWR)); }
static unsigned int RDWR
Definition: filemgr.h:76
FileDesc * idxfp[2]
Definition: zverse.h:43
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 zText::linkEntry ( const SWKey sourceKey)
virtual

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

Reimplemented from SWModule.

Definition at line 133 of file ztext.cpp.

133  {
134  VerseKey &destkey = getVerseKey();
135  const VerseKey *srckey = &getVerseKeyConst(inkey);
136  doLinkEntry(destkey.getTestament(), destkey.getTestamentIndex(), srckey->getTestamentIndex());
137 }
const VerseKey & getVerseKeyConst(const SWKey *key=0) const
Definition: swtext.cpp:95
const VerseKey & getVerseKey(const SWKey *key=0) const
Definition: swtext.h:46
virtual long getTestamentIndex() const
Definition: versekey.cpp:1704
void doLinkEntry(char testmt, long destidxoff, long srcidxoff)
Definition: zverse.cpp:394
virtual char getTestament() const
Definition: versekey.cpp:1498
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 void zText::rawZFilter ( SWBuf buf,
char  direction = 0 
) const
inlinevirtual

Reimplemented from zVerse.

Definition at line 71 of file ztext.h.

71 { rawFilter(buf, (SWKey *)(long)direction); }// hack, use key as direction for enciphering
virtual void rawFilter(SWBuf &buf, const SWKey *key) const
Definition: swmodule.h:716
char direction
Definition: swmodule.h:132
Definition: swkey.h:77
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 }
bool zText::sameBlock ( VerseKey lastWriteKey,
VerseKey key 
)
private

Definition at line 97 of file ztext.cpp.

97  {
98  if (k1->getTestament() != k2->getTestament())
99  return false;
100 
101  switch (blockType) {
102  case VERSEBLOCKS:
103  if (k1->getVerse() != k2->getVerse())
104  return false;
105  case CHAPTERBLOCKS:
106  if (k1->getChapter() != k2->getChapter())
107  return false;
108  case BOOKBLOCKS:
109  if (k1->getBook() != k2->getBook())
110  return false;
111  }
112  return true;
113 }
#define VERSEBLOCKS
Definition: zverse.h:58
int blockType
Definition: ztext.h:44
#define CHAPTERBLOCKS
Definition: zverse.h:59
#define BOOKBLOCKS
Definition: zverse.h:60
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 zText::setEntry ( const char *  inbuf,
long  len = -1 
)
virtual

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

Reimplemented from SWModule.

Definition at line 116 of file ztext.cpp.

116  {
117  VerseKey &key = getVerseKey();
118 
119  // see if we've jumped across blocks since last write
120  if (lastWriteKey) {
121  if (!sameBlock(lastWriteKey, &key)) {
122  flushCache();
123  }
124  delete lastWriteKey;
125  }
126 
127  doSetText(key.getTestament(), key.getTestamentIndex(), inbuf, len);
128 
129  lastWriteKey = (VerseKey *)key.clone(); // must delete
130 }
void doSetText(char testmt, long idxoff, const char *buf, long len=0)
Definition: zverse.cpp:299
virtual SWKey * clone() const
Definition: versekey.cpp:278
VerseKey * lastWriteKey
Definition: ztext.h:42
bool sameBlock(VerseKey *lastWriteKey, VerseKey *key)
Definition: ztext.cpp:97
const VerseKey & getVerseKey(const SWKey *key=0) const
Definition: swtext.h:46
virtual long getTestamentIndex() const
Definition: versekey.cpp:1704
SWKey * key
Definition: swmodule.h:124
void flushCache() const
Definition: zverse.cpp:339
virtual char getTestament() const
Definition: versekey.cpp:1498
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
void zVerse::zReadText ( char  testmt,
long  start,
unsigned short  size,
unsigned long  buffnum,
SWBuf buf 
) const
inherited

Definition at line 206 of file zverse.cpp.

206  {
207  SW_u32 ulCompOffset = 0; // compressed buffer start
208  SW_u32 ulCompSize = 0; // buffer size compressed
209  SW_u32 ulUnCompSize = 0; // buffer size uncompressed
210 
211  if (!testmt) {
212  testmt = ((idxfp[0]) ? 1:2);
213  }
214 
215  // assert we have and valid file descriptor
216  if (compfp[testmt-1]->getFd() < 1)
217  return;
218 
219  if (size &&
220  !(((long) ulBuffNum == cacheBufIdx) && (testmt == cacheTestament) && (cacheBuf))) {
221  //fprintf(stderr, "Got buffer number{%ld} versestart{%ld} versesize{%d}\n", ulBuffNum, ulVerseStart, usVerseSize);
222 
223  if (idxfp[testmt-1]->seek(ulBuffNum*12, SEEK_SET)!=(long) ulBuffNum*12)
224  {
225  fprintf(stderr, "Error seeking compressed file index\n");
226  return;
227  }
228  if (idxfp[testmt-1]->read(&ulCompOffset, 4)<4)
229  {
230  fprintf(stderr, "Error reading ulCompOffset\n");
231  return;
232  }
233  if (idxfp[testmt-1]->read(&ulCompSize, 4)<4)
234  {
235  fprintf(stderr, "Error reading ulCompSize\n");
236  return;
237  }
238  if (idxfp[testmt-1]->read(&ulUnCompSize, 4)<4)
239  {
240  fprintf(stderr, "Error reading ulUnCompSize\n");
241  return;
242  }
243 
244  ulCompOffset = swordtoarch32(ulCompOffset);
245  ulCompSize = swordtoarch32(ulCompSize);
246  ulUnCompSize = swordtoarch32(ulUnCompSize);
247 
248  if (textfp[testmt-1]->seek(ulCompOffset, SEEK_SET)!=(long)ulCompOffset)
249  {
250  fprintf(stderr, "Error: could not seek to right place in compressed text\n");
251  return;
252  }
253  SWBuf pcCompText;
254  pcCompText.setSize(ulCompSize+5);
255 
256  if (textfp[testmt-1]->read(pcCompText.getRawData(), ulCompSize)<(long)ulCompSize) {
257  fprintf(stderr, "Error reading compressed text\n");
258  return;
259  }
260  pcCompText.setSize(ulCompSize);
261  rawZFilter(pcCompText, 0); // 0 = decipher
262 
263  unsigned long bufSize = ulCompSize;
264  compressor->setCompressedBuf(&bufSize, pcCompText.getRawData());
265 
266  if (cacheBuf) {
267  flushCache();
268  free(cacheBuf);
269  }
270 
271  unsigned long len = 0;
272  compressor->setUncompressedBuf(0, &len);
273  cacheBuf = (char *)calloc(len + 1, 1);
274  memcpy(cacheBuf, compressor->getUncompressedBuf(), len);
275  cacheBufSize = (int)strlen(cacheBuf); // TODO: can we just use len?
276  cacheTestament = testmt;
277  cacheBufIdx = ulBuffNum;
278  }
279 
280  inBuf = "";
281  if ((size > 0) && cacheBuf && ((unsigned)start < cacheBufSize)) {
282  inBuf.setFillByte(0);
283  inBuf.setSize(size+1);
284  strncpy(inBuf.getRawData(), &(cacheBuf[start]), size);
285  inBuf.setSize(strlen(inBuf.c_str()));
286  }
287 }
SWCompress * compressor
Definition: zverse.h:38
FileDesc * textfp[2]
Definition: zverse.h:44
Definition: swbuf.h:47
char cacheTestament
Definition: zverse.h:52
char * cacheBuf
Definition: zverse.h:50
unsigned int cacheBufSize
Definition: zverse.h:51
virtual void setCompressedBuf(unsigned long *len, char *buf=0)
Definition: swcomprs.cpp:101
long cacheBufIdx
Definition: zverse.h:53
virtual char * getUncompressedBuf(unsigned long *len=0)
Definition: swcomprs.cpp:90
virtual void setUncompressedBuf(const char *buf=0, unsigned long *len=0)
Definition: swcomprs.cpp:75
char * getRawData()
Definition: swbuf.h:379
free(preg->fastmap)
virtual void rawZFilter(SWBuf &buf, char direction=0) const
Definition: zverse.h:70
#define swordtoarch32(x)
Definition: sysdata.h:94
#define SEEK_SET
Definition: zconf.h:244
int size
Definition: regex.c:5043
FileDesc * compfp[2]
Definition: zverse.h:45
unsigned int SW_u32
Definition: sysdata.h:41
FileDesc * idxfp[2]
Definition: zverse.h:43
void flushCache() const
Definition: zverse.cpp:339
void setSize(unsigned long len)
Definition: swbuf.h:255

Member Data Documentation

int zText::blockType
private

Definition at line 44 of file ztext.h.

char* zVerse::cacheBuf
mutableprotectedinherited

Definition at line 50 of file zverse.h.

long zVerse::cacheBufIdx
mutableprotectedinherited

Definition at line 53 of file zverse.h.

unsigned int zVerse::cacheBufSize
mutableprotectedinherited

Definition at line 51 of file zverse.h.

char zVerse::cacheTestament
mutableprotectedinherited

Definition at line 52 of file zverse.h.

FileDesc* zVerse::compfp[2]
protectedinherited

Definition at line 45 of file zverse.h.

ConfigEntMap* SWModule::config
protectedinherited

Definition at line 116 of file swmodule.h.

char SWModule::direction
protectedinherited

Definition at line 132 of file swmodule.h.

bool zVerse::dirtyCache
mutableprotectedinherited

Definition at line 54 of file zverse.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.

FileDesc* zVerse::idxfp[2]
protectedinherited

Definition at line 43 of file zverse.h.

SWORD_NAMESPACE_START int zVerse::instance = 0
staticprotectedinherited

Definition at line 41 of file zverse.h.

SWKey* SWModule::key
protectedinherited

the current key

Definition at line 124 of file swmodule.h.

VerseKey* zText::lastWriteKey
private

Definition at line 42 of file ztext.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.

char* zVerse::path
protectedinherited

Definition at line 46 of file zverse.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.

FileDesc* zVerse::textfp[2]
protectedinherited

Definition at line 44 of file zverse.h.

const char zVerse::uniqueIndexID = {'X', 'r', 'v', 'c', 'b'}
staticinherited

Definition at line 62 of file zverse.h.


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