The SWORD Project
1.9.0.svnversion
|
#include <ctype.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <stdlib.h>
#include <stack>
#include <vector>
#include <iostream>
#include <fstream>
#include <utilstr.h>
#include <swmgr.h>
#include <rawtext.h>
#include <rawtext4.h>
#include <swbuf.h>
#include <utilxml.h>
#include <listkey.h>
#include <versekey.h>
#include <swversion.h>
#include <ztext.h>
#include <ztext4.h>
#include <lzsscomprs.h>
#include <zipcomprs.h>
#include <bz2comprs.h>
#include <xzcomprs.h>
#include <cipherfil.h>
#include <utf8utf16.h>
#include <utf16utf8.h>
Go to the source code of this file.
Functions | |
int | detectUTF8 (const char *txt) |
bool | handleToken (SWBuf &text, XMLTag token) |
bool | isOSISAbbrev (const char *buf) |
bool | isValidRef (const char *buf, const char *caller) |
void | linkToEntry (VerseKey &linkKey, VerseKey &dest) |
int | main (int argc, char **argv) |
void | makeValidRef (VerseKey &key) |
void | prepareSWText (const char *osisID, SWBuf &text) |
void | prepareSWVerseKey (SWBuf &buf) |
void | processOSIS (istream &infile) |
XMLTag | transformBSP (XMLTag t) |
void | usage (const char *app, const char *error=0, const bool verboseHelp=false) |
void | writeEntry (SWBuf &text, bool force=false) |
void | writeLinks () |
Variables | |
char | activeOsisID [255] |
SWBuf | activeVerseText |
int | converted = 0 |
ListKey | currentKeyIDs = ListKey() |
char | currentOsisID [255] |
VerseKey | currentVerse |
int | debug = 0 |
const int | DEBUG_INTERVERSE = 16 |
const int | DEBUG_OTHER = 512 |
const int | DEBUG_QUOTE = 4 |
const int | DEBUG_REF = 128 |
const int | DEBUG_REV11N = 64 |
const int | DEBUG_STACK = 256 |
const int | DEBUG_TITLE = 8 |
const int | DEBUG_VERSE = 2 |
const int | DEBUG_WRITE = 1 |
const int | DEBUG_XFORM = 32 |
const int | EXIT_BAD_ARG = 1 |
const int | EXIT_BAD_NESTING = 5 |
const int | EXIT_NO_CREATE = 3 |
const int | EXIT_NO_READ = 4 |
const int | EXIT_NO_WRITE = 2 |
static bool | inCanonicalOSISBook = true |
std::vector< ListKey > | linkedVerses |
SWText * | module = 0 |
static bool | normalize = true |
int | normalized = 0 |
SWFilter * | outputDecoder = NULL |
SWFilter * | outputEncoder = NULL |
SWBuf | v11n = "KJV" |
int detectUTF8 | ( | const char * | txt | ) |
Determine whether the string contains a valid unicode sequence. The following table give the pattern of a valid UTF-8 character. Unicode Range 1st 2nd 3rd 4th U-00000000 - U-0000007F 0nnnnnnn U-00000080 - U-000007FF 110nnnnn 10nnnnnn U-00000800 - U-0000FFFF 1110nnnn 10nnnnnn 10nnnnnn U-00010000 - U-0010FFFF 11110nnn 10nnnnnn 10nnnnnn 10nnnnnn
Note:
param txt the text to check return 1 if all high order characters form a valid unicode sequence -1 if there are no high order characters. Note: this is also a valid unicode sequence 0 if there are high order characters that do not form a valid unicode sequence author DM Smith
Definition at line 152 of file osis2mod.cpp.
Definition at line 617 of file osis2mod.cpp.
bool isOSISAbbrev | ( | const char * | buf | ) |
Definition at line 120 of file osis2mod.cpp.
Determine whether a verse as given is valid for the versification. This is done by comparing the before and after of normalization.
Definition at line 372 of file osis2mod.cpp.
Definition at line 595 of file osis2mod.cpp.
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 1847 of file osis2mod.cpp.
void makeValidRef | ( | VerseKey & | key | ) |
This routine is used to ensure that all the text in the input is saved to the module. Assumption: The input orders all the verses for a chapter in numerical order. Thus, any verses that are not in the chosen versification (v11n) follow those that are.
The prior implementation of this adjusted the verse to the last one that is in the chosen v11n. If it the chapter were extra, then it is appended to the last verse of the last chapter in the chosen v11n for that book. If it is just extra verses for a chapter, then it is appended to the last verse of the chapter.
The problem with this is when a OSIS verse refers to more than one verse, e.g. osisID="Gen.1.29 Gen.1.30 Gen.1.31" (Gen.1.31 is the last verse of the chapter in the chosen v11n) and then it is followed by Gen.1.32.
This routine assumes that linking is postponed to the end so that in the example Gen.1.30-31 are not linked but rather empty. This routine will then find the last verse in the computed chapter that has content.
Alternative, we could have done linking as we went, but this routine would have needed to find the first entry in the link set and elsewhere in the code when appending to a verse, it would need to be checked for adjacent links and those would have needed to be adjusted.
param key the key that may need to be adjusted
Definition at line 433 of file osis2mod.cpp.
Definition at line 200 of file osis2mod.cpp.
void prepareSWVerseKey | ( | SWBuf & | buf | ) |
Definition at line 253 of file osis2mod.cpp.
void processOSIS | ( | istream & | infile | ) |
Definition at line 1428 of file osis2mod.cpp.
Support normalizations necessary for a SWORD module. OSIS allows for document structure (Book, Section, Paragraph or BSP) to overlap Bible versification (Book, Chapter, Verse). Most SWORD applications need to display verses in isolation or in HTML table cells, requiring each stored entry (i.e. verses) to be well-formed xml. This routine normalizes container elements which could cross verse boundaries into milestones. For most of these OSIS elements, there is a milestone form. However, p is not milestoneable. For this reason, p is transformed into div elements with type x-p. param t the tag to transform return the transformed tag or the original one
Definition at line 1215 of file osis2mod.cpp.
Definition at line 1352 of file osis2mod.cpp.
Definition at line 483 of file osis2mod.cpp.
void writeLinks | ( | ) |
Write out all links in the module. Waiting is necessary because writeEntry might ultimately append text to a verse moving it's offset in the data file. While we are minimizing it by postponing the write until we have gathered the next verse, the following scenario is happening: A module is using linked verses and has some verses that are not in the chosen versification. If the out-of-canon verse happens following a linked verse, the out-of-canon verse is appended to the prior verse. Care has to be taken that the linked verses all point to the first of the set.
Definition at line 1323 of file osis2mod.cpp.
char activeOsisID[255] |
Definition at line 108 of file osis2mod.cpp.
SWBuf activeVerseText |
Definition at line 111 of file osis2mod.cpp.
int converted = 0 |
Definition at line 103 of file osis2mod.cpp.
Definition at line 113 of file osis2mod.cpp.
char currentOsisID[255] |
Definition at line 109 of file osis2mod.cpp.
VerseKey currentVerse |
Definition at line 106 of file osis2mod.cpp.
int debug = 0 |
Definition at line 76 of file osis2mod.cpp.
const int DEBUG_INTERVERSE = 16 |
Definition at line 81 of file osis2mod.cpp.
const int DEBUG_OTHER = 512 |
Definition at line 86 of file osis2mod.cpp.
const int DEBUG_QUOTE = 4 |
Definition at line 79 of file osis2mod.cpp.
const int DEBUG_REF = 128 |
Definition at line 84 of file osis2mod.cpp.
const int DEBUG_REV11N = 64 |
Definition at line 83 of file osis2mod.cpp.
const int DEBUG_STACK = 256 |
Definition at line 85 of file osis2mod.cpp.
const int DEBUG_TITLE = 8 |
Definition at line 80 of file osis2mod.cpp.
const int DEBUG_VERSE = 2 |
Definition at line 78 of file osis2mod.cpp.
const int DEBUG_WRITE = 1 |
Definition at line 77 of file osis2mod.cpp.
const int DEBUG_XFORM = 32 |
Definition at line 82 of file osis2mod.cpp.
const int EXIT_BAD_ARG = 1 |
Definition at line 89 of file osis2mod.cpp.
const int EXIT_BAD_NESTING = 5 |
Definition at line 93 of file osis2mod.cpp.
const int EXIT_NO_CREATE = 3 |
Definition at line 91 of file osis2mod.cpp.
const int EXIT_NO_READ = 4 |
Definition at line 92 of file osis2mod.cpp.
const int EXIT_NO_WRITE = 2 |
Definition at line 90 of file osis2mod.cpp.
|
static |
Definition at line 117 of file osis2mod.cpp.
std::vector<ListKey> linkedVerses |
Definition at line 115 of file osis2mod.cpp.
SWText* module = 0 |
Definition at line 105 of file osis2mod.cpp.
|
static |
Definition at line 118 of file osis2mod.cpp.
int normalized = 0 |
Definition at line 102 of file osis2mod.cpp.
Definition at line 100 of file osis2mod.cpp.
Definition at line 99 of file osis2mod.cpp.
SWBuf v11n = "KJV" |
Definition at line 107 of file osis2mod.cpp.