[sword-svn] r2867 - trunk/utilities/diatheke

chrislit at crosswire.org chrislit at crosswire.org
Mon Jul 8 15:14:23 MST 2013


Author: chrislit
Date: 2013-07-08 15:14:23 -0700 (Mon, 08 Jul 2013)
New Revision: 2867

Modified:
   trunk/utilities/diatheke/corediatheke.cpp
   trunk/utilities/diatheke/corediatheke.h
   trunk/utilities/diatheke/diatheke.cpp
Log:
added Enum, Xlit, & Glosses filter options to command-line
simplified preprocessor defines
simplified filter toggles
added framework of HTMLHREF & XHTML output


Modified: trunk/utilities/diatheke/corediatheke.cpp
===================================================================
--- trunk/utilities/diatheke/corediatheke.cpp	2013-07-08 14:07:03 UTC (rev 2866)
+++ trunk/utilities/diatheke/corediatheke.cpp	2013-07-08 22:14:23 UTC (rev 2867)
@@ -203,63 +203,33 @@
 	else if (!strcmp(target->getType(), "Generic Books"))
 		querytype = QT_LD;
 
-	if (optionfilters & OP_FOOTNOTES)
-		manager.setGlobalOption("Footnotes","On");
-	else
-		manager.setGlobalOption("Footnotes","Off");
-	if (optionfilters & OP_HEADINGS)
-		manager.setGlobalOption("Headings","On");
-	else
-		manager.setGlobalOption("Headings","Off");
-	if (optionfilters & OP_STRONGS)
-		manager.setGlobalOption("Strong's Numbers","On");
-	else
-		manager.setGlobalOption("Strong's Numbers","Off");
-	if (optionfilters & OP_MORPH)
-		manager.setGlobalOption("Morphological Tags","On");
-	else
-		manager.setGlobalOption("Morphological Tags","Off");
-	if (optionfilters & OP_CANTILLATION)
-		manager.setGlobalOption("Hebrew Cantillation","On");
-	else
-		manager.setGlobalOption("Hebrew Cantillation","Off");
-	if (optionfilters & OP_HEBREWPOINTS)
-		manager.setGlobalOption("Hebrew Vowel Points","On");
-	else
-		manager.setGlobalOption("Hebrew Vowel Points","Off");
-	if (optionfilters & OP_GREEKACCENTS)
-		manager.setGlobalOption("Greek Accents","On");
-	else
-		manager.setGlobalOption("Greek Accents","Off");
-	if (optionfilters & OP_LEMMAS)
-		manager.setGlobalOption("Lemmas","On");
-	else
-		manager.setGlobalOption("Lemmas","Off");
-	if (optionfilters & OP_SCRIPREF)
-		manager.setGlobalOption("Cross-references","On");
-	else
-		manager.setGlobalOption("Cross-references","Off");
-	if (optionfilters & OP_RED)
-		manager.setGlobalOption("Words of Christ in Red","On");
-	else
-		manager.setGlobalOption("Words of Christ in Red","Off");
+	manager.setGlobalOption("Footnotes", (optionfilters & OP_FOOTNOTES) ? "On": "Off");
+	manager.setGlobalOption("Headings", (optionfilters & OP_HEADINGS) ? "On": "Off");
+	manager.setGlobalOption("Strong's Numbers", (optionfilters & OP_STRONGS) ? "On": "Off");
+	manager.setGlobalOption("Morphological Tags", (optionfilters & OP_MORPH) ? "On": "Off");
+	manager.setGlobalOption("Hebrew Cantillation", (optionfilters & OP_CANTILLATION) ? "On": "Off");
+	manager.setGlobalOption("Hebrew Vowel Points", (optionfilters & OP_HEBREWPOINTS) ? "On": "Off");
+	manager.setGlobalOption("Greek Accents", (optionfilters & OP_GREEKACCENTS) ? "On": "Off");
+	manager.setGlobalOption("Lemmas", (optionfilters & OP_LEMMAS) ? "On": "Off");
+	manager.setGlobalOption("Cross-references", (optionfilters & OP_SCRIPREF) ? "On": "Off");
+	manager.setGlobalOption("Words of Christ in Red", (optionfilters & OP_REDLETTERWORDS) ? "On": "Off");
+	manager.setGlobalOption("Arabic Vowel Points", (optionfilters & OP_ARABICPOINTS) ? "On": "Off");
+	manager.setGlobalOption("Glosses", (optionfilters & OP_GLOSSES) ? "On": "Off");
+	manager.setGlobalOption("Transliterated Forms", (optionfilters & OP_XLIT) ? "On": "Off");
+	manager.setGlobalOption("Enumerations", (optionfilters & OP_ENUM) ? "On": "Off");
+
+	manager.setGlobalOption("Transliteration", (optionfilters & OP_TRANSLITERATOR && script) ? script : "Off");
+	
 	if (optionfilters & OP_VARIANTS && variants) {
 			if (variants == -1)
-                manager.setGlobalOption("Variants", "All Readings");
+				manager.setGlobalOption("Variants", "All Readings");
 			else if (variants == 1)
 				manager.setGlobalOption("Variants", "Secondary Readings");
 	}
 	else
 		manager.setGlobalOption("Variants", "Primary Readings");
