本文整理汇总了C++中VerseKey::ParseVerseList方法的典型用法代码示例。如果您正苦于以下问题:C++ VerseKey::ParseVerseList方法的具体用法?C++ VerseKey::ParseVerseList怎么用?C++ VerseKey::ParseVerseList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VerseKey
的用法示例。
在下文中一共展示了VerseKey::ParseVerseList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseRangeKey
std::string parseRangeKey(const char* keyValue, const char* locale) {
const char* oldLocale = LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName();
LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(locale);
std::string ret;
VerseKey DefaultVSKey;
DefaultVSKey = "jas3:1";
ListKey verses = DefaultVSKey.ParseVerseList(keyValue, DefaultVSKey, true);
for (int i = 0; i < verses.Count(); i++) {
VerseKey *element = dynamic_cast<VerseKey *>(verses.GetElement(i));
if (element) {
if (ret.length()) {
ret.append(" ");
}
ret.appendFormatted( "%s - %s;", (const char*)element->LowerBound(), (const char*)element->UpperBound() );
}
else {
if (ret.length()) {
ret.append(" ");
}
ret.appendFormatted("%s;", (const char *)*verses.GetElement(i));
}
}
// cout << ret.c_str() << endl;
LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(oldLocale);
return ret;
};
示例2: decodeCrossReference
const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
Q_ASSERT(!data.isEmpty());
if (data.isEmpty()) {
return QString("<div class=\"crossrefinfo\"><h3>%1</h3></div>")
.arg(tr("Cross references"));
}
// qWarning("setting crossref %s", data.latin1());
CSwordBackend::DisplayOptions dispOpts;
dispOpts.lineBreaks = false;
dispOpts.verseNumbers = true;
CSwordBackend::FilterOptions filterOpts;
filterOpts.headings = false;
filterOpts.strongNumbers = false;
filterOpts.morphTags = false;
filterOpts.lemmas = false;
filterOpts.footnotes = false;
filterOpts.scriptureReferences = false;
CrossRefRendering renderer(dispOpts, filterOpts);
CTextRendering::KeyTree tree;
// const bool isBible = true;
CSwordModuleInfo* module = CBTConfig::get
(CBTConfig::standardBible);
//a prefixed module gives the module to look into
QRegExp re("^[^ ]+:");
// re.setMinimal(true);
int pos = re.indexIn(data);
if (pos != -1) {
pos += re.matchedLength()-1;
}
if (pos > 0) {
const QString moduleName = data.left(pos);
// qWarning("found module %s", moduleName.latin1());
module = CPointers::backend()->findModuleByName(moduleName);
if (!module) {
module = CBTConfig::get
(CBTConfig::standardBible);
}
// Q_ASSERT(module);
}
//Q_ASSERT(module); //why? the existense of the module is tested later
CTextRendering::KeyTreeItem::Settings settings (
false,
CTextRendering::KeyTreeItem::Settings::CompleteShort
);
if (module && (module->type() == CSwordModuleInfo::Bible)) {
VerseKey vk;
sword::ListKey refs = vk.ParseVerseList((const char*)data.mid((pos == -1) ? 0 : pos+1).toUtf8(), "Gen 1:1", true);
for (int i = 0; i < refs.Count(); ++i) {
SWKey* key = refs.getElement(i);
Q_ASSERT(key);
VerseKey* vk = dynamic_cast<VerseKey*>(key);
CTextRendering::KeyTreeItem* itm = (CTextRendering::KeyTreeItem*)0; //explicit conversion for MS VS
if (vk && vk->isBoundSet()) { //render a range of keys
itm = new CTextRendering::KeyTreeItem(
QString::fromUtf8(vk->LowerBound().getText()),
QString::fromUtf8(vk->UpperBound().getText()),
module,
settings
);
}
else {
itm = new CTextRendering::KeyTreeItem(
QString::fromUtf8(key->getText()),
QString::fromUtf8(key->getText()),
module,
settings
);
}
Q_ASSERT(itm);
tree.append( itm );
}
}
else if (module) {
CTextRendering::KeyTreeItem* itm = new CTextRendering::KeyTreeItem(
data.mid((pos == -1) ? 0 : pos+1),
module,
settings
);
tree.append( itm );
}
// qWarning("rendered the tree: %s", renderer.renderKeyTree(tree).latin1());
//spanns containing rtl text need dir=rtl on their parent tag to be aligned properly
QString lang = "en"; // default english
if (module)
lang = module->language()->abbrev();
return QString("<div class=\"crossrefinfo\" lang=\"%1\"><h3>%2</h3><div class=\"para\" dir=\"%3\">%4</div></div>")
//.........这里部分代码省略.........
示例3: 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;
}