[sword-cvs] sword/bindings/corba/orbitcpp swordorb-impl.cpp,1.7,1.8 swordorb-impl.hpp,1.6,1.7 testclient.cpp,1.6,1.7

sword@www.crosswire.org sword@www.crosswire.org
Fri, 22 Aug 2003 08:14:05 -0700


Update of /usr/local/cvsroot/sword/bindings/corba/orbitcpp
In directory www:/tmp/cvs-serv13752/bindings/corba/orbitcpp

Modified Files:
	swordorb-impl.cpp swordorb-impl.hpp testclient.cpp 
Log Message:



Index: swordorb-impl.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/bindings/corba/orbitcpp/swordorb-impl.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- swordorb-impl.cpp	18 Aug 2003 17:32:53 -0000	1.7
+++ swordorb-impl.cpp	22 Aug 2003 15:14:02 -0000	1.8
@@ -2,6 +2,8 @@
 #include <iostream>
 #include <swmgr.h>
 #include <versekey.h>
+#include <treekeyidx.h>
+#include <swbuf.h>
 
 /*
 char* swordorb::SWModule_impl::helloWorld(const char* greeting) throw(CORBA::SystemException) {
@@ -10,96 +12,150 @@
 }
 */
 
+using sword::VerseKey;
+using sword::SWBuf;
+using sword::TreeKeyIdx;
+
 namespace swordorb {
 
 sword::RawText NULLMod("/dev/null", SWNULL, SWNULL);
 
-	ModInfoList *SWMgr_impl::getModInfoList() throw(CORBA::SystemException) {
+ModInfoList *SWMgr_impl::getModInfoList() throw(CORBA::SystemException) {
 
-		ModInfoList *milist = new ModInfoList;
-		sword::SWModule *module = 0;
-		int size = 0;
-		for (sword::ModMap::iterator it = delegate->Modules.begin(); it != delegate->Modules.end(); it++) {
-			if ((!(it->second->getConfigEntry("CipherKey"))) || (*(it->second->getConfigEntry("CipherKey"))))
-				size++;
-		}
-		milist->length(size);
-		int i = 0;
-		for (sword::ModMap::iterator it = delegate->Modules.begin(); it != delegate->Modules.end(); it++) {
-			module = it->second;
-			if ((!(module->getConfigEntry("CipherKey"))) || (*(module->getConfigEntry("CipherKey")))) {
-				(*milist)[i].name = CORBA::string_dup(module->Name());
-				(*milist)[i].type = CORBA::string_dup(module->Type());
-				(*milist)[i++].lang = CORBA::string_dup(module->Lang());
-			}
+	ModInfoList *milist = new ModInfoList;
+	sword::SWModule *module = 0;
+	int size = 0;
+	for (sword::ModMap::iterator it = delegate->Modules.begin(); it != delegate->Modules.end(); it++) {
+		if ((!(it->second->getConfigEntry("CipherKey"))) || (*(it->second->getConfigEntry("CipherKey"))))
+			size++;
+	}
+	milist->length(size);
+	int i = 0;
+	for (sword::ModMap::iterator it = delegate->Modules.begin(); it != delegate->Modules.end(); it++) {
+		module = it->second;
+		if ((!(module->getConfigEntry("CipherKey"))) || (*(module->getConfigEntry("CipherKey")))) {
+			SWBuf type = module->Type();
+			SWBuf cat = module->getConfigEntry("Category");
+			if (cat.length() > 0)
+				type = cat;
+			(*milist)[i].name = CORBA::string_dup(module->Name());
+			(*milist)[i].description = CORBA::string_dup(module->Description());
+			(*milist)[i].category = CORBA::string_dup(type.c_str());
+			(*milist)[i++].language = CORBA::string_dup(module->Lang());
 		}
-		return milist;
 	}
+	return milist;
+}
 
 
-	SWModule_ptr SWMgr_impl::getModuleByName(const char *name) throw(CORBA::SystemException) {
-		SWModuleMap::iterator it;
-		SWModule_ptr retVal;
-		sword::SWModule *mod = delegate->Modules[name];
+
+SWModule_ptr SWMgr_impl::getModuleByName(const char *name) throw(CORBA::SystemException) {
+	SWModuleMap::iterator it;
+	SWModule_ptr retVal;
+	sword::SWModule *mod = delegate->Modules[name];
+	it = moduleImpls.find((mod)?name:SWNULL);
+	if (it == moduleImpls.end()) {
+		moduleImpls[(mod)?name:SWNULL] = new SWModule_impl((mod)?mod:&NULLMod);
 		it = moduleImpls.find((mod)?name:SWNULL);
-		if (it == moduleImpls.end()) {
-			moduleImpls[(mod)?name:SWNULL] = new SWModule_impl((mod)?mod:&NULLMod);
-			it = moduleImpls.find((mod)?name:SWNULL);
-		}
-		if (it != moduleImpls.end()) {
-			retVal = it->second->_this();
-		}
-		return ::swordorb::SWModule::_duplicate(retVal);
 	}
+	if (it != moduleImpls.end()) {
+		retVal = it->second->_this();
+	}
+	return ::swordorb::SWModule::_duplicate(retVal);
+}
 
 
-	StringList *SWMgr_impl::getGlobalOptions() throw(CORBA::SystemException) {
-	}
+StringList *SWMgr_impl::getGlobalOptions() throw(CORBA::SystemException) {
+}
 
 
-	StringList *SWMgr_impl::getGlobalOptionValues(const char *option) throw(CORBA::SystemException) {
-	}
+StringList *SWMgr_impl::getGlobalOptionValues(const char *option) throw(CORBA::SystemException) {
+}
 
 
-	void SWMgr_impl::terminate() throw(CORBA::SystemException) {
-		exit(0);
-	}
+void SWMgr_impl::terminate() throw(CORBA::SystemException) {
+	exit(0);
+}
 
 
-	CORBA::Boolean SWMgr_impl::testConnection() throw(CORBA::SystemException) {
-		return true;
-	}
+CORBA::Boolean SWMgr_impl::testConnection() throw(CORBA::SystemException) {
+	return true;
+}
 
 
-	StringList *SWModule_impl::search(const char *istr, SearchType searchType, CORBA::Long flags, const char *scope) throw(CORBA::SystemException) {
-		int stype = 2;
-		sword::ListKey lscope;
-		sword::VerseKey parser;
-		if (searchType == REGEX) stype = 0;
-		if (searchType == PHRASE) stype = -1;
-		if (searchType == MULTIWORD) stype = -2;
-		sword::ListKey result;
+char *SWModule_impl::getCategory() throw(CORBA::SystemException) {
+	SWBuf type = delegate->Type();
+	SWBuf cat = delegate->getConfigEntry("Category");
+	if (cat.length() > 0)
+		type = cat;
+	return CORBA::string_dup((char *)type.c_str());
+}
 
-		if ((scope) && (strlen(scope)) > 0) {
-			lscope = parser.ParseVerseList(scope, parser, true);
-			result = delegate->Search(istr, stype, flags, &lscope);
-		}
-		else	result = delegate->Search(istr, stype, flags);
 
-		StringList *retVal = new StringList;
-		int count = 0;
-		for (result = sword::TOP; !result.Error(); result++) count++;
-		retVal->length(count);
-		int i = 0;
-		for (result = sword::TOP; !result.Error(); result++)
-			(*retVal)[i++] = CORBA::string_dup((const char *)result);
+StringList *SWModule_impl::search(const char *istr, SearchType searchType, CORBA::Long flags, const char *scope) throw(CORBA::SystemException) {
+	int stype = 2;
+	sword::ListKey lscope;
+	sword::VerseKey parser;
+	if (searchType == REGEX) stype = 0;
+	if (searchType == PHRASE) stype = -1;
+	if (searchType == MULTIWORD) stype = -2;
+	sword::ListKey result;
 
-		return retVal;
+	if ((scope) && (strlen(scope)) > 0) {
+		lscope = parser.ParseVerseList(scope, parser, true);
+		result = delegate->Search(istr, stype, flags, &lscope);
 	}
-		
+	else	result = delegate->Search(istr, stype, flags);
+
+	StringList *retVal = new StringList;
+	int count = 0;
+	for (result = sword::TOP; !result.Error(); result++) count++;
+	retVal->length(count);
+	int i = 0;
+	for (result = sword::TOP; !result.Error(); result++)
+		(*retVal)[i++] = CORBA::string_dup((const char *)result);
 
+	return retVal;
+}
 
 
+StringList *SWModule_impl::getKeyChildren() throw(CORBA::SystemException) {
+	sword::SWKey *key = delegate->getKey();
+	StringList *retVal = new StringList;
+	int count = 0;
 
+	sword::VerseKey *vkey = SWDYNAMIC_CAST(VerseKey, key);
+	if (vkey) {
+		retVal->length(2);
+		SWBuf num;
+		num.appendFormatted("%d", vkey->books[vkey->Testament()-1][vkey->Book()-1].chapmax);
+		(*retVal)[0] = CORBA::string_dup(num.c_str());
+		num = "";
+		num.appendFormatted("%d", vkey->books[vkey->Testament()-1][vkey->Book()-1].versemax[vkey->Chapter()-1]);
+		(*retVal)[1] = CORBA::string_dup(num.c_str());
+	}
+	else {
+		TreeKeyIdx *tkey = SWDYNAMIC_CAST(TreeKeyIdx, key);
+		if (tkey) {
+			if (tkey->firstChild()) {
+				do {
+					count++;
+				}
+				while (tkey->nextSibling());
+				tkey->parent();
+			}
+			retVal->length(count);
+			count = 0;
+			if (tkey->firstChild()) {
+				do {
+					(*retVal)[count++] = CORBA::string_dup(tkey->getLocalName());
+				}
+				while (tkey->nextSibling());
+				tkey->parent();
+			}
+		}
+	}
+	return retVal;
+}
 
 }

Index: swordorb-impl.hpp
===================================================================
RCS file: /usr/local/cvsroot/sword/bindings/corba/orbitcpp/swordorb-impl.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- swordorb-impl.hpp	18 Aug 2003 17:32:53 -0000	1.6
+++ swordorb-impl.hpp	22 Aug 2003 15:14:03 -0000	1.7
@@ -25,9 +25,10 @@
 	CORBA::Long getEntrySize() throw(CORBA::SystemException) { return delegate->getEntrySize(); }
 	void   setKeyText(const char *key) throw(CORBA::SystemException) { delegate->KeyText(key); }
 	char *getKeyText() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->KeyText()); }
+	StringList *getKeyChildren() throw(CORBA::SystemException);
 	char *getName() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->Name()); }
 	char *getDescription() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->Description()); }
