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

chrislit at crosswire.org chrislit at crosswire.org
Sat Aug 3 01:39:03 MST 2013


Author: chrislit
Date: 2013-08-03 01:39:02 -0700 (Sat, 03 Aug 2013)
New Revision: 2942

Modified:
   trunk/include/defs.h
   trunk/include/swmodule.h
   trunk/src/modules/swmodule.cpp
Log:
updated SWModule::getBibliography to take an unsigned char that indicates the format of the bibliographic data output-- currently only BibTeX (the default) is supported

Modified: trunk/include/defs.h
===================================================================
--- trunk/include/defs.h	2013-08-03 07:08:24 UTC (rev 2941)
+++ trunk/include/defs.h	2013-08-03 08:39:02 UTC (rev 2942)
@@ -157,6 +157,7 @@
 enum {DIRECTION_LTR = 0, DIRECTION_RTL, DIRECTION_BIDI};
 enum {FMT_UNKNOWN = 0, FMT_PLAIN, FMT_THML, FMT_GBF, FMT_HTML, FMT_HTMLHREF, FMT_RTF, FMT_OSIS, FMT_WEBIF, FMT_TEI, FMT_XHTML};
 enum {ENC_UNKNOWN = 0, ENC_LATIN1, ENC_UTF8, ENC_SCSU, ENC_UTF16, ENC_RTF, ENC_HTML};
+enum {BIB_BIBTEX = 0, /* possible future formats: BIB_MARCXML, BIB_MARC21, BIB_DCMI BIB_OSISHEADER, BIB_SBL_XHTML, BIB_MLA_XHTML, BIB_APA_XHTML, BIB_CHICAGO_XHTML */};
 
 SWORD_NAMESPACE_END
 #endif //SWORDDEFS_H

Modified: trunk/include/swmodule.h
===================================================================
--- trunk/include/swmodule.h	2013-08-03 07:08:24 UTC (rev 2941)
+++ trunk/include/swmodule.h	2013-08-03 08:39:02 UTC (rev 2942)
@@ -197,9 +197,12 @@
 	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.
+	 * Returns bibliographic data for a module in the requested format
+	 *
+	 * @param bibFormat format of the bibliographic data
+	 * @return bibliographic data in the requested format as a string (BibTeX by default)
 	 */
-	virtual const char *getBibliography() const;
+	virtual const char *getBibliography(unsigned char bibFormat = BIB_BIBTEX) const;
 
 	/**
 	 * @return The size of the text entry for the module's current key position.

Modified: trunk/src/modules/swmodule.cpp
===================================================================
--- trunk/src/modules/swmodule.cpp	2013-08-03 07:08:24 UTC (rev 2941)
+++ trunk/src/modules/swmodule.cpp	2013-08-03 08:39:02 UTC (rev 2942)
@@ -922,21 +922,22 @@
 }
 
 /******************************************************************************
- * 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
+ * SWModule::getBibliography	-Returns bibliographic data for a module in the
+ *								requested format
  *
- * RET: Bibliography entry in BibTex format
+ * ENT: bibFormat format of the bibliographic data
+ *
+ * RET: bibliographic data in the requested format as a string (BibTeX by default)
  */
 
-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::getBibliography(unsigned char bibFormat) const {
+	SWBuf s;
+	switch (bibFormat) {
+	case BIB_BIBTEX:
+		s = SWBuf("@Book {") + (SWBuf) modname + SWBuf(", Title = \"") + (SWBuf) moddesc + SWBuf("\", Publisher = \"CrossWire Bible Society\"}");
+		break;
 	}
+	return s;
 }
 
 const char *SWModule::getConfigEntry(const char *key) const {




More information about the sword-cvs mailing list