diff options
Diffstat (limited to 'utilities')
-rw-r--r-- | utilities/imp2vs.cpp | 105 |
1 files changed, 67 insertions, 38 deletions
diff --git a/utilities/imp2vs.cpp b/utilities/imp2vs.cpp index 0764ff9..9a47301 100644 --- a/utilities/imp2vs.cpp +++ b/utilities/imp2vs.cpp @@ -64,19 +64,31 @@ int main(int argc, char **argv) { vkey->Headings(1); vkey->AutoNormalize(0); vkey->Persist(1); + mod->setKey(*vkey); while (readline(infile, linebuffer)) { if (!strncmp(linebuffer, "$$$", 3)) { if (strlen(keybuffer) && strlen(entbuffer)) { - std::cout << keybuffer << std::endl; + std::cout << "from file: " << keybuffer << std::endl; *vkey = keybuffer; - mod->setKey(*vkey); if (!vkey->Chapter()) { // bad hack: 0:0 is Book intro; (chapter):0 is Chapter intro; 0:2 is Module intro; 0:1 is Testament intro int backstep = vkey->Verse(); - vkey->Verse(0); - *mod -= backstep; + if (backstep) { + vkey->Verse(1); + vkey->Chapter(1); + switch (backstep) { + case 2: + vkey->Book(1); + vkey->Testament(0); + case 1: + vkey->Book(0); + vkey->Chapter(0); + } + vkey->Verse(0); + } + std::cout << "adding entry: " << *vkey << std::endl; mod->setEntry(entbuffer, strlen(entbuffer)); } else { @@ -84,39 +96,42 @@ int main(int argc, char **argv) { int i; bool havefirst = false; VerseKey firstverse; + firstverse.Headings(1); + firstverse.AutoNormalize(0); for (i = 0; i < listkey.Count(); i++) { VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(i)); if (element) { - mod->Key(element->LowerBound()); + *vkey = element->LowerBound(); VerseKey finalkey = element->UpperBound(); - std::cout << (const char*)mod->Key() << "-" << (const char*)finalkey << std::endl; + finalkey.Headings(1); + finalkey.AutoNormalize(0); if (!havefirst) { havefirst = true; - firstverse = mod->Key(); + firstverse = *vkey; + std::cout << "adding entry: " << *vkey << std::endl; mod->setEntry(entbuffer, strlen(entbuffer)); - std::cout << "f" << (const char*)firstverse << std::endl; - (mod->Key())++; + (*vkey)++; } - while (mod->Key() <= finalkey) { - std::cout << (const char*)mod->Key() << std::endl; - *(SWModule*)mod << &firstverse; - (mod->Key())++; + while (*vkey <= finalkey) { + std::cout << "linking entry: " << *vkey << " to " << firstverse << std::endl; + *mod << &firstverse; + (*vkey)++; } } else { if (havefirst) { - mod->Key(*listkey.GetElement(i)); - *(SWModule*)mod << &firstverse; - std::cout << (const char*)mod->Key() << std::endl; + *vkey = (*listkey.GetElement(i)); + std::cout << "linking entry: " << *vkey << " to " << firstverse << std::endl; + *mod << &firstverse; } else { - mod->Key(*listkey.GetElement(i)); + *vkey = (*listkey.GetElement(i)); havefirst = true; - firstverse = mod->Key(); + firstverse = *vkey; + std::cout << "adding entry: " << *vkey << std::endl; mod->setEntry(entbuffer, strlen(entbuffer)); - std::cout << "f" << (const char*)firstverse << std::endl; } } } @@ -133,15 +148,26 @@ int main(int argc, char **argv) { //handle final entry if (strlen(keybuffer) && strlen(entbuffer)) { - std::cout << keybuffer << std::endl; + std::cout << "from file: " << keybuffer << std::endl; *vkey = keybuffer; - mod->setKey(*vkey); if (!vkey->Chapter()) { // bad hack: 0:0 is Book intro; (chapter):0 is Chapter intro; 0:2 is Module intro; 0:1 is Testament intro - int backstep = vkey->Verse(); - vkey->Verse(0); - *mod -= backstep; + int backstep = vkey->Verse(); + if (backstep) { + vkey->Verse(1); + vkey->Chapter(1); + switch (backstep) { + case 2: + vkey->Book(1); + vkey->Testament(0); + case 1: + vkey->Book(0); + vkey->Chapter(0); + } + vkey->Verse(0); + } + std::cout << "adding entry: " << *vkey << std::endl; mod->setEntry(entbuffer, strlen(entbuffer)); } else { @@ -149,39 +175,42 @@ int main(int argc, char **argv) { int i; bool havefirst = false; VerseKey firstverse; + firstverse.Headings(1); + firstverse.AutoNormalize(0); for (i = 0; i < listkey.Count(); i++) { VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(i)); if (element) { - mod->Key(element->LowerBound()); + *vkey = element->LowerBound(); VerseKey finalkey = element->UpperBound(); - std::cout << (const char*)mod->Key() << "-" << (const char*)finalkey << std::endl; + finalkey.Headings(1); + finalkey.AutoNormalize(0); if (!havefirst) { havefirst = true; - firstverse = mod->Key(); + firstverse = *vkey; - ((SWModule*)mod)->setEntry(entbuffer, strlen(entbuffer)); - std::cout << "f" << (const char*)firstverse << std::endl; - (mod->Key())++; + std::cout << "adding entry: " << *vkey << std::endl; + mod->setEntry(entbuffer, strlen(entbuffer)); + (*vkey)++; } - while (mod->Key() <= finalkey) { - std::cout << (const char*)mod->Key() << std::endl; + while (*vkey <= finalkey) { + std::cout << "linking entry: " << *vkey << " to " << firstverse << std::endl; *(SWModule*)mod << &firstverse; - (mod->Key())++; + (*vkey)++; } } else { if (havefirst) { - mod->Key(*listkey.GetElement(i)); + *vkey = (*listkey.GetElement(i)); + std::cout << "linking entry: " << *vkey << " to " << firstverse << std::endl; *mod << &firstverse; - std::cout << (const char*)mod->Key() << std::endl; } else { - mod->Key(*listkey.GetElement(i)); + *vkey = (*listkey.GetElement(i)); havefirst = true; - firstverse = mod->Key(); + firstverse = *vkey; + std::cout << "adding entry: " << *vkey << std::endl; mod->setEntry(entbuffer, strlen(entbuffer)); - std::cout << "f" << (const char*)firstverse << std::endl; } } } |