-	char *getType() throw(CORBA::SystemException) { return CORBA::string_dup((char *)delegate->Type()); }
+	char *getCategory() throw(CORBA::SystemException);
 	void   previous() throw(CORBA::SystemException) { delegate->decrement(); }
 	void   next() throw(CORBA::SystemException) { delegate->increment(); }
 	void   begin() throw(CORBA::SystemException) { delegate->setPosition(sword::TOP); }

Index: testclient.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/bindings/corba/orbitcpp/testclient.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- testclient.cpp	18 Aug 2003 17:32:53 -0000	1.6
+++ testclient.cpp	22 Aug 2003 15:14:03 -0000	1.7
@@ -33,7 +33,7 @@
 		modInfoList = mgr->getModInfoList();
 		std::cout << "sequence length: " << modInfoList->length() << "\n";
 		for (int i = 0; i < modInfoList->length(); i++) {
-			std::cout << (*modInfoList)[i].name << ": " << (*modInfoList)[i].type << ": " << (*modInfoList)[i].lang << "\n";
+			std::cout << (*modInfoList)[i].name << ": " << (*modInfoList)[i].category << ": " << (*modInfoList)[i].language << "\n";
 			module = mgr->getModuleByName((*modInfoList)[i].name);
 			module->setKeyText("jas1:19");
 			std::cout << module->getRenderText() << "\n";