+        
 
-	if (optionfilters & OP_TRANSLITERATOR && script)
-                manager.setGlobalOption("Transliteration", script);
-	else
-		manager.setGlobalOption("Transliteration", "Off");
-	if (optionfilters & OP_ARABICPOINTS)
-		manager.setGlobalOption("Arabic Vowel Points","On");
-	else
-		manager.setGlobalOption("Arabic Vowel Points","Off");
 
 	if (querytype == QT_SEARCH) {
 
@@ -343,13 +313,13 @@
 				*output << "Times New Roman";
 			*output << ";}}";
 		}
-		else if (outputformat == FMT_HTML) {
+		else if (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML) {
 			*output << "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
 		}
 
 		if (strlen(text)) {
 			*output << (char*)target->getKeyText();
-			if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
+			if (font && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
 				*output << ": <font face=\"";
 				*output << font;
 				*output << "\">";
@@ -361,7 +331,7 @@
 				*output << ": ";
 			}
 			*output << text;
-			if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
+			if (font && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
 				*output << "</font>";
 			}
 			else if (outputformat == FMT_RTF) {
@@ -400,7 +370,7 @@
 				*output << "Times New Roman";
 			*output << ";}{\\f7\\froman\\fcharset2\\fprq2 Symbol;}}";
 		}
-		else if (outputformat == FMT_HTML) {
+		else if (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML) {
 			*output << "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
 		}
 
@@ -411,7 +381,7 @@
 				*parser = element->getUpperBound();
 				while (maxverses && *target->getKey() <= *parser) {
 					*output << (char*)target->getKeyText();
-					if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
+					if (font && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
 						*output << ": <font face=\"";
 						*output << font;
 						*output << "\">";
@@ -423,14 +393,14 @@
 						*output << ": ";
 					}
 					*output << (const char*)*target;
-					if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
+					if (font && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
 						*output << "</font>";
 					}
 					else if (outputformat == FMT_RTF) {
 						*output << "}";
 					}
 
-					if (inputformat != FMT_THML && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI))
+					if (inputformat != FMT_THML && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI))
 						*output << "<br />";
 					else if (outputformat == FMT_OSIS)
 						*output << "<milestone type=\"line\"/>";
@@ -450,7 +420,7 @@
 			else {
 				target->setKey(*listkey.GetElement(i));
 				*output << (char*)target->getKeyText();
-				if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
+				if (font && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
 					*output << ": <font face=\"";
 					*output << font;
 					*output << "\">";
@@ -462,14 +432,14 @@
 					*output << ": ";
 				}
 				*output << (const char*)*target;
-				if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
+				if (font && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
 					*output << "</font>";
 				}
 				else if (outputformat == FMT_RTF) {
 					*output << "}";
 				}
 
-				if (inputformat != FMT_THML && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI))
+				if (inputformat != FMT_THML && (outputformat == FMT_HTML || outputformat == FMT_HTMLHREF || outputformat == FMT_XHTML || outputformat == FMT_THML || outputformat == FMT_CGI))
 					*output << "<br />";
 				else if (outputformat == FMT_OSIS)
 					*output << "<milestone type=\"line\"/>";

Modified: trunk/utilities/diatheke/corediatheke.h
===================================================================
--- trunk/utilities/diatheke/corediatheke.h	2013-07-08 14:07:03 UTC (rev 2866)
+++ trunk/utilities/diatheke/corediatheke.h	2013-07-08 22:14:23 UTC (rev 2867)
@@ -40,23 +40,27 @@
 
 #define OP_NONE 0
 #define OP_STRONGS 1
-#define OP_FOOTNOTES 2
-#define OP_HEADINGS 4
-#define OP_MORPH 8
-#define OP_CANTILLATION 16
-#define OP_HEBREWPOINTS 32
-#define OP_GREEKACCENTS 64
-#define OP_TRANSLITERATOR 128
-#define OP_LEMMAS 256
-#define OP_SCRIPREF 512
-#define OP_ARSHAPE 1024
-#define OP_BIDI 2048
-#define OP_VARIANTS 4096
-#define OP_RED 8192
-#define OP_ARABICPOINTS 16384
+#define OP_FOOTNOTES (1<<1)
+#define OP_HEADINGS (1<<2)
+#define OP_MORPH (1<<3)
+#define OP_CANTILLATION (1<<4)
+#define OP_HEBREWPOINTS (1<<5)
+#define OP_GREEKACCENTS (1<<6)
+#define OP_TRANSLITERATOR (1<<7)
+#define OP_LEMMAS (1<<8)
+#define OP_SCRIPREF (1<<9)
+#define OP_ARSHAPE (1<<10)
+#define OP_BIDI (1<<11)
+#define OP_VARIANTS (1<<12)
+#define OP_REDLETTERWORDS (1<<13)
+#define OP_ARABICPOINTS (1<<14)
+#define OP_GLOSSES (1<<15)
+#define OP_XLIT (1<<16)
+#define OP_ENUM (1<<17)
+
 #define ST_NONE 0
-#define ST_REGEX 1 //0
-#define ST_PHRASE 2  // -1
+#define ST_REGEX 1     //  0
+#define ST_PHRASE 2    // -1
 #define ST_MULTIWORD 3 // -2
 
 using namespace std;

Modified: trunk/utilities/diatheke/diatheke.cpp
===================================================================
--- trunk/utilities/diatheke/diatheke.cpp	2013-07-08 14:07:03 UTC (rev 2866)
+++ trunk/utilities/diatheke/diatheke.cpp	2013-07-08 22:14:23 UTC (rev 2867)
@@ -4,7 +4,7 @@
  *
  * $Id$
  *
- * Copyright 2000-2013 CrossWire Bible Society (http://www.crosswire.org)
+ * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
  *	CrossWire Bible Society
  *	P. O. Box 2528
  *	Tempe, AZ  85280-2528
@@ -38,14 +38,14 @@
 void printsyntax() { 
 	//if we got this far without exiting, something went wrong, so print syntax
 	fprintf (stderr, "Diatheke command-line SWORD frontend Version 4.5\n");
-	fprintf (stderr, "Copyright 1999-2009 by the CrossWire Bible Society\n");
+	fprintf (stderr, "Copyright 1999-2013 by the CrossWire Bible Society\n");
 	fprintf (stderr, "http://www.crosswire.org/sword/diatheke/\n");
-	fprintf (stderr, "usage: \n  ");
- 	fprintf (stderr, "diatheke <-b module_name> [-s search_type] [-r search_range]\n");
-	fprintf (stderr, "[-o option_filters] [-m maximum_verses] [-f output_format]\n");
-	fprintf (stderr, "[-e output_encoding] [-t script] [-v variant#(-1=all|0|1)]\n");
-	fprintf (stderr, "[-l locale] <-k query_key>\n");
 	fprintf (stderr, "\n");
+	fprintf (stderr, "usage:  diatheke <-b module_name> [-s search_type] [-r search_range]\n");
+	fprintf (stderr, "    [-o option_filters] [-m maximum_verses] [-f output_format]\n");
+	fprintf (stderr, "    [-e output_encoding] [-v variant#(-1=all|0|1)]\n");
+	fprintf (stderr, "    [-l locale] <-k query_key>\n");
+	fprintf (stderr, "\n");
 	fprintf (stderr, "If <book> is \"system\" you may use these system keys: \"modulelist\",\n");
 	fprintf (stderr, "\"modulelistnames\", and \"localelist\".");
 	fprintf (stderr, "\n");
@@ -54,15 +54,18 @@
 	fprintf (stderr, "  f (Footnotes), m (Morphology), h (Section Headings),\n");
 	fprintf (stderr, "  c (Cantillation), v (Hebrew Vowels), a (Greek Accents), p (Arabic Vowels)\n");
 	fprintf (stderr, "  l (Lemmas), s (Scripture Crossrefs), r (Arabic Shaping),\n");
-	fprintf (stderr, "  b (Bi-Directional Reordering), x (Red Words of Christ)\n");
+	fprintf (stderr, "  b (Bi-Directional Reordering), w (Red Words of Christ),\n");
+	fprintf (stderr, "  g (Glosses/Ruby), e (Word Enumerations),\n");
+	fprintf (stderr, "  x (Encoded Transliterations), t (Algorithmic Transliterations via ICU)\n");
 
 	fprintf (stderr, "Maximum verses may be any integer value\n");
-	fprintf (stderr, "Valid output_format values are: GBF, ThML, RTF, HTML, HTMLHREF, XHTML, OSIS, CGI, and plain (def)\n");
+	fprintf (stderr, "Valid output_format values are: GBF, ThML, RTF, HTML, HTMLHREF, XHTML, OSIS,\n");
+	fprintf (stderr, "  CGI, and plain (def)\n");
 	fprintf (stderr, "Valid output_encoding values are: Latin1, UTF8 (def), UTF16, HTML, and RTF\n");
 	fprintf (stderr, "Valid locale values depend on installed locales. en is default.\n");
 	fprintf (stderr, "The query_key must be the last argument because all following\n");
-	fprintf (stderr, "  arguments are added to the key.\n\n");
-
+	fprintf (stderr, "  arguments are added to the key.\n");
+	fprintf (stderr, "\n");
 	fprintf (stderr, "Example usage:\n");
 	fprintf (stderr, "  diatheke -b KJV -o fmnx -k Jn 3:16\n");
 	fprintf (stderr, "  diatheke -b WHNU -t Latin -o mn -k Mt 24\n");
@@ -74,9 +77,10 @@
 	int maxverses = -1;
 	unsigned char outputformat = FMT_PLAIN, searchtype = ST_NONE, outputencoding = ENC_UTF8;
 	unsigned long optionfilters = OP_NONE;
- 	char *text = 0, *locale = 0, *ref = 0, *script = 0, *range = 0;
+ 	char *text = 0, *locale = 0, *ref = 0, *range = 0;
+	char script[] = "Latin"; // for the moment, only this target script is supported
 	signed short variants = 0;
-	
+
 	char runquery = 0; // used to check that we have enough arguments to perform a legal query
 	// (a querytype & text = 1 and a ref = 2)
 	
@@ -147,10 +151,18 @@
 					optionfilters |= OP_ARSHAPE;
 				if (strchr(argv[i+1], 'b'))
 					optionfilters |= OP_BIDI;
-				if (strchr(argv[i+1], 'x'))
-					optionfilters |= OP_RED;
+				if (strchr(argv[i+1], 'w'))
+					optionfilters |= OP_REDLETTERWORDS;
 				if (strchr(argv[i+1], 'p'))
 					optionfilters |= OP_ARABICPOINTS;
+				if (strchr(argv[i+1], 'g'))
+					optionfilters |= OP_GLOSSES;
+				if (strchr(argv[i+1], 'x'))
+					optionfilters |= OP_XLIT;
+				if (strchr(argv[i+1], 'e'))
+					optionfilters |= OP_ENUM;
+				if (strchr(argv[i+1], 't'))
+					optionfilters |= OP_TRANSLITERATOR;
 				i++;
 			}
 		}
@@ -236,6 +248,7 @@
 				i++;
 			}
 		}
+		/*
 		else if (!::stricmp("-t", argv[i])) {
 			if (i+1 <= argc) {
 				script = argv[i+1];
@@ -243,6 +256,7 @@
 				i++;
 			}
 		}
+		*/
 	}
 	
 	




More information about the sword-cvs mailing list