utilities/diatheke/corediatheke.h File Reference

#include <stdio.h>
#include <iostream>
#include "diathekemgr.h"
#include <localemgr.h>
Include dependency graph for corediatheke.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define OP_ARABICPOINTS   16384
#define OP_ARSHAPE   1024
#define OP_BIDI   2048
#define OP_CANTILLATION   16
#define OP_FOOTNOTES   2
#define OP_GREEKACCENTS   64
#define OP_HEADINGS   4
#define OP_HEBREWPOINTS   32
#define OP_LEMMAS   256
#define OP_MORPH   8
#define OP_NONE   0
#define OP_RED   8192
#define OP_SCRIPREF   512
#define OP_STRONGS   1
#define OP_TRANSLITERATOR   128
#define OP_VARIANTS   4096
#define QT_BIBLE   1
#define QT_COMM   2
#define QT_INFO   6
#define QT_LD   3
#define QT_SEARCH   4
#define QT_SYSTEM   5
#define ST_MULTIWORD   3
#define ST_NONE   0
#define ST_PHRASE   2
#define ST_REGEX   1

Functions

void doquery (unsigned long maxverses, unsigned char outputformat, unsigned char outputencoding, unsigned long optionfilters, unsigned char searchtype, const char *range, const char *text, const char *locale, const char *ref, ostream *output, const char *script, signed short variants)
int hasalpha (char *string)

Define Documentation

#define OP_ARABICPOINTS   16384

Definition at line 50 of file corediatheke.h.

#define OP_ARSHAPE   1024

Definition at line 46 of file corediatheke.h.

#define OP_BIDI   2048

Definition at line 47 of file corediatheke.h.

#define OP_CANTILLATION   16

Definition at line 40 of file corediatheke.h.

#define OP_FOOTNOTES   2

Definition at line 37 of file corediatheke.h.

#define OP_GREEKACCENTS   64

Definition at line 42 of file corediatheke.h.

#define OP_HEADINGS   4

Definition at line 38 of file corediatheke.h.

#define OP_HEBREWPOINTS   32

Definition at line 41 of file corediatheke.h.

#define OP_LEMMAS   256

Definition at line 44 of file corediatheke.h.

#define OP_MORPH   8

Definition at line 39 of file corediatheke.h.

#define OP_NONE   0

Definition at line 35 of file corediatheke.h.

#define OP_RED   8192

Definition at line 49 of file corediatheke.h.

#define OP_SCRIPREF   512

Definition at line 45 of file corediatheke.h.

#define OP_STRONGS   1

Definition at line 36 of file corediatheke.h.

#define OP_TRANSLITERATOR   128

Definition at line 43 of file corediatheke.h.

#define OP_VARIANTS   4096

Definition at line 48 of file corediatheke.h.

#define QT_BIBLE   1

Definition at line 28 of file corediatheke.h.

#define QT_COMM   2

Definition at line 29 of file corediatheke.h.

#define QT_INFO   6

Definition at line 33 of file corediatheke.h.

#define QT_LD   3

Definition at line 30 of file corediatheke.h.

#define QT_SEARCH   4

Definition at line 31 of file corediatheke.h.

#define QT_SYSTEM   5

Definition at line 32 of file corediatheke.h.

#define ST_MULTIWORD   3

Definition at line 54 of file corediatheke.h.

#define ST_NONE   0

Definition at line 51 of file corediatheke.h.

#define ST_PHRASE   2

Definition at line 53 of file corediatheke.h.

#define ST_REGEX   1

Definition at line 52 of file corediatheke.h.


Function Documentation

void doquery ( unsigned long  maxverses,
unsigned char  outputformat,
unsigned char  outputencoding,
unsigned long  optionfilters,
unsigned char  searchtype,
const char *  range,
const char *  text,
const char *  locale,
const char *  ref,
ostream *  output,
const char *  script,
signed short  variants 
)

Definition at line 108 of file corediatheke.cpp.

