本文整理汇总了C++中ListKey::popError方法的典型用法代码示例。如果您正苦于以下问题:C++ ListKey::popError方法的具体用法?C++ ListKey::popError怎么用?C++ ListKey::popError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ListKey
的用法示例。
在下文中一共展示了ListKey::popError方法的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) {
SWMgr mgr;
SWModule *mod = mgr.getModule("KJVgb");
VerseKey *key1 = (VerseKey *)mod->createKey();
key1->setTestament(2);
key1->setBook(4);
key1->setChapter(2);
key1->setVerse(3);
cout << "\n" << key1->getText() << ":\n\n";
ListKey keys;
keys << *key1;
cout << "\n" << keys.getRangeText() << ":\n\n";
ListKey keys2 = keys;
cout << "\n" << keys2.getRangeText() << ":\n\n";
keys = key1->parseVerseList("Lk.4.5");
cout << "\n" << key1->getText() << ":\n\n";
key1->setText("jn.6.7");
cout << "\n" << key1->getText() << ":\n\n";
mod->setKey("lk.2.3");
cout << "\n" << mod->getKeyText() << ":\n" << endl;
cout << mod->getRawEntry() << endl;
cout << "\nListkey persist key iteration test\n\n";
keys = key1->parseVerseList("mat1", 0, true);
for (keys = TOP; !keys.popError(); keys++) {
cout << "\n" << keys.getText() << ":\n" << endl;
}
keys.setPersist(true);
mod->setKey(keys);
for ((*mod) = TOP; !mod->popError(); (*mod)++) {
cout << "\n" << mod->getKeyText() << ":\n" << endl;
}
delete key1;
return 0;
}
示例4: 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;
}
示例5: 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;
}
示例6: writeEntry
void writeEntry(SWModule *module, const SWBuf &key, const SWBuf &entry)
{
if (key.size() && entry.size()) {
std::cout << "from file: " << key << std::endl;
VerseKey *vkey = (VerseKey *)module->getKey();
VerseKey *linkMaster = (VerseKey *)module->createKey();
ListKey listKey = vkey->parseVerseList(key.c_str(), "Gen1:1", true);
bool first = true;
for (listKey = TOP; !listKey.popError(); listKey++) {
*vkey = listKey;
if (first) {
*linkMaster = *vkey;
SWBuf text = module->getRawEntry();
text += entry;
//------------------------------------------------------------
// Tregelles Page marking special stuff
//------------------------------------------------------------
/*
const char *pageMarker = "<seg type=\"page\" subtype=\"";
int newPage = page;
SWBuf pageData = strstr(text.c_str(), pageMarker);
if (pageData.length()) {
pageData << strlen(pageMarker);
const char *pn = pageData.stripPrefix('"');
if (pn) newPage = atoi(pn);
}
// add page stuff for treg
if (text.startsWith(pageMarker)) {
// don't add anything cuz we already start with one
}
else {
SWBuf pm = pageMarker;
pm.appendFormatted("%d\" />", page);
text = pm + text;
}
page = newPage; // when our line set a new page number
*/
//------------------------------------------------------------
std::cout << "adding entry: " << *vkey << " length " << entry.size() << "/" << (unsigned short)text.size() << std::endl;
module->setEntry(text);
first = false;
}
else {
std::cout << "linking entry: " << *vkey << " to " << *linkMaster << std::endl;
module->linkEntry(linkMaster);
}
}
delete linkMaster;
}
}
示例7:
const char *listkey_iterator_val(SWHANDLE lki) {
ListKey *lk = (ListKey*)lki;
if(!lk->popError())
return (const char *) lk->getText();
return NULL;
}
示例8: 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;
}
示例9: doquery
//.........这里部分代码省略.........
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;
*output << " matches total (";
*output << target->getName();
*output << ")\n";
}
else {