本文整理汇总了C++中XMLTag::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLTag::reset方法的具体用法?C++ XMLTag::reset怎么用?C++ XMLTag::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLTag
的用法示例。
在下文中一共展示了XMLTag::reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNext
int XMLParser::getNext(XMLTag& tag)
{
wchar ch;
int32_t start, end;
tag.reset();
// If there's nothing left, exit.
if (atEnd()) {
return XMLParser::kEndOfDocument;
}
// R41
// If the ignore whitespace flag is on, don't produce
// all-whitespace text nodes.
if (m_ignoreWhite)
{
if (!skipWhiteSpace())
return XMLParser::kEndOfDocument;
}
// end R41
// If it starts with <, it's an XML element.
// If it doesn't, it must be a text element.
start = m_pos;
ch = m_str[m_pos];
if (ch != '<')
{
// Treat it as text. Scan up to the next < or until EOF.
m_pos = m_str->indexOfCharCode('<', m_pos + 1);
if (m_pos < 0)
m_pos = m_str->length();
tag.text = unescape(start, m_pos, false);
// Condense whitespace if desired
if (m_ignoreWhite && m_condenseWhite)
tag.text = _condenseWhitespace(tag.text);
tag.nodeType = XMLTag::kTextNodeType;
return XMLParser::kNoError;
}
// Is this a <?xml> declaration?
start = m_pos;
if (m_str->matchesLatin1("<?xml ", 6, start))
{
end = m_str->indexOfLatin1("?>", 2, start + 6);
if (end >= 0)
{
// We have the end of the XML declaration
// [email protected] changed to not return <?...?> parts
tag.text = m_str->substring(start + 2, end);
m_pos = end + 2;
tag.nodeType = XMLTag::kXMLDeclaration;
return XMLParser::kNoError;
}
return XMLParser::kUnterminatedXMLDeclaration;
}
// Is this a <!DOCTYPE> declaration?
if (m_str->matchesLatin1("<!DOCTYPE", 8, start))
{
// Scan forward for '>', but check for embedded <>
int32_t depth = 0;
end = start + 1;
while (!atEnd())
{
ch = m_str[end++];
if (ch == '<')
depth++;
else if (ch == '>')
{
if (!depth)
{
// We've reached the end of the DOCTYPE.
tag.text = m_str->substring(start, end - 1);
tag.nodeType = XMLTag::kDocTypeDeclaration;
m_pos = end;
return XMLParser::kNoError;
}
depth--;
}
m_pos = end;
}
return XMLParser::kUnterminatedDocTypeDeclaration;
}
// Is this a CDATA section?
if (m_str->matchesLatin1("<![CDATA[", 9, start))
{
start += 9;
end = m_str->indexOfLatin1("]]>", 3, start);
if (end >= 0)
{
// We have the end of the CDATA section.
tag.text = m_str->substring(start, end);
tag.nodeType = XMLTag::kCDataSection;
m_pos = end + 3;
return XMLParser::kNoError;
}
//.........这里部分代码省略.........