00108                                                                                                                                                                                                                                                                                                                                                                        {
00109     static DiathekeMgr manager(NULL, NULL, false, outputencoding, outputformat,
00110         ((OP_BIDI & optionfilters) == OP_BIDI),
00111         ((OP_ARSHAPE & optionfilters) == OP_ARSHAPE));
00112 
00113     ModMap::iterator it;
00114     ListKey listkey;
00115     SectionMap::iterator sit;
00116     ConfigEntMap::iterator eit;
00117 
00118     SWModule *target;
00119     char *font = 0;
00120     char inputformat = 0;
00121     SWBuf encoding;
00122     char querytype = 0;
00123 
00124     if (locale) {
00125         LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(locale);
00126     }
00127 
00128     //deal with queries to "system"
00129     if (!::stricmp(text, "system")) {
00130         querytype = QT_SYSTEM;
00131         systemquery(ref, output);
00132     }
00133     if (!strnicmp(text, "info", 4)) {
00134             querytype = QT_INFO;
00135         text = ref;
00136     }
00137     //otherwise, we have a real book
00138     it = manager.Modules.find(text);
00139     if (it == manager.Modules.end()) { //book not found
00140         return;
00141     }
00142     target = (*it).second;
00143     SWKey *p = target->createKey();
00144         VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
00145     if (!parser) {
00146             delete p;
00147             parser = new VerseKey();
00148     }
00149 
00150     if ((sit = manager.config->Sections.find((*it).second->getName())) != manager.config->Sections.end()) {
00151         if ((eit = (*sit).second.find("SourceType")) != (*sit).second.end()) {
00152             if (!::stricmp((char *)(*eit).second.c_str(), "GBF"))
00153                 inputformat = FMT_GBF;
00154             else if (!::stricmp((char *)(*eit).second.c_str(), "ThML"))
00155                 inputformat = FMT_THML;
00156             else if (!::stricmp((char *)(*eit).second.c_str(), "OSIS"))
00157                 inputformat = FMT_OSIS;
00158             else if (!::stricmp((char *)(*eit).second.c_str(), "TEI"))
00159                 inputformat = FMT_TEI;
00160         }
00161         encoding = ((eit = (*sit).second.find("Encoding")) != (*sit).second.end()) ? (*eit).second : (SWBuf)"";
00162     }
00163 
00164 
00165     if (querytype == QT_INFO) {
00166       switch (inputformat) {
00167       case FMT_THML :
00168         *output << "ThML";
00169         break;
00170       case FMT_GBF :
00171         *output << "GBF";
00172         break;
00173       case FMT_OSIS :
00174         *output << "OSIS";
00175         break;
00176       case FMT_TEI :
00177         *output << "TEI";
00178         break;
00179       default:
00180         *output << "Other";
00181       }
00182       *output << ";";
00183       *output << target->getType();
00184       *output << ";";
00185       delete parser;
00186       return;
00187     }
00188 
00189     if (searchtype)
00190         querytype = QT_SEARCH;
00191     else if (!strcmp(target->getType(), "Biblical Texts"))
00192         querytype = QT_BIBLE;
00193     else if (!strcmp(target->getType(), "Commentaries"))
00194         querytype = QT_COMM;
00195     else if (!strcmp(target->getType(), "Lexicons / Dictionaries"))
00196         querytype = QT_LD;
00197     else if (!strcmp(target->getType(), "Generic Books"))
00198         querytype = QT_LD;
00199 
00200     if (optionfilters & OP_FOOTNOTES)
00201         manager.setGlobalOption("Footnotes","On");
00202     else
00203         manager.setGlobalOption("Footnotes","Off");
00204     if (optionfilters & OP_HEADINGS)
00205         manager.setGlobalOption("Headings","On");
00206     else
00207         manager.setGlobalOption("Headings","Off");
00208     if (optionfilters & OP_STRONGS)
00209         manager.setGlobalOption("Strong's Numbers","On");
00210     else
00211         manager.setGlobalOption("Strong's Numbers","Off");
00212     if (optionfilters & OP_MORPH)
00213         manager.setGlobalOption("Morphological Tags","On");
00214     else
00215         manager.setGlobalOption("Morphological Tags","Off");
00216     if (optionfilters & OP_CANTILLATION)
00217         manager.setGlobalOption("Hebrew Cantillation","On");
00218     else
00219         manager.setGlobalOption("Hebrew Cantillation","Off");
00220     if (optionfilters & OP_HEBREWPOINTS)
00221         manager.setGlobalOption("Hebrew Vowel Points","On");
00222     else
00223         manager.setGlobalOption("Hebrew Vowel Points","Off");
00224     if (optionfilters & OP_GREEKACCENTS)
00225         manager.setGlobalOption("Greek Accents","On");
00226     else
00227         manager.setGlobalOption("Greek Accents","Off");
00228     if (optionfilters & OP_LEMMAS)
00229         manager.setGlobalOption("Lemmas","On");
00230     else
00231         manager.setGlobalOption("Lemmas","Off");
00232     if (optionfilters & OP_SCRIPREF)
00233         manager.setGlobalOption("Cross-references","On");
00234     else
00235         manager.setGlobalOption("Cross-references","Off");
00236     if (optionfilters & OP_RED)
00237         manager.setGlobalOption("Words of Christ in Red","On");
00238     else
00239         manager.setGlobalOption("Words of Christ in Red","Off");
00240     if (optionfilters & OP_VARIANTS && variants) {
00241             if (variants == -1)
00242                 manager.setGlobalOption("Variants", "All Readings");
00243             else if (variants == 1)
00244                 manager.setGlobalOption("Variants", "Secondary Readings");
00245     }
00246     else
00247         manager.setGlobalOption("Variants", "Primary Readings");
00248 
00249     if (optionfilters & OP_TRANSLITERATOR && script)
00250                 manager.setGlobalOption("Transliteration", script);
00251     else
00252         manager.setGlobalOption("Transliteration", "Off");
00253     if (optionfilters & OP_ARABICPOINTS)
00254         manager.setGlobalOption("Arabic Vowel Points","On");
00255     else
00256         manager.setGlobalOption("Arabic Vowel Points","Off");
00257 
00258     if (querytype == QT_SEARCH) {
00259 
00260             //this test is just to determine if we've got SWKeys or VerseKeys
00261             if (!strcmp(target->getType(), "Biblical Texts"))
00262           querytype = QT_BIBLE;
00263         else if (!strcmp(target->getType(), "Commentaries"))
00264           querytype = QT_BIBLE;
00265         else if (!strcmp(target->getType(), "Lexicons / Dictionaries"))
00266           querytype = QT_LD;
00267         else if (!strcmp(target->getType(), "Generic Books"))
00268           querytype = QT_LD;
00269 
00270         //do search stuff
00271         char st = 1 - searchtype;
00272         if (querytype == QT_BIBLE) {
00273           *output << "Verses containing \"";
00274         }
00275         else *output << "Entries containing \"";
00276             *output << ref;
00277         *output << "\"-- ";
00278 
00279         if (range) {
00280             ListKey scope = parser->parseVerseList(range, "Gen 1:1", true);
00281             listkey = target->search(ref, st, REG_ICASE, &scope);
00282         }
00283         else listkey = target->search(ref, st, REG_ICASE);
00284 
00285         if (strlen((const char*)listkey)) {
00286           if (!listkey.popError()) {
00287             if (outputformat == FMT_CGI) *output << "<entry>";
00288             if (querytype == QT_BIBLE) {
00289               *parser = listkey;
00290               *output << (const char *)*parser;
00291             }
00292             else *output << (const char *)listkey;
00293             if (outputformat == FMT_CGI) *output << "</entry>";
00294           }
00295           listkey++;
00296           while (!listkey.popError()) {
00297             *output << " ; ";
00298             if (outputformat == FMT_CGI) *output << "<entry>";
00299             if (querytype == QT_BIBLE) {
00300               *parser = listkey;
00301               *output << (const char *)*parser;
00302             }
00303             else *output << (const char *)listkey;
00304             if (outputformat == FMT_CGI) *output << "</entry>";
00305             listkey++;
00306           }
00307           *output << " -- ";
00308 
00309           char *temp = new char[10];
00310           sprintf(temp, "%u", listkey.Count());
00311           *output << temp;
00312           delete [] temp;
00313 
00314           *output << " matches total (";
00315           *output << target->getName();
00316           *output << ")\n";
00317         }
00318         else {
00319           *output << "none (";
00320           *output << target->getName();
00321           *output << ")\n";
00322         }
00323     }
00324 
00325     else if (querytype == QT_LD) {
00326         //do dictionary stuff
00327 
00328         target->setKey(ref);
00329 
00330         const char * text = (const char *) *target;
00331 
00332         if (outputformat == FMT_RTF) {
00333             *output << "{\\rtf1\\ansi{\\fonttbl{\\f0\\froman\\fcharset0\\fprq2 Times New Roman;}{\\f1\\fdecor\\fprq2 ";
00334             if (font)
00335                 *output << font;
00336             else
00337                 *output << "Times New Roman";
00338             *output << ";}}";
00339         }
00340         else if (outputformat == FMT_HTML) {
00341             *output << "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
00342         }
00343 
00344         if (strlen(text)) {
00345             *output << (char*)target->getKeyText();
00346             if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
00347                 *output << ": <font face=\"";
00348                 *output << font;
00349                 *output << "\">";
00350             }
00351             else if (outputformat == FMT_RTF) {
00352                 *output << ": {\\f1 ";
00353             }
00354             else {
00355                 *output << ": ";
00356             }
00357             *output << text;
00358             if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
00359                 *output << "</font>";
00360             }
00361             else if (outputformat == FMT_RTF) {
00362                 *output << "}";
00363             }
00364 
00365             *output << "(";
00366             *output << target->getName();
00367             *output << ")\n";
00368         }
00369 
00370         if (outputformat == FMT_RTF) {
00371             *output << "}";
00372         }
00373 
00374     }
00375 
00376     else if (querytype == QT_BIBLE || querytype == QT_COMM) {
00377         //do commentary/Bible stuff
00378 
00379         if ((sit = manager.config->Sections.find((*it).second->getName())) != manager.config->Sections.end()) {
00380             if ((eit = (*sit).second.find("Font")) != (*sit).second.end()) {
00381                 font = (char *)(*eit).second.c_str();
00382                 if (strlen(font) == 0) font = 0;
00383             }
00384         }
00385 
00386         listkey = parser->parseVerseList(ref, "Gen1:1", true);
00387         int i;
00388 
00389         if (outputformat == FMT_RTF) {
00390             *output << "{\\rtf1\\ansi{\\fonttbl{\\f0\\froman\\fcharset0\\fprq2 Times New Roman;}{\\f1\\fdecor\\fprq2 ";
00391             if (font)
00392                 *output << font;
00393             else
00394                 *output << "Times New Roman";
00395             *output << ";}{\\f7\\froman\\fcharset2\\fprq2 Symbol;}}";
00396         }
00397         else if (outputformat == FMT_HTML) {
00398             *output << "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
00399         }
00400 
00401         for (i = 0; i < listkey.Count() && maxverses; i++) {
00402             VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(i));
00403             if (element && element->isBoundSet()) {
00404               target->setKey(element->getLowerBound());
00405                 *parser = element->getUpperBound();
00406                 while (maxverses && *target->getKey() <= *parser) {
00407                     *output << (char*)target->getKeyText();
00408                     if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
00409                         *output << ": <font face=\"";
00410                         *output << font;
00411                         *output << "\">";
00412                     }
00413                     else if (outputformat == FMT_RTF) {
00414                         *output << ": {\\f1 ";
00415                     }
00416                     else {
00417                         *output << ": ";
00418                     }
00419                     *output << (const char*)*target;
00420                     if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
00421                         *output << "</font>";
00422                     }
00423                     else if (outputformat == FMT_RTF) {
00424                         *output << "}";
00425                     }
00426 
00427                     if (inputformat != FMT_THML && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI))
00428                         *output << "<br />";
00429                     else if (outputformat == FMT_OSIS)
00430                         *output << "<milestone type=\"line\"/>";
00431                     else if (outputformat == FMT_RTF)
00432                         *output << "\\par ";
00433                     else if (outputformat == FMT_GBF)
00434                         *output << "<CM>";
00435 
00436                     *output << "\n";
00437 
00438                     if (*target->getKey() == *parser)
00439                       break;
00440                     maxverses--;
00441                     (*target)++;
00442                 }
00443             }
00444             else {
00445                 target->setKey(*listkey.GetElement(i));
00446                 *output << (char*)target->getKeyText();
00447                 if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
00448                     *output << ": <font face=\"";
00449                     *output << font;
00450                     *output << "\">";
00451                 }
00452                 else if (outputformat == FMT_RTF) {
00453                     *output << ": {\\f1 ";
00454                 }
00455                 else {
00456                     *output << ": ";
00457                 }
00458                 *output << (const char*)*target;
00459                 if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) {
00460                     *output << "</font>";
00461                 }
00462                 else if (outputformat == FMT_RTF) {
00463                     *output << "}";
00464                 }
00465 
00466                 if (inputformat != FMT_THML && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI))
00467                     *output << "<br />";
00468                 else if (outputformat == FMT_OSIS)
00469                     *output << "<milestone type=\"line\"/>";
00470                 else if (outputformat == FMT_RTF)
00471                     *output << "\\par ";
00472                 else if (outputformat == FMT_GBF)
00473                     *output << "<CM>";
00474 
00475                 *output << "\n";
00476                 maxverses--;
00477             }
00478         }
00479 
00480         *output << "(";
00481         *output << target->getName();
00482         *output << ")\n";
00483 
00484         if (outputformat == FMT_RTF) {
00485             *output << "}";
00486         }
00487 
00488     }
00489     delete parser;
00490 }

int hasalpha ( char *  string  ) 

Generated on 18 Mar 2013 for The SWORD Project by  doxygen 1.6.1