[sword-svn] r2452 - in trunk/bindings/corba: . omniorbcpp orbitcpp

scribe at crosswire.org scribe at crosswire.org
Tue Sep 15 08:31:09 MST 2009


Author: scribe
Date: 2009-09-15 08:31:09 -0700 (Tue, 15 Sep 2009)
New Revision: 2452

Modified:
   trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
   trunk/bindings/corba/orbitcpp/swordorb-impl.cpp
   trunk/bindings/corba/swordorb.idl
Log:
Added some comments and extended some special VerseKey handlers.


Modified: trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp	2009-09-03 02:32:54 UTC (rev 2451)
+++ trunk/bindings/corba/omniorbcpp/swordorb-impl.cpp	2009-09-15 15:31:09 UTC (rev 2452)
@@ -189,8 +189,21 @@
 	return retVal;
 }
 
-void swordorb_SWModule_i::setKeyText(const char* key){
-	delegate->KeyText(key);
+void swordorb_SWModule_i::setKeyText(const char* keyText) {
+	sword::SWKey *key = delegate->getKey();
+	sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
+	if (vkey && (*keyText=='+' ||*keyText=='-')) {
+		if (!stricmp(keyText+1, "book")) {
+			vkey->setBook(vkey->getBook() + ((*keyText=='-')?1:-1));
+			return;
+		}
+		else if (!stricmp(keyText+1, "chapter")) {
+			vkey->setChapter(vkey->getChapter() + ((*keyText=='-')?1:-1));
+			return;
+		}
+	}
+
+	delegate->KeyText(keyText);
 }
 
 char* swordorb_SWModule_i::getKeyText(){
@@ -199,7 +212,7 @@
 
 ::CORBA::Boolean swordorb_SWModule_i::hasKeyChildren(){
 	sword::SWKey *key = delegate->getKey();
-	bool retVal = "";
+	bool retVal = false;
 
 	TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
 	if (tkey) {
@@ -208,6 +221,7 @@
 	return retVal;
 }
 
+
 swordorb::StringList* swordorb_SWModule_i::getKeyChildren(){
 	sword::SWKey *key = delegate->getKey();
 	swordorb::StringList *retVal = new swordorb::StringList;
@@ -215,12 +229,12 @@
 
 	sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
 	if (vkey) {
-		retVal->length(6);
+		retVal->length(7);
 		SWBuf num;
 		num.appendFormatted("%d", vkey->Testament());
 		(*retVal)[0] = CORBA::string_dup(num.c_str());
 		num = "";
-		num.appendFormatted("%d", vkey->Book());
+		num.appendFormatted("%d", vkey->getBook());
 		(*retVal)[1] = CORBA::string_dup(num.c_str());
 		num = "";
 		num.appendFormatted("%d", vkey->Chapter());
@@ -234,6 +248,9 @@
 		num = "";
 		num.appendFormatted("%d", vkey->getVerseMax());
 		(*retVal)[5] = CORBA::string_dup(num.c_str());
+		num = "";
+		num.appendFormatted("%d", vkey->getBookName());
+		(*retVal)[6] = CORBA::string_dup(num.c_str());
 	}
 	else {
 		TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);

Modified: trunk/bindings/corba/orbitcpp/swordorb-impl.cpp
===================================================================
--- trunk/bindings/corba/orbitcpp/swordorb-impl.cpp	2009-09-03 02:32:54 UTC (rev 2451)
+++ trunk/bindings/corba/orbitcpp/swordorb-impl.cpp	2009-09-15 15:31:09 UTC (rev 2452)
@@ -288,7 +288,23 @@
 	return retVal;
 }
 
+void SWModule_impl::setKeyText(const char *key) throw(CORBA::SystemException) {
+	sword::SWKey *key = delegate->getKey();
+	sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
+	if (vkey && (*keyText=='+' ||*keyText=='-')) {
+		if (!stricmp(keyText+1, "book")) {
+			vkey->setBook(vkey->getBook() + ((*keyText=='-')?1:-1));
+			return;
+		}
+		else if (!stricmp(keyText+1, "chapter")) {
+			vkey->setChapter(vkey->getChapter() + ((*keyText=='-')?1:-1));
+			return;
+		}
+	}
 
+	delegate->KeyText(key);
+}
+
 StringList *SWModule_impl::getKeyChildren() throw(CORBA::SystemException) {
 	sword::SWKey *key = delegate->getKey();
 	StringList *retVal = new StringList;
@@ -296,7 +312,7 @@
 
 	sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
 	if (vkey) {
-		retVal->length(6);
+		retVal->length(7);
 		SWBuf num;
 		num.appendFormatted("%d", vkey->Testament());
 		(*retVal)[0] = CORBA::string_dup(num.c_str());
@@ -315,6 +331,9 @@
 		num = "";
 		num.appendFormatted("%d", vkey->getVerseMax());
 		(*retVal)[5] = CORBA::string_dup(num.c_str());
+		num = "";
+		num.appendFormatted("%d", vkey->getBookName());
+		(*retVal)[6] = CORBA::string_dup(num.c_str());
 	}
 	else {
 		TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
@@ -342,7 +361,7 @@
 
 CORBA::Boolean SWModule_impl::hasKeyChildren() throw(CORBA::SystemException) {
 	sword::SWKey *key = delegate->getKey();
-	bool retVal = "";
+	bool retVal = false;
 
 	TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
 	if (tkey) {

Modified: trunk/bindings/corba/swordorb.idl
===================================================================
--- trunk/bindings/corba/swordorb.idl	2009-09-03 02:32:54 UTC (rev 2451)
+++ trunk/bindings/corba/swordorb.idl	2009-09-15 15:31:09 UTC (rev 2452)
@@ -62,10 +62,19 @@
 	long          getEntrySize();
 	StringList    getEntryAttribute(in string level1, in string level2, in string level3, in boolean filtered);
 	StringList    parseKeyList(in string keyText);
+
+	// Special values handled for VerseKey modules: [+-][book|chapter]
+	//	(e.g.	"+chapter" will increment the VerseKey 1 chapter)
 	void          setKeyText(in string key);
+
 	string        getKeyText();
 	boolean       hasKeyChildren();
+
+	// This method returns child nodes for a genbook,
+	// but has special handling if called on a VerseKey module:
+	//  [0..6] [testament, book, chapter, verse, chapterMax, verseMax, bookName]
 	StringList    getKeyChildren();
+
 	string        getKeyParent();
 	string        getName();
 	string        getDescription();




More information about the sword-cvs mailing list