[sword-svn] r411 - trunk/flashtools

scribe at crosswire.org scribe at crosswire.org
Tue Feb 5 06:19:50 MST 2013


Author: scribe
Date: 2013-02-05 06:19:50 -0700 (Tue, 05 Feb 2013)
New Revision: 411

Modified:
   trunk/flashtools/flash.cpp
Log:
updated to build against latest SWORD trunk


Modified: trunk/flashtools/flash.cpp
===================================================================
--- trunk/flashtools/flash.cpp	2013-01-04 13:45:54 UTC (rev 410)
+++ trunk/flashtools/flash.cpp	2013-02-05 13:19:50 UTC (rev 411)
@@ -188,6 +188,12 @@
      // output header
      cout
           << "FreqKJV|"
+          << "Greek|"
+          << "Strongs|"
+          << "TranslationInAV"
+          << "\n";
+/*
+          << "FreqKJV|"
           << "PointedHeb|"
           << "Meaning|"
           << "Strongs|"
@@ -205,6 +211,7 @@
           << "FullMeaning|"
           << "TranslationInAV"
           << "\n";
+*/
 
 	for (vector<Word>::const_iterator it = wordList.begin(); it != wordList.end(); it++) {
 		const Word &w = (*it);
@@ -213,9 +220,13 @@
 		if (gh == 'G' || gh == 'H') {
 			s << 1;
 		}
-          s = itoa(atoi(s.c_str())).c_str();
-//		cout << w->freq << "|" << escapedUTF8(w->utf8).c_str() << "|" << w->strong << "|" << prettyKJVFreq(w->kjvFreq).c_str() << "\n";
+		s = itoa(atoi(s.c_str())).c_str();
 		cout
+			<< w.freq << "|"
+			<< escapedUTF8(w.utf8).c_str() << "|"
+			<< w.strong << "|"
+			<< prettyKJVFreq(w.kjvFreq).c_str()
+/*
                << w.freq << "|"
 			<< hebrew[s]["UTF8"] << "|"
 			<< hebrew[s]["Meaning"] << "|"
@@ -233,6 +244,7 @@
 			<< hebrew[s]["Notes"] << "|"
 			<< hebrew[s]["FullMeaning"] << "|"
 			<< hebrew[s]["TranslationInAV"]
+*/
                << "\n";
 	}
 	std::cout << std::endl;
@@ -321,23 +333,22 @@
  *		(useful for generating complete OT or NT strongs word lists)
  *
  */
-vector<Word> processWords(const char *range, bool addAll = true) {
+vector<Word> processWords(const char *range, bool addAll = true, SWBuf modName = "KJV") {
 	SWMgr manager;
 	map<SWBuf, Word> wordList;
 	
-	SWModule *tmpBible = manager.getModule("KJV");
+	SWModule *tmpBible = manager.getModule(modName);
 	if (!tmpBible) {
 		cerr << "Unable to locate KJV module" << endl;
 		exit(1);
 	}
 	SWModule &bible = *tmpBible;
 
-	VerseKey parser;
-	ListKey r = parser.ParseVerseList(range, 0, true);
-	r.Persist(true);
-	bible.setKey(r);
-	for (bible = TOP; !bible.Error(); bible++) {
-		bible.RenderText();		// force an entry lookup to resolve key to something in the index
+	VerseKey *parser = (VerseKey *)bible.createKey();
+	ListKey r = parser->parseVerseList(range, 0, true);
+	for (r = TOP; !r.popError(); r++) {
+		bible.setKey(r);
+		bible.renderText();		// force an entry lookup to resolve key to something in the index
 
 		AttributeList &words = bible.getEntryAttributes()["Word"];
 		for (AttributeList::iterator word = words.begin(); word != words.end(); word++) {
@@ -389,13 +400,13 @@
 		// this assures we have an entry for every word, even if it is not
 		// present in the module
 		r = TOP;
-		if (VerseKey(r).Testament() == 1) {
+		if (VerseKey(r).getTestament() == 1) {
 			for (SectionMap::iterator it = hebrew.Sections.begin(); it != hebrew.Sections.end(); it++) {
 				wordList[(SWBuf)"H0"+it->first].utf8;  // just access to be sure created.  We'll add later.
 			}
 		}
 		r = BOTTOM;
-		if (VerseKey(r).Testament() == 2) {
+		if (VerseKey(r).getTestament() == 2) {
 			for (SectionMap::iterator it = greek.Sections.begin(); it != greek.Sections.end(); it++) {
 				wordList[(SWBuf)"G"+it->first].utf8;
 			}
@@ -428,6 +439,8 @@
 	}
 	sort(sorted.begin(), sorted.end(), compareFreq);
 
+	delete parser;
+
 	return sorted;
 }
 
@@ -443,6 +456,7 @@
 	fprintf(stderr, "  -d <m|k>\t\t definition to use (default k):\n");
 	fprintf(stderr, "\t\t\t\t m - short meaning; k - KJV collation\n");
 	fprintf(stderr, "  -r <\"range\">\t\t verse range\n");
+	fprintf(stderr, "  -m <\"module name\">\t\t module name to use (default \"KJV\")\n");
 	fprintf(stderr, "  -f <fontName>\t\t include special font name for lesson\n");
 	fprintf(stderr, "  -h\t\t\t display this help message\n\n");
 	exit(-1);
@@ -450,8 +464,9 @@
 
 int main(int argc, char **argv) {
 
+	const int REQUIRED = 0;
 	// Let's test our command line arguments
-	if (argc < 1) {
+	if (argc < REQUIRED+1) {   // this never happens since we don't have any required argument count
 		usage(*argv);
 	}
 
@@ -462,6 +477,7 @@
 	SWBuf range          = "Mat-Rev";
 	SWBuf fontName       = "";
 	SWBuf outDir         = ".";
+	SWBuf modName        = "KJV";
 	int count            = 25;
 
 	for (int i = 1; i < argc; i++) {
@@ -486,6 +502,10 @@
 			if (i+1 < argc) range = argv[++i];
 			else usage(*argv, "-r requires <\"range\">");
 		}
+		else if (!strcmp(argv[i], "-m")) {
+			if (i+1 < argc) modName = argv[++i];
+			else usage(*argv, "-m requires <\"module name\">");
+		}
 		else if (!strcmp(argv[i], "-f")) {
 			if (i+1 < argc) fontName = argv[++i];
 			else usage(*argv, "-f requires <\"fontName\">");
@@ -504,10 +524,10 @@
 	}
 
 	if (csv) {
-		outputCSV(processWords(range));
+		outputCSV(processWords(range, true, modName));
 	}
 	else {
-		outputFlash(processWords(range), outDir, (def == 'k'), count, (fontName.length()?fontName.c_str():0));
+		outputFlash(processWords(range, true, modName), outDir, (def == 'k'), count, (fontName.length()?fontName.c_str():0));
 	}
 
 	return 0;




More information about the sword-cvs mailing list