[sword-svn] r2893 - in trunk: bindings bindings/swig include src/keys src/modules src/modules/comments src/modules/genbook src/modules/texts tests utilities utilities/diatheke
scribe at crosswire.org
scribe at crosswire.org
Mon Jul 15 20:07:02 MST 2013
Author: scribe
Date: 2013-07-15 20:07:02 -0700 (Mon, 15 Jul 2013)
New Revision: 2893
Added:
trunk/bindings/swig/multimapwdef.i
Modified:
trunk/bindings/flatapi.cpp
trunk/bindings/swig/listkey.i
trunk/bindings/swig/sword.i
trunk/include/listkey.h
trunk/include/swkey.h
trunk/src/keys/listkey.cpp
trunk/src/keys/versekey.cpp
trunk/src/modules/comments/swcom.cpp
trunk/src/modules/genbook/swgenbook.cpp
trunk/src/modules/swmodule.cpp
trunk/src/modules/texts/swtext.cpp
trunk/tests/listtest.cpp
trunk/utilities/addvs.cpp
trunk/utilities/diatheke/corediatheke.cpp
trunk/utilities/osis2mod.cpp
Log:
normalized ListKey method names and deprecated old names
added multimapwdef.i to ignore unsupported operator []
Modified: trunk/bindings/flatapi.cpp
===================================================================
--- trunk/bindings/flatapi.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/bindings/flatapi.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -178,7 +178,7 @@
if (!module)
return -1;
- results.ClearList();
+ results.clear();
results = module->search(searchString, type, params, scope, 0, percent, (void *) &percentUserData);
return (SWHANDLE)&results;
@@ -326,7 +326,7 @@
static ListKey verses;
versekey.setText(key);
- verses.ClearList();
+ verses.clear();
verses = versekey.parseVerseList(list, versekey);
return (SWHANDLE)&verses;
}
Modified: trunk/bindings/swig/listkey.i
===================================================================
--- trunk/bindings/swig/listkey.i 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/bindings/swig/listkey.i 2013-07-16 03:07:02 UTC (rev 2893)
@@ -3,6 +3,11 @@
%}
%ignore sword::ListKey::operator<<;
+%ignore sword::ListKey::ClearList;
+%ignore sword::ListKey::Count;
+%ignore sword::ListKey::Remove;
+%ignore sword::ListKey::SetToElement;
+%ignore sword::ListKey::GetElement;
%include "listkey.h"
@@ -18,4 +23,4 @@
static sword::ListKey *castTo(sword::SWKey *o) {
return dynamic_cast<sword::ListKey*>(o);
}
-}
\ No newline at end of file
+}
Added: trunk/bindings/swig/multimapwdef.i
===================================================================
--- trunk/bindings/swig/multimapwdef.i (rev 0)
+++ trunk/bindings/swig/multimapwdef.i 2013-07-16 03:07:02 UTC (rev 2893)
@@ -0,0 +1,11 @@
+%{
+#include "multimapwdef.h"
+%}
+
+%ignore sword::multimapwithdefault::operator [];
+
+%include "multimapwdef.h"
+
+%extend sword::multimapwithdefault {
+}
+
Modified: trunk/bindings/swig/sword.i
===================================================================
--- trunk/bindings/swig/sword.i 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/bindings/swig/sword.i 2013-07-16 03:07:02 UTC (rev 2893)
@@ -25,6 +25,9 @@
%include "defs.i"
%include "swbuf.i"
+%include "multimapwdef.i"
+
+
/* Now include all the STL templates we are going to use */
%include "templates.i"
Modified: trunk/include/listkey.h
===================================================================
--- trunk/include/listkey.h 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/include/listkey.h 2013-07-16 03:07:02 UTC (rev 2893)
@@ -64,26 +64,36 @@
/** Clears out elements of list
*/
virtual void clear();
+ // deprecated, use clear(), instead
+ SWDEPRECATED virtual void ClearList() { clear(); }
- /** deprecated, use clear(), instead
- */
- virtual void ClearList() { clear(); }
- /** Returns number of elements in list
- * @return number of elements in list
+ /** Returns number of key elements in list
+ * @return number of key elements in list
*/
- virtual int Count();
+ virtual int getCount() const;
+ //deprecated, use getCount
+ SWDEPRECATED virtual int Count() { return getCount(); }
/** Removes current element from list
*/
- virtual void Remove();
+ virtual void remove();
+ // deprecated use remove
+ SWDEPRECATED virtual void Remove() { remove(); }
+
- /** Sets key to element number
+ /** Sets container to subkey element number and repositions that subkey to either top or bottom
*
- * @param ielement element number to set to
+ * @param ielement - element number to set to
+ * @param pos - set the subkey element to position (TOP) or BOTTOM
* @return error status
+ * deprecated use setToElement
*/
- virtual char SetToElement(int ielement, SW_POSITION = TOP);
+ virtual char setToElement(int ielement, SW_POSITION = TOP);
+ // deprecated use setToElement
+ SWDEPRECATED virtual char SetToElement(int ielement, SW_POSITION pos = TOP) { return setToElement(ielement, pos); }
+
+
/** Gets a key element number
*
@@ -91,9 +101,10 @@
* @return Key or null on error
*/
virtual SWKey *getElement(int pos = -1);
+ virtual const SWKey *getElement(int pos = -1) const;
// deprecated, use above function
- virtual SWKey *GetElement(int pos = -1) { return getElement(pos); }
+ SWDEPRECATED virtual SWKey *GetElement(int pos = -1) { return getElement(pos); }
/** Adds an element to the list
* @param ikey the element to add
@@ -133,7 +144,7 @@
* Returns the index for the new one given as as parameter.
* The first parameter is the new index.
*/
- virtual void setIndex(long index) { SetToElement(index); }
+ virtual void setIndex(long index) { setToElement(index); }
virtual const char *getText() const;
virtual void setText(const char *ikey);
virtual void sort();
Modified: trunk/include/swkey.h
===================================================================
--- trunk/include/swkey.h 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/include/swkey.h 2013-07-16 03:07:02 UTC (rev 2893)
@@ -105,7 +105,7 @@
mutable char *rangeText;
mutable bool boundSet;
bool persist;
- char error;
+ mutable char error;
char *localeName;
SWLocale *getPrivateLocale() const;
Modified: trunk/src/keys/listkey.cpp
===================================================================
--- trunk/src/keys/listkey.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/src/keys/listkey.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -42,7 +42,7 @@
ListKey::ListKey(const char *ikey): SWKey(ikey) {
arraymax = 0;
- ClearList();
+ clear();
init();
}
@@ -76,7 +76,7 @@
ListKey::~ListKey()
{
- ClearList();
+ clear();
}
@@ -108,7 +108,7 @@
*/
void ListKey::copyFrom(const ListKey &ikey) {
- ClearList();
+ clear();
arraymax = ikey.arraymax;
arraypos = ikey.arraypos;
@@ -117,7 +117,7 @@
for (int i = 0; i < arraycnt; i++)
array[i] = ikey.array[i]->clone();
- SetToElement(0);
+ setToElement(0);
}
@@ -131,7 +131,7 @@
arraymax = arraycnt + 32;
}
array[arraycnt-1] = ikey.clone();
- SetToElement(arraycnt-1);
+ setToElement(arraycnt-1);
}
@@ -147,10 +147,10 @@
void ListKey::setPosition(SW_POSITION p) {
switch (p) {
case 1: // GCC won't compile P_TOP
- SetToElement(0, p);
+ setToElement(0, p);
break;
case 2: // GCC won't compile P_BOTTOM
- SetToElement(arraycnt-1, p);
+ setToElement(arraycnt-1, p);
break;
}
}
@@ -171,7 +171,7 @@
if (array[arraypos]->isBoundSet())
(*(array[arraypos]))++;
if ((array[arraypos]->popError()) || (!array[arraypos]->isBoundSet())) {
- SetToElement(arraypos+1);
+ setToElement(arraypos+1);
}
else SWKey::setText((const char *)(*array[arraypos]));
}
@@ -195,7 +195,7 @@
if (array[arraypos]->isBoundSet())
(*(array[arraypos]))--;
if ((array[arraypos]->popError()) || (!array[arraypos]->isBoundSet())) {
- SetToElement(arraypos-1, BOTTOM);
+ setToElement(arraypos-1, BOTTOM);
}
else SWKey::setText((const char *)(*array[arraypos]));
}
@@ -208,7 +208,7 @@
* ListKey::Count - Returns number of elements in list
*/
-int ListKey::Count() {
+int ListKey::getCount() const {
return arraycnt;
}
@@ -217,11 +217,12 @@
* ListKey::SetToElement - Sets key to element number
*
* ENT: ielement - element number to set to
+ * pos - set the subkey element to position (TOP) or BOTTOM
*
* RET: error status
*/
-char ListKey::SetToElement(int ielement, SW_POSITION pos) {
+char ListKey::setToElement(int ielement, SW_POSITION pos) {
arraypos = ielement;
if (arraypos >= arraycnt) {
arraypos = (arraycnt>0)?arraycnt - 1:0;
@@ -256,7 +257,7 @@
* RET: Key or null on error
*/
-SWKey *ListKey::getElement(int pos) {
+const SWKey *ListKey::getElement(int pos) const {
if (pos < 0)
pos = arraypos;
@@ -265,20 +266,25 @@
return (error) ? 0:array[pos];
}
+
+SWKey *ListKey::getElement(int pos) {
+ return const_cast<SWKey *>(getElement(pos));
+}
+
/******************************************************************************
* ListKey::Remove - Removes current element from list
*/
-void ListKey::Remove() {
+void ListKey::remove() {
if ((arraypos > -1) && (arraypos < arraycnt)) {
delete array[arraypos];
if (arraypos < arraycnt - 1)
memmove(&array[arraypos], &array[arraypos+1], (arraycnt - arraypos - 1) * sizeof(SWKey *));
arraycnt--;
- SetToElement((arraypos)?arraypos-1:0);
+ setToElement((arraypos)?arraypos-1:0);
}
}
Modified: trunk/src/keys/versekey.cpp
===================================================================
--- trunk/src/keys/versekey.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/src/keys/versekey.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -221,13 +221,13 @@
{
init(v11n);
ListKey tmpListKey = parseVerseList(min);
- if (tmpListKey.Count()) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement(0));
+ if (tmpListKey.getCount()) {
+ VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement(0));
setLowerBound(*newElement);
}
tmpListKey = parseVerseList(max, min, true);
- if (tmpListKey.Count()) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement(0));
+ if (tmpListKey.getCount()) {
+ VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement(0));
setUpperBound((newElement->isBoundSet())?newElement->getUpperBound():*newElement);
}
setPosition(TOP);
@@ -294,7 +294,7 @@
if (keytext) {
// pass our own copy of keytext as keytext memory may be freshed during parse
ListKey tmpListKey = parseVerseList(SWBuf(keytext).c_str());
- if (tmpListKey.Count()) {
+ if (tmpListKey.getCount()) {
this->positionFrom(*tmpListKey.getElement(0));
error = this->error;
} else error = 1;
@@ -732,8 +732,8 @@
lastKey->setLowerBound(*curKey);
lastKey->setPosition(TOP);
tmpListKey << *lastKey;
- ((VerseKey *)tmpListKey.GetElement())->setAutoNormalize(isAutoNormalize());
- tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+ ((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
else {
if (!dash) { // if last separator was not a dash just add
@@ -746,8 +746,8 @@
lastKey->setUpperBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- ((VerseKey *)tmpListKey.GetElement())->setAutoNormalize(isAutoNormalize());
- tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+ ((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
else {
bool f = false;
@@ -761,12 +761,12 @@
lastKey->setUpperBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- ((VerseKey *)tmpListKey.GetElement())->setAutoNormalize(isAutoNormalize());
- tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+ ((VerseKey *)tmpListKey.getElement())->setAutoNormalize(isAutoNormalize());
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
}
else if (expandRange) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement());
+ VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement());
if (newElement) {
if (partial > 1)
*curKey = MAXCHAPTER;
@@ -775,7 +775,7 @@
newElement->setUpperBound(*curKey);
*lastKey = *curKey;
*newElement = TOP;
- tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
}
}
@@ -1006,7 +1006,7 @@
lastKey->setLowerBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
else {
if (!dash) { // if last separator was not a dash just add
@@ -1019,7 +1019,7 @@
lastKey->setUpperBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
else {
bool f = false;
@@ -1033,11 +1033,11 @@
lastKey->setUpperBound(*curKey);
*lastKey = TOP;
tmpListKey << *lastKey;
- tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
}
else if (expandRange) {
- VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.GetElement());
+ VerseKey *newElement = SWDYNAMIC_CAST(VerseKey, tmpListKey.getElement());
if (newElement) {
if (partial > 1)
*curKey = MAXCHAPTER;
@@ -1045,7 +1045,7 @@
*curKey = MAXVERSE;
newElement->setUpperBound(*curKey);
*newElement = TOP;
- tmpListKey.GetElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
+ tmpListKey.getElement()->userData = (__u64)(bufStart+(buf-iBuf.c_str()));
}
}
}
@@ -1816,8 +1816,8 @@
VerseKey defLanguage;
ListKey verses = defLanguage.parseVerseList(inRef, (*lastKnownKey), true);
const char *startFrag = inRef;
- for (int i = 0; i < verses.Count(); i++) {
- SWKey *element = verses.GetElement(i);
+ for (int i = 0; i < verses.getCount(); i++) {
+ SWKey *element = verses.getElement(i);
// VerseKey *element = SWDYNAMIC_CAST(VerseKey, verses.GetElement(i));
SWBuf buf;
// TODO: This code really needs to not use fixed size arrays
Modified: trunk/src/modules/comments/swcom.cpp
===================================================================
--- trunk/src/modules/comments/swcom.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/src/modules/comments/swcom.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -104,7 +104,7 @@
SWCATCH ( ... ) { }
if (lkTest) {
SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->getElement());
}
SWCATCH ( ... ) { }
}
Modified: trunk/src/modules/genbook/swgenbook.cpp
===================================================================
--- trunk/src/modules/genbook/swgenbook.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/src/modules/genbook/swgenbook.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -66,11 +66,11 @@
SWCATCH ( ... ) { }
if (lkTest) {
SWTRY {
- key = SWDYNAMIC_CAST(TreeKey, lkTest->GetElement());
+ key = SWDYNAMIC_CAST(TreeKey, lkTest->getElement());
if (!key) {
VerseTreeKey *tkey = 0;
SWTRY {
- tkey = SWDYNAMIC_CAST(VerseTreeKey, lkTest->GetElement());
+ tkey = SWDYNAMIC_CAST(VerseTreeKey, lkTest->getElement());
}
SWCATCH ( ... ) {}
if (tkey) key = tkey->getTreeKey();
Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/src/modules/swmodule.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -367,7 +367,7 @@
ListKey &SWModule::search(const char *istr, int searchType, int flags, SWKey *scope, bool *justCheckIfSupported, void (*percent)(char, void *), void *percentUserData) {
- listKey.ClearList();
+ listKey.clear();
SWBuf term = istr;
bool includeComponents = false; // for entryAttrib e.g., /Lemma.1/
@@ -473,7 +473,7 @@
}
}
listKey << *resultKey;
- listKey.GetElement()->userData = (__u64)((__u32)(h->score(i)*100));
+ listKey.getElement()->userData = (__u64)((__u32)(h->score(i)*100));
}
(*percent)(98, percentUserData);
}
Modified: trunk/src/modules/texts/swtext.cpp
===================================================================
--- trunk/src/modules/texts/swtext.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/src/modules/texts/swtext.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -109,7 +109,7 @@
SWCATCH ( ... ) { }
if (lkTest) {
SWTRY {
- key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement());
+ key = SWDYNAMIC_CAST(VerseKey, lkTest->getElement());
}
SWCATCH ( ... ) { }
}
Modified: trunk/tests/listtest.cpp
===================================================================
--- trunk/tests/listtest.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/tests/listtest.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -99,9 +99,9 @@
for (lk2 = TOP; !lk2.popError(); lk2++)
cout << (const char *) lk2 << "\n";
- lk.ClearList();
+ lk.clear();
lk << "john 3:16";
- cout << "\nCount should be 1: " << lk.Count();
+ cout << "\nCount should be 1: " << lk.getCount();
lk = vk.parseVerseList("mat;mark;luke", vk, true);
lk = (VerseKey)"mark 3:16";
Modified: trunk/utilities/addvs.cpp
===================================================================
--- trunk/utilities/addvs.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/utilities/addvs.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -100,8 +100,8 @@
int i;
bool havefirst = false;
VerseKey firstverse;
- for (i = 0; i < listkey.Count(); i++) {
- VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(i));
+ for (i = 0; i < listkey.getCount(); i++) {
+ VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.getElement(i));
if (element) {
mod->setKey(element->getLowerBound());
VerseKey finalkey = element->getUpperBound();
Modified: trunk/utilities/diatheke/corediatheke.cpp
===================================================================
--- trunk/utilities/diatheke/corediatheke.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/utilities/diatheke/corediatheke.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -283,7 +283,7 @@
*output << " -- ";
char *temp = new char[10];
- sprintf(temp, "%u", listkey.Count());
+ sprintf(temp, "%u", listkey.getCount());
*output << temp;
delete [] temp;
@@ -374,8 +374,8 @@
*output << "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
}
- for (i = 0; i < listkey.Count() && maxverses; i++) {
- VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(i));
+ for (i = 0; i < listkey.getCount() && maxverses; i++) {
+ VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.getElement(i));
if (element && element->isBoundSet()) {
target->setKey(element->getLowerBound());
*parser = element->getUpperBound();
@@ -418,7 +418,7 @@
}
}
else {
- target->setKey(*listkey.GetElement(i));
+ target->setKey(*listkey.getElement(i));
*output << (char*)target->getKeyText();
if (font && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
*output << ": <font face=\"";
Modified: trunk/utilities/osis2mod.cpp
===================================================================
--- trunk/utilities/osis2mod.cpp 2013-07-13 23:45:09 UTC (rev 2892)
+++ trunk/utilities/osis2mod.cpp 2013-07-16 03:07:02 UTC (rev 2893)
@@ -793,7 +793,7 @@
// Use the last verse seen (i.e. the currentVerse) as the basis for recovering from bad parsing.
// This should never happen if the references are valid OSIS references
ListKey verseKeys = currentVerse.parseVerseList(keyVal, currentVerse, true);
- int memberKeyCount = verseKeys.Count();
+ int memberKeyCount = verseKeys.getCount();
if (memberKeyCount) {
currentVerse = verseKeys.getElement(0);
// See if this osisID or annotateRef refers to more than one verse.
More information about the sword-cvs
mailing list