[sword-svn] r2940 - in trunk: include src/modules tests

chrislit at crosswire.org chrislit at crosswire.org
Fri Aug 2 23:53:35 MST 2013


Author: chrislit
Date: 2013-08-02 23:53:35 -0700 (Fri, 02 Aug 2013)
New Revision: 2940

Added:
   trunk/tests/bibliotest.cpp
Modified:
   trunk/include/swmodule.h
   trunk/src/modules/swmodule.cpp
   trunk/tests/Makefile.am
Log:
added refdoc's getBibliography method patch

Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2013-08-02 18:25:46 UTC (rev 2939)
+++ trunk/include/swmodule.h	2013-08-03 06:53:35 UTC (rev 2940)
@@ -197,6 +197,11 @@
 	virtual const char *getConfigEntry(const char *key) const;
 
 	/**
+	 * @return  This medhod will either return an existing BibTex entry from the module's conf file or construct and return a rudimentary one. The size of the text entry for the module's current key position.
+	 */
+	virtual const char *getBibliography() const;
+
+	/**
 	 * @return The size of the text entry for the module's current key position.
 	 */
 	virtual int getEntrySize() const { return entrySize; }

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2013-08-02 18:25:46 UTC (rev 2939)
+++ trunk/src/modules/swmodule.cpp	2013-08-03 06:53:35 UTC (rev 2940)
@@ -921,7 +921,24 @@
 	return retVal;
 }
 
+/******************************************************************************
+ * SWModule::getBibliography 	- checks whether module conf file has an key
+ * "Bibliography" and returns the relevant entry or creates a rudimentary BibTex
+ * entry from existing data
+ *
+ * RET: Bibliography entry in BibTex format
+ */
 
+const char *SWModule::getBibliography() const {
+	if (const char *c = getConfigEntry("Bibliography"))
+		return c;	
+	else {	 
+		SWBuf s = SWBuf("@Book {") + (SWBuf) modname + SWBuf(", Title = \"") + (SWBuf) moddesc + SWBuf("\", Publisher = \"CrossWire Bible Society\"}");
+		(*config)["Bibliography"] = s;
+		return getConfigEntry("Bibliography");
+	}
+}
+
 const char *SWModule::getConfigEntry(const char *key) const {
 	ConfigEntMap::iterator it = config->find(key);
 	return (it != config->end()) ? it->second.c_str() : 0;

Modified: trunk/tests/Makefile.am
===================================================================
--- trunk/tests/Makefile.am	2013-08-02 18:25:46 UTC (rev 2939)
+++ trunk/tests/Makefile.am	2013-08-03 06:53:35 UTC (rev 2940)
@@ -7,10 +7,12 @@
 
 SUBDIRS = cppunit
 
-noinst_PROGRAMS = utf8norm ciphertest keytest mgrtest parsekey versekeytest vtreekeytest versemgrtest listtest casttest \
-modtest compnone complzss localetest introtest indextest configtest keycast \
-romantest testblocks filtertest rawldidxtest lextest swaptest \
- swbuftest xmltest webiftest striptest osistest
+noinst_PROGRAMS = utf8norm ciphertest keytest mgrtest parsekey versekeytest \
+			vtreekeytest versemgrtest listtest casttest modtest \
+			compnone complzss localetest introtest indextest \
+			configtest keycast romantest testblocks filtertest \
+			rawldidxtest lextest swaptest swbuftest xmltest \
+			webiftest striptest osistest bibliotest
 
 if HAVE_ICU
 ICUPROG = icutest translittest tlitmgrtest
@@ -67,6 +69,7 @@
 striptest_SOURCES = striptest.cpp
 xmltest_SOURCES = xmltest.cpp
 osistest_SOURCES = osistest.cpp
+bibliotest_SOURCE = bibliotest.cpp
 
 EXTRA_DIST = 
 include bcppmake/Makefile.am

Added: trunk/tests/bibliotest.cpp
===================================================================
--- trunk/tests/bibliotest.cpp	                        (rev 0)
+++ trunk/tests/bibliotest.cpp	2013-08-03 06:53:35 UTC (rev 2940)
@@ -0,0 +1,43 @@
+/******************************************************************************
+ *
+ *  bibliotest.cpp -	
+ *
+ * $Id$
+ *
+ * Copyright 2013 CrossWire Bible Society (http://www.crosswire.org)
+ *	CrossWire Bible Society
+ *	P. O. Box 2528
+ *	Tempe, AZ  85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#include <swmgr.h>
+#include <swtext.h>
+#include <versekey.h>
+#include <iostream>
+#ifndef NO_SWORD_NAMESPACE
+using namespace sword;
+#endif
+
+int main(int argc, char **argv) {
+	SWMgr mymgr;
+	ModMap::iterator it;
+	if ( argc > 1 ) {
+		SWModule *module = mymgr.Modules[argv[1]];
+		std::cout << module->getBibliography() << "\n";
+		return 0;
+	}
+	else {
+		std::cout << "Usage: bibliography <ModuleName>"<< "\n";
+		return 1;
+	}
+}


Property changes on: trunk/tests/bibliotest.cpp
___________________________________________________________________
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native




More information about the sword-cvs mailing list