本文整理汇总了C++中XMLTag::getAttributeNames方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLTag::getAttributeNames方法的具体用法?C++ XMLTag::getAttributeNames怎么用?C++ XMLTag::getAttributeNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLTag
的用法示例。
在下文中一共展示了XMLTag::getAttributeNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
//.........这里部分代码省略.........
示例2: 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;
}