本文整理汇总了C++中VerseKey::getUpperBound方法的典型用法代码示例。如果您正苦于以下问题:C++ VerseKey::getUpperBound方法的具体用法?C++ VerseKey::getUpperBound怎么用?C++ VerseKey::getUpperBound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VerseKey
的用法示例。
在下文中一共展示了VerseKey::getUpperBound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
const char * helptext = "addvs 1.1 Bible & Commentary module creation tool for the SWORD Project\nUse -a to add a new verse from standard input or a file, -d to delete a verse,\n-l to link two verses, -c to create a new module.\n usage:\n %s -a </path/to/module> <verse> [</path/to/file/with/verse>]\n %s -d </path/to/module> <key>\n %s -l </path/to/module> <first verse (already assigned)> <second verse>\n %s -c </path/to/module>\n";
long entrysize;
if (argc < 3) {
fprintf(stderr, helptext, argv[0], argv[0], argv[0], argv[0]);
exit(-1);
}
if (!strcmp(argv[1], "-a") && (argc == 4 || argc == 5)) {
// Do some initialization stuff
char buffer[65536]; //this is the max size of any entry
RawText * mod = new RawText(argv[2]); // open our datapath with our RawText driver.
VerseKey *vkey = new VerseKey;
vkey->setIntros(true);
vkey->setAutoNormalize(false);
vkey->setPersist(true); // the magical setting
*vkey = argv[3];
// Set our VerseKey
mod->setKey(*vkey);
if (!vkey->getChapter()) {
// 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->getVerse();
vkey->setVerse(0);
*mod -= backstep;
// << bad hack
FILE *infile;
// case: add from text file
//Open our data file and read its contents into the buffer
if (argc == 5) infile = fopen(argv[4], "r");
// case: add from stdin
else infile = stdin;
entrysize = fread(buffer, sizeof(char), sizeof(buffer), infile);
mod->setEntry(buffer, entrysize); // save text to module at current position
}
else {
ListKey listkey = vkey->parseVerseList(argv[3], "Gen1:1", true);
int i;
bool havefirst = false;
VerseKey firstverse;
for (i = 0; i < listkey.getCount(); i++) {
VerseKey *element = SWDYNAMIC_CAST(VerseKey, listkey.getElement(i));
if (element) {
mod->setKey(element->getLowerBound());
VerseKey finalkey = element->getUpperBound();
std::cout << mod->getKeyText() << "-" << (const char*)finalkey << std::endl;
if (!havefirst) {
havefirst = true;
firstverse = *mod->getKey();
FILE *infile;
// case: add from text file
//Open our data file and read its contents into the buffer
if (argc == 5) infile = fopen(argv[4], "r");
// case: add from stdin
else infile = stdin;
entrysize = fread(buffer, sizeof(char), sizeof(buffer), infile);
mod->setEntry(buffer, entrysize); // save text to module at current position
std::cout << "f" << (const char*)firstverse << std::endl;
(*mod)++;
}
while (*mod->getKey() <= finalkey) {
std::cout << mod->getKeyText() << std::endl;
*(SWModule*)mod << &firstverse;
(*mod)++;
}
}
else {
if (havefirst) {
mod->setKey(*listkey.getElement(i));
*(SWModule*)mod << &firstverse;
std::cout << mod->getKeyText() << std::endl;
}
else {
mod->setKey(*listkey.getElement(i));
havefirst = true;
firstverse = *mod->getKey();
FILE *infile;
// case: add from text file
//Open our data file and read its contents into the buffer
if (argc == 5) infile = fopen(argv[4], "r");
// case: add from stdin
else infile = stdin;
entrysize = fread(buffer, sizeof(char), sizeof(buffer), infile);
mod->setEntry(buffer, entrysize); // save text to module at current position
std::cout << "f" << (const char*)firstverse << std::endl;
}
}
//.........这里部分代码省略.........
示例2: doquery
void doquery(unsigned long maxverses = -1, unsigned char outputformat = FMT_PLAIN, unsigned char outputencoding = ENC_UTF8, unsigned long optionfilters = 0, unsigned char searchtype = ST_NONE, const char *range = 0, const char *text = 0, const char *locale = 0, const char *ref = 0, ostream* output = &cout, const char *script = 0, signed short variants = 0) {
static DiathekeMgr manager(NULL, NULL, false, outputencoding, outputformat,
((OP_BIDI & optionfilters) == OP_BIDI),
((OP_ARSHAPE & optionfilters) == OP_ARSHAPE));
ModMap::iterator it;
ListKey listkey;
SectionMap::iterator sit;
ConfigEntMap::iterator eit;
SWModule *target;
char *font = 0;
char inputformat = 0;
SWBuf encoding;
char querytype = 0;
if (locale) {
LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(locale);
}
//deal with queries to "system"
if (!::stricmp(text, "system")) {
querytype = QT_SYSTEM;
systemquery(ref, output);
}
if (!strnicmp(text, "info", 4)) {
querytype = QT_INFO;
text = ref;
}
//otherwise, we have a real book
it = manager.Modules.find(text);
if (it == manager.Modules.end()) { //book not found
return;
}
target = (*it).second;
SWKey *p = target->createKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
parser = new VerseKey();
}
if ((sit = manager.config->Sections.find((*it).second->getName())) != manager.config->Sections.end()) {
if ((eit = (*sit).second.find("SourceType")) != (*sit).second.end()) {
if (!::stricmp((char *)(*eit).second.c_str(), "GBF"))
inputformat = FMT_GBF;
else if (!::stricmp((char *)(*eit).second.c_str(), "ThML"))
inputformat = FMT_THML;
else if (!::stricmp((char *)(*eit).second.c_str(), "OSIS"))
inputformat = FMT_OSIS;
else if (!::stricmp((char *)(*eit).second.c_str(), "TEI"))
inputformat = FMT_TEI;
}
encoding = ((eit = (*sit).second.find("Encoding")) != (*sit).second.end()) ? (*eit).second : (SWBuf)"";
}
if (querytype == QT_INFO) {
switch (inputformat) {
case FMT_THML :
*output << "ThML";
break;
case FMT_GBF :
*output << "GBF";
break;
case FMT_OSIS :
*output << "OSIS";
break;
case FMT_TEI :
*output << "TEI";
break;
default:
*output << "Other";
}
*output << ";";
*output << target->getType();
*output << ";";
delete parser;
return;
}
if (searchtype)
querytype = QT_SEARCH;
else if (!strcmp(target->getType(), "Biblical Texts"))
querytype = QT_BIBLE;
else if (!strcmp(target->getType(), "Commentaries"))
querytype = QT_COMM;
else if (!strcmp(target->getType(), "Lexicons / Dictionaries"))
querytype = QT_LD;
else if (!strcmp(target->getType(), "Generic Books"))
querytype = QT_LD;
if (optionfilters & OP_FOOTNOTES)
manager.setGlobalOption("Footnotes","On");
else
manager.setGlobalOption("Footnotes","Off");
if (optionfilters & OP_HEADINGS)
manager.setGlobalOption("Headings","On");
else
manager.setGlobalOption("Headings","Off");
//.........这里部分代码省略.........