[sword-svn] r2194 - in trunk: . include src/keys src/modules tests utilities
scribe at www.crosswire.org
scribe at www.crosswire.org
Wed Sep 3 08:46:12 MST 2008
Author: scribe
Date: 2008-09-03 08:46:12 -0700 (Wed, 03 Sep 2008)
New Revision: 2194
Modified:
trunk/ChangeLog
trunk/include/listkey.h
trunk/include/swkey.h
trunk/include/versekey.h
trunk/src/keys/listkey.cpp
trunk/src/keys/swkey.cpp
trunk/src/keys/versekey.cpp
trunk/src/modules/swmodule.cpp
trunk/tests/parsekey.cpp
trunk/utilities/Makefile.am
trunk/utilities/vs2osisref.cpp
Log:
Reverted lucene syntax to deprecated signature as we still have older clucene on server
Added getOSISRefRangeText to SWKey. Not yetimplemented ideally or even correctly for all SWKey types.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/ChangeLog 2008-09-03 15:46:12 UTC (rev 2194)
@@ -1,5 +1,9 @@
API ChangeLog
+03-Sep-2008 Troy A. Griffitts <scribe at crosswire.org>
+ Added getOSISRefRangeText to SWKey. Not yetimplemented
+ ideally or even correctly for all SWKey types.
+
* Release 1.5.11 *
14-May-2008 Troy A. Griffitts <scribe at crosswire.org>
Modified: trunk/include/listkey.h
===================================================================
--- trunk/include/listkey.h 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/include/listkey.h 2008-09-03 15:46:12 UTC (rev 2194)
@@ -126,6 +126,7 @@
virtual bool isTraversable() const { return true; }
virtual long Index() const { return arraypos; }
virtual const char *getRangeText() const;
+ virtual const char *getOSISRefRangeText() const;
/**
* Returns the index for the new one given as as parameter.
Modified: trunk/include/swkey.h
===================================================================
--- trunk/include/swkey.h 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/include/swkey.h 2008-09-03 15:46:12 UTC (rev 2194)
@@ -141,6 +141,7 @@
virtual const char *getText() const;
virtual const char *getShortText() const { return getText(); }
virtual const char *getRangeText() const;
+ virtual const char *getOSISRefRangeText() const;
virtual bool isBoundSet() const { return boundSet; }
virtual void clearBound() const { boundSet = false; }
Modified: trunk/include/versekey.h
===================================================================
--- trunk/include/versekey.h 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/include/versekey.h 2008-09-03 15:46:12 UTC (rev 2194)
@@ -398,6 +398,7 @@
virtual ListKey ParseVerseList(const char *buf, const char *defaultKey = 0, bool expandRange = false);
virtual const char *getRangeText() const;
+ virtual const char *getOSISRefRangeText() const;
/** Compares another SWKey object
*
* @param ikey key to compare with this one
Modified: trunk/src/keys/listkey.cpp
===================================================================
--- trunk/src/keys/listkey.cpp 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/src/keys/listkey.cpp 2008-09-03 15:46:12 UTC (rev 2194)
@@ -281,6 +281,24 @@
/******************************************************************************
+ * ListKey::getOSISRefRangeText - returns parsable range text for this key
+ */
+
+const char *ListKey::getOSISRefRangeText() const {
+ char *buf = new char[(arraycnt + 1) * 255];
+ buf[0] = 0;
+ for (int i = 0; i < arraycnt; i++) {
+ strcat(buf, array[i]->getOSISRefRangeText());
+ if (i < arraycnt-1)
+ strcat(buf, ";");
+ }
+ stdstr(&rangeText, buf);
+ delete [] buf;
+ return rangeText;
+}
+
+
+/******************************************************************************
* ListKey::getText - returns text key if (const char *) cast is requested
*/
Modified: trunk/src/keys/swkey.cpp
===================================================================
--- trunk/src/keys/swkey.cpp 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/src/keys/swkey.cpp 2008-09-03 15:46:12 UTC (rev 2194)
@@ -157,6 +157,15 @@
/******************************************************************************
+ * SWKey::getOSISRefRangeText - returns parsable range text for this key
+ */
+
+const char *SWKey::getOSISRefRangeText() const {
+ return getRangeText();
+}
+
+
+/******************************************************************************
* SWKey::compare - Compares another VerseKey object
*
* ENT: ikey - key to compare with this one
Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/src/keys/versekey.cpp 2008-09-03 15:46:12 UTC (rev 2194)
@@ -1623,6 +1623,21 @@
}
+/******************************************************************************
+ * VerseKey::getOSISRefRangeText - returns parsable range text for this key
+ */
+
+const char *VerseKey::getOSISRefRangeText() const {
+ if (isBoundSet() && (LowerBound() != UpperBound())) {
+ char buf[1023];
+ sprintf(buf, "%s-%s", LowerBound().getOSISRef(), UpperBound().getOSISRef());
+ stdstr(&rangeText, buf);
+ }
+ else stdstr(&rangeText, getOSISRef());
+ return rangeText;
+}
+
+
const char *VerseKey::convertToOSIS(const char *inRef, const SWKey *lastKnownKey) {
static SWBuf outRef;
Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/src/modules/swmodule.cpp 2008-09-03 15:46:12 UTC (rev 2194)
@@ -1036,8 +1036,10 @@
}
lucene_utf8towcs(wcharBuffer, keyText, MAX_CONV_SIZE); //keyText must be utf8
- doc->add( *(new Field("key", wcharBuffer, Field::STORE_YES | Field::INDEX_TOKENIZED)));
+// doc->add( *(new Field("key", wcharBuffer, Field::STORE_YES | Field::INDEX_TOKENIZED)));
+ doc->add( *Field::Text(_T("key"), wcharBuffer ) );
+
if (includeKeyInSearch) {
c = keyText;
c += " ";
Modified: trunk/tests/parsekey.cpp
===================================================================
--- trunk/tests/parsekey.cpp 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/tests/parsekey.cpp 2008-09-03 15:46:12 UTC (rev 2194)
@@ -1,6 +1,4 @@
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
#include <versekey.h>
#include <localemgr.h>
@@ -10,7 +8,7 @@
int main(int argc, char **argv) {
if ((argc < 2) || (argc > 4)) {
- fprintf(stderr, "usage: %s <\"string to parse\"> [locale name] [test-in-set-verse]\n", *argv);
+ fprintf(stderr, "usage: %s <\"string to parse\"> [locale_name] [test-in-set-verse]\n", *argv);
exit(-1);
}
Modified: trunk/utilities/Makefile.am
===================================================================
--- trunk/utilities/Makefile.am 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/utilities/Makefile.am 2008-09-03 15:46:12 UTC (rev 2194)
@@ -6,7 +6,7 @@
stepdump step2vpl gbfidx modwrite addvs emptyvss \
addgb genbookutil treeidxutil
-bin_PROGRAMS = mod2imp mod2osis osis2mod tei2mod vs2osisref mod2vpl \
+bin_PROGRAMS = mod2imp mod2osis osis2mod tei2mod vs2osisref vs2osisreftxt mod2vpl \
mkfastmod vpl2mod imp2vs installmgr xml2gbs imp2gbs
#if INSTALLMGR
@@ -58,6 +58,7 @@
osis2mod_SOURCES = osis2mod.cpp
tei2mod_SOURCES = tei2mod.cpp
vs2osisref_SOURCES = vs2osisref.cpp
+vs2osisreftxt_SOURCES = vs2osisreftxt.cpp
genbookutil_SOURCES = genbookutil.cpp
treeidxutil_SOURCES = treeidxutil.cpp
Modified: trunk/utilities/vs2osisref.cpp
===================================================================
--- trunk/utilities/vs2osisref.cpp 2008-09-03 13:22:12 UTC (rev 2193)
+++ trunk/utilities/vs2osisref.cpp 2008-09-03 15:46:12 UTC (rev 2194)
@@ -1,25 +1,5 @@
-// Compression on variable granularity
-#include <fcntl.h>
#include <iostream>
-#include <fstream>
-
-#ifndef __GNUC__
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <ztext.h>
-#include <zld.h>
-#include <zcom.h>
-#include <swmgr.h>
-#include <lzsscomprs.h>
-#include <zipcomprs.h>
#include <versekey.h>
-#include <thmlosis.h>
-#include <stdio.h>
-#include <markupfiltmgr.h>
-#include <algorithm>
#ifndef NO_SWORD_NAMESPACE
using namespace sword;
@@ -32,25 +12,14 @@
int main(int argc, char **argv)
{
if (argc < 2) {
- cerr << argv[0] << " - a tool to convert verse references from English to OSIS\n";
- cerr << "usage: "<< argv[0] << " <verse ref> [verse context]\n";
+ cerr << argv[0] << " - parse verse reference to OSISRef markup\n";
+ cerr << "usage: "<< argv[0] << " <verse_ref> [verse_context]\n";
cerr << "\n\n";
exit(-1);
}
- VerseKey verseKey;
- int i = strlen(argv[1]) + 1;
- char * verseString = new char[i];
- strcpy (verseString, argv[1]);
- verseString[i - 1] = 0;
-
- if (argc > 2) {
- verseKey = argv[2];
- }
- else {
- verseKey = "Gen 1:1";
- }
+ VerseKey verseKey = (argc > 2) ? argv[2] : "Gen 1:1";
- std::cout << VerseKey::convertToOSIS(verseString, &verseKey) << "\n";
+ std::cout << VerseKey::convertToOSIS(argv[1], &verseKey) << "\n";
return 0;
}
More information about the sword-cvs
mailing list