本文整理汇总了C++中VerseKey::parseVerseList方法的典型用法代码示例。如果您正苦于以下问题:C++ VerseKey::parseVerseList方法的具体用法?C++ VerseKey::parseVerseList怎么用?C++ VerseKey::parseVerseList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VerseKey
的用法示例。
在下文中一共展示了VerseKey::parseVerseList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
const char *range = (argc > 1) ? argv[1] : "Mat 2:10,12-15";
VerseKey parser;
ListKey result;
result = parser.parseVerseList(range, parser.getText().c_str(), true);
// let's iterate the key and display
for (result.positionToTop(); !result.popError(); result.increment()) {
cout << result.getText() << "\n";
}
cout << endl;
// Now let's output a module with the entries from the result
// we'll initialize our library of books
SWMgr library(std::make_shared<MarkupFilterMgr>(FMT_PLAIN)); // render plain without fancy markup
// Let's get a book;
auto const book(library.getModule("KJV"));
// couldn't find our test module
if (!book) return -1;
// now let's iterate the book and display
for (result.positionToTop(); !result.popError(); result.increment()) {
book->setKey(result);
cout << "*** " << book->getKeyText() << ": " << book->renderText() << "\n";
}
return 0;
}
示例2: writeEntry
void writeEntry(SWModule & module,
std::string const & key,
std::string const & entry,
bool const replace)
{
if (key.size() && entry.size()) {
std::cout << "from file: " << key << std::endl;
VerseKey *vkey = (VerseKey *)module.getKey();
std::unique_ptr<VerseKey> linkMaster(
static_cast<VerseKey *>(module.createKey().release()));
ListKey listKey = vkey->parseVerseList(key.c_str(), "Gen1:1", true);
bool first = true;
for (listKey.positionToTop(); !listKey.popError(); listKey.increment()) {
vkey->positionFrom(listKey);
if (first) {
*linkMaster = *vkey;
std::string text;
if (!replace)
text = module.getRawEntry();
text += entry;
std::cout << "adding entry: " << vkey->getText() << " length " << entry.size() << "/" << (unsigned short)text.size() << std::endl;
module.setEntry(text.c_str());
first = false;
}
else {
std::cout << "linking entry: " << vkey->getText() << " to " << linkMaster->getText() << std::endl;
module.linkEntry(*linkMaster);
}
}
}
}
示例3: main
int main(int argc, char **argv)
{
const char *range = (argc > 1) ? argv[1] : "Mat 2:10,12-15";
VerseKey parser;
ListKey result;
result = parser.parseVerseList(range, parser, true);
// let's iterate the key and display
for (result = TOP; !result.popError(); result++) {
cout << result << "\n";
}
cout << endl;
// Now if we'd like persist this key for use inside of a book...
result.setPersist(true);
// Let's get a book;
SWMgr library(new MarkupFilterMgr(FMT_PLAIN)); // render plain without fancy markup
SWModule *book = library.getModule("KJV");
// and set our limited key inside
book->setKey(result);
// now let's iterate the book and display
for ((*book) = TOP; !book->popError(); (*book)++) {
cout << "*** " << book->getKeyText() << ": " << book->renderText() << "\n";
}
// Since we've told our result key to persist in book, we can reuse our
// setup by simply resetting result, e.g.
//
// result = parser.ParseVerseList(someNewRange, parser, true);
//
// Now an iteration of book will give us our new range.
//
// To stop persistence of our custom key, we'll need to set our book's key
// to something simple:
//
// book->setKey("gen.1.1");
//
// Resetting our book object's key to something not persistent will revert our book object to using its default key for positioning
//
//
return 0;
}
示例4: main
int main(int argc, char **argv) {
if ((argc < 2) || (argc > 4)) {
fprintf(stderr, "usage: %s <\"string to parse\"> [locale_name] [test-in-set-verse]\n", *argv);
exit(-1);
}
if (argc > 2)
LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(argv[2]);
VerseKey DefaultVSKey;
DefaultVSKey = "jas3:1";
ListKey verses = DefaultVSKey.parseVerseList(argv[1], DefaultVSKey, true);
std::cout << verses.getOSISRefRangeText() << "\n";
if (argc > 3) {
verses.setText(argv[3]);
std::cout << "Verse is" << ((verses.popError()) ? " NOT" : "") << " in set.\n\n";
}
return 0;
}
示例5: processText
char OSISFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
SWBuf token;
bool intoken = false;
bool hide = false;
SWBuf tagText;
XMLTag startTag;
SWBuf refs = "";
int footnoteNum = 1;
char buf[254];
SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
parser = new VerseKey();
}
*parser = key->getText();
SWBuf orig = text;
const char *from = orig.c_str();
XMLTag tag;
bool strongsMarkup = false;
for (text = ""; *from; ++from) {
// remove all newlines temporarily to fix kjv2003 module
if ((*from == 10) || (*from == 13)) {
if ((text.length()>1) && (text[text.length()-2] != ' ') && (*(from+1) != ' '))
text.append(' ');
continue;
}
if (*from == '<') {
intoken = true;
token = "";
continue;
}
if (*from == '>') { // process tokens
intoken = false;
if (!strncmp(token, "note", 4) || !strncmp(token.c_str(), "/note", 5)) {
tag = token;
if (!tag.isEndTag()) {
if (tag.getAttribute("type") && (!strcmp("x-strongsMarkup", tag.getAttribute("type"))
|| !strcmp("strongsMarkup", tag.getAttribute("type"))) // deprecated
) {
tag.setEmpty(false); // handle bug in KJV2003 module where some note open tags were <note ... />
strongsMarkup = true;
}
if (!tag.isEmpty()) {
// if ((!tag.isEmpty()) || (SWBuf("strongsMarkup") == tag.getAttribute("type"))) {
refs = "";
startTag = tag;
hide = true;
tagText = "";
continue;
}
}
if (hide && tag.isEndTag()) {
if (module->isProcessEntryAttributes() && !strongsMarkup) { //don`t parse strongsMarkup to EntryAttributes as Footnote
sprintf(buf, "%i", footnoteNum++);
StringList attributes = startTag.getAttributeNames();
for (StringList::const_iterator it = attributes.begin(); it != attributes.end(); it++) {
module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
}
module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
startTag.setAttribute("swordFootnote", buf);
if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) {
if (!refs.length())
refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText();
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
}
}
hide = false;
if (option || (startTag.getAttribute("type") && !strcmp(startTag.getAttribute("type"), "crossReference"))) { // we want the tag in the text; crossReferences are handled by another filter
text.append(startTag);
// text.append(tagText); // we don't put the body back in because it is retrievable from EntryAttributes["Footnotes"][]["body"].
}
else continue;
}
strongsMarkup = false;
}
// if not a heading token, keep token in text
//if ((!strcmp(tag.getName(), "reference")) && (!tag.isEndTag())) {
// SWBuf osisRef = tag.getAttribute("osisRef");
if (!strncmp(token, "reference", 9)) {
if (refs.length()) {
refs.append("; ");
}
const char* attr = strstr(token.c_str() + 9, "osisRef=\"");
const char* end = attr ? strchr(attr+9, '"') : 0;
//.........这里部分代码省略.........
示例6: processText
char ThMLFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
SWBuf token;
bool intoken = false;
bool hide = false;
SWBuf tagText;
XMLTag startTag;
SWBuf refs = "";
int footnoteNum = 1;
char buf[254];
SWKey *p = (module) ? module->createKey() : (key) ? key->clone() : new VerseKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, p);
if (!parser) {
delete p;
parser = new VerseKey();
}
*parser = key->getText();
SWBuf orig = text;
const char *from = orig.c_str();
for (text = ""; *from; from++) {
if (*from == '<') {
intoken = true;
token = "";
continue;
}
if (*from == '>') { // process tokens
intoken = false;
XMLTag tag(token);
if (!strcmp(tag.getName(), "note")) {
if (!tag.isEndTag()) {
if (!tag.isEmpty()) {
refs = "";
startTag = tag;
hide = true;
tagText = "";
continue;
}
}
if (hide && tag.isEndTag()) {
if (module->isProcessEntryAttributes()) {
SWBuf fc = module->getEntryAttributes()["Footnote"]["count"]["value"];
footnoteNum = (fc.length()) ? atoi(fc.c_str()) : 0;
sprintf(buf, "%i", ++footnoteNum);
module->getEntryAttributes()["Footnote"]["count"]["value"] = buf;
StringList attributes = startTag.getAttributeNames();
for (StringList::iterator it = attributes.begin(); it != attributes.end(); it++) {
module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
}
module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
startTag.setAttribute("swordFootnote", buf);
if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) {
if (!refs.length())
refs = parser->parseVerseList(tagText.c_str(), *parser, true).getRangeText();
module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
}
}
hide = false;
if ((option) || ((startTag.getAttribute("type") && (!strcmp(startTag.getAttribute("type"), "crossReference"))))) { // we want the tag in the text; crossReferences are handled by another filter
text += startTag;
text.append(tagText);
}
else continue;
}
}
// if not a note token, keep token in text
if ((!strcmp(tag.getName(), "scripRef")) && (!tag.isEndTag())) {
SWBuf osisRef = tag.getAttribute("passage");
if (refs.length())
refs += "; ";
refs += osisRef;
}
if (!hide) {
text += '<';
text.append(token);
text += '>';
}
else {
tagText += '<';
tagText.append(token);
tagText += '>';
}
continue;
}
if (intoken) { //copy token
token += *from;
}
else if (!hide) { //copy text which is not inside a token
text += *from;
}
else tagText += *from;
}
delete parser;
return 0;
}
示例7: main
int main(int argc, char **argv)
{
// SWMgr manager(0, 0, true, new MarkupFilterMgr(FMT_RTF, ENC_RTF));
SWMgr manager;
SWModule *target;
ListKey listkey;
ListKey scope;
ModMap::iterator it;
if ((argc < 3) || (argc > 5)) {
fprintf(stderr, "\nusage: %s <modname> <\"search string\"> [\"search_scope\"] [\"search again for string in previous result set\"]\n"
"\tExample: search KJV \"swift hear slow speak\"\n\n", argv[0]);
exit(-1);
}
std::string searchTerm = argv[2];
manager.setGlobalOption("Greek Accents", "Off");
manager.setGlobalOption("Strong's Numbers", "On");
manager.setGlobalOption("Hebrew Vowel Points", "Off");
manager.filterText("Greek Accents", searchTerm);
it = manager.Modules.find(argv[1]);
if (it == manager.Modules.end()) {
fprintf(stderr, "Could not find module [%s]. Available modules:\n", argv[1]);
for (it = manager.Modules.begin(); it != manager.Modules.end(); ++it) {
fprintf(stderr, "[%s]\t - %s\n", (*it).second->getName(), (*it).second->getDescription());
}
exit(-1);
}
target = (*it).second;
if (argc > 3) { // if min / max specified
SWKey *k = target->getKey();
VerseKey *parser = SWDYNAMIC_CAST(VerseKey, k);
VerseKey kjvParser;
if (!parser) parser = &kjvParser; // use standard KJV parsing as fallback
scope = parser->parseVerseList(argv[3], *parser, true);
scope.setPersist(true);
target->setKey(scope);
}
std::cerr << "[0=================================50===============================100]\n ";
char lineLen = 70;
listkey = target->search(searchTerm.c_str(), SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
std::cerr << std::endl;
if (argc > 4) { // if min / max specified
scope = listkey;
scope.setPersist(true);
target->setKey(scope);
printed = 0;
std::cerr << " ";
listkey = target->search(argv[4], SEARCH_TYPE, /*SEARCHFLAG_MATCHWHOLEENTRY*/ REG_ICASE, 0, 0, &percentUpdate, &lineLen);
std::cerr << std::endl;
}
// we don't want to sort by verse if we've been given scores
// listkey.sort();
while (!listkey.popError()) {
std::cout << (const char *)listkey;
if (listkey.getElement()->userData) std::cout << " : " << (uint64_t)listkey.getElement()->userData << "%";
std::cout << std::endl;
++listkey;
}
return 0;
}
示例8: 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;
}
}
//.........这里部分代码省略.........
示例9: doquery
//.........这里部分代码省略.........
manager.setGlobalOption("Variants", "Primary Readings");
if (optionfilters & OP_TRANSLITERATOR && script)
manager.setGlobalOption("Transliteration", script);
else
manager.setGlobalOption("Transliteration", "Off");
if (optionfilters & OP_ARABICPOINTS)
manager.setGlobalOption("Arabic Vowel Points","On");
else
manager.setGlobalOption("Arabic Vowel Points","Off");
if (querytype == QT_SEARCH) {
//this test is just to determine if we've got SWKeys or VerseKeys
if (!strcmp(target->getType(), "Biblical Texts"))
querytype = QT_BIBLE;
else if (!strcmp(target->getType(), "Commentaries"))
querytype = QT_BIBLE;
else if (!strcmp(target->getType(), "Lexicons / Dictionaries"))
querytype = QT_LD;
else if (!strcmp(target->getType(), "Generic Books"))
querytype = QT_LD;
//do search stuff
char st = 1 - searchtype;
if (querytype == QT_BIBLE) {
*output << "Verses containing \"";
}
else *output << "Entries containing \"";
*output << ref;
*output << "\"-- ";
if (range) {
ListKey scope = parser->parseVerseList(range, "Gen 1:1", true);
listkey = target->search(ref, st, REG_ICASE, &scope);
}
else listkey = target->search(ref, st, REG_ICASE);
if (strlen((const char*)listkey)) {
if (!listkey.popError()) {
if (outputformat == FMT_CGI) *output << "<entry>";
if (querytype == QT_BIBLE) {
*parser = listkey;
*output << (const char *)*parser;
}
else *output << (const char *)listkey;
if (outputformat == FMT_CGI) *output << "</entry>";
}
listkey++;
while (!listkey.popError()) {
*output << " ; ";
if (outputformat == FMT_CGI) *output << "<entry>";
if (querytype == QT_BIBLE) {
*parser = listkey;
*output << (const char *)*parser;
}
else *output << (const char *)listkey;
if (outputformat == FMT_CGI) *output << "</entry>";
listkey++;
}
*output << " -- ";
char *temp = new char[10];
sprintf(temp, "%u", listkey.Count());
*output << temp;
delete [] temp;