summaryrefslogtreecommitdiff
path: root/utilities/imp2vs.cpp
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-05-12 08:21:30 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-05-12 08:21:30 -0400
commit7a00574163029c0c2b649878c95d5acbd083564a (patch)
treec13cc5736025834df2874ed87ee8598070025ea6 /utilities/imp2vs.cpp
parentb745315323de9f27538edac9453205ca70e6186e (diff)
Imported Upstream version 1.7.2+dfsg
Diffstat (limited to 'utilities/imp2vs.cpp')
-rw-r--r--utilities/imp2vs.cpp40
1 files changed, 29 insertions, 11 deletions
diff --git a/utilities/imp2vs.cpp b/utilities/imp2vs.cpp
index 35c9382..cc26f0b 100644
--- a/utilities/imp2vs.cpp
+++ b/utilities/imp2vs.cpp
@@ -1,5 +1,10 @@
-/*
- * Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
+/******************************************************************************
+ *
+ * imp2vs.cpp - Utility to import IMP formatted VerseKey modules
+ *
+ * $Id: imp2vs.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ *
+ * Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
@@ -30,6 +35,7 @@
#include <ztext.h>
#include <lzsscomprs.h>
#include <zipcomprs.h>
+#include <localemgr.h>
#ifndef NO_SWORD_NAMESPACE
using namespace sword;
@@ -52,11 +58,12 @@ void usage(const char *progName, const char *error = 0) {
fprintf(stderr, "\t\t\t\t 2 - verse; 3 - chapter; 4 - book\n");
fprintf(stderr, " -v <v11n>\t\t specify a versification scheme to use (default is KJV)\n");
fprintf(stderr, "\t\t\t\t Note: The following are valid values for v11n:\n");
- VerseMgr *vmgr = VerseMgr::getSystemVerseMgr();
+ VersificationMgr *vmgr = VersificationMgr::getSystemVersificationMgr();
StringList av11n = vmgr->getVersificationSystems();
for (StringList::iterator loop = av11n.begin(); loop != av11n.end(); loop++) {
fprintf(stderr, "\t\t\t\t\t%s\n", (*loop).c_str());
}
+ fprintf(stderr, " -l <locale>\t\t specify a locale scheme to use (default is en)\n");
fprintf(stderr, "\n");
fprintf(stderr, "'imp' format is a simple standard for importing data into SWORD modules.\n"
"Required is a plain text file containing $$$key lines followed by content.\n\n"
@@ -84,6 +91,8 @@ int main(int argc, char **argv) {
const char *inFileName = argv[1];
SWBuf v11n = "KJV";
SWBuf outPath = "./";
+ SWBuf locale = "en";
+
bool fourByteSize = false;
bool append = false;
int iType = 4;
@@ -122,10 +131,14 @@ int main(int argc, char **argv) {
if (i+1 < argc) v11n = argv[++i];
else usage(progName, "-v requires <v11n>");
}
+ else if (!strcmp(argv[i], "-l")) {
+ if (i+1 < argc) locale = argv[++i];
+ else usage(progName, "-l requires <locale>");
+ }
else usage(progName, (((SWBuf)"Unknown argument: ")+ argv[i]).c_str());
}
// -----------------------------------------------------
- const VerseMgr::System *v = VerseMgr::getSystemVerseMgr()->getVersificationSystem(v11n);
+ const VersificationMgr::System *v = VersificationMgr::getSystemVersificationMgr()->getVersificationSystem(v11n);
if (!v) std::cout << "Warning: Versification " << v11n << " not found. Using KJV versification...\n";
if (compType == "ZIP") {
@@ -178,13 +191,18 @@ int main(int argc, char **argv) {
: (SWModule *)new RawText4(outPath, 0, 0, 0, ENC_UNKNOWN, DIRECTION_LTR, FMT_UNKNOWN, 0, v11n);
}
// -----------------------------------------------------
+
+ // setup locale manager
+
+ LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(locale);
// setup module key to allow full range of possible values, and then some
- VerseKey *vkey = (VerseKey *)module->CreateKey();
- vkey->Headings(1);
- vkey->AutoNormalize(0);
- vkey->Persist(1);
+
+ VerseKey *vkey = (VerseKey *)module->createKey();
+ vkey->setIntros(true);
+ vkey->setAutoNormalize(false);
+ vkey->setPersist(true);
module->setKey(*vkey);
// -----------------------------------------------------
@@ -228,12 +246,12 @@ void writeEntry(const SWBuf &key, const SWBuf &entry, SWModule *module)
if (key.size() && entry.size()) {
std::cout << "from file: " << key << std::endl;
VerseKey *vkey = (VerseKey *)module->getKey();
- VerseKey *linkMaster = (VerseKey *)module->CreateKey();
+ VerseKey *linkMaster = (VerseKey *)module->createKey();
- ListKey listKey = vkey->ParseVerseList(key.c_str(), "Gen1:1", true);
+ ListKey listKey = vkey->parseVerseList(key.c_str(), "Gen1:1", true);
bool first = true;
- for (listKey = TOP; !listKey.Error(); listKey++) {
+ for (listKey = TOP; !listKey.popError(); listKey++) {
*vkey = listKey;
if (first) {
*linkMaster = *vkey;