本文整理汇总了C++中XMLNode::AddText方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLNode::AddText方法的具体用法?C++ XMLNode::AddText怎么用?C++ XMLNode::AddText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLNode
的用法示例。
在下文中一共展示了XMLNode::AddText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
/**
* Recursively parse an XML element.
*/
static bool
XML::ParseXMLElement(XMLNode &node, Parser *pXML)
{
bool is_declaration;
const TCHAR *text = nullptr;
XMLNode *pNew;
enum Status status; // inside or outside a tag
enum Attrib attrib = eAttribName;
/* the name of the attribute that is currently being */
tstring attribute_name;
assert(pXML);
// If this is the first call to the function
if (pXML->nFirst) {
// Assume we are outside of a tag definition
pXML->nFirst = false;
status = eOutsideTag;
} else {
// If this is not the first call then we should only be called when inside a tag.
status = eInsideTag;
}
// Iterate through the tokens in the document
while (true) {
// Obtain the next token
NextToken token = GetNextToken(pXML);
if (gcc_unlikely(token.type == eTokenError))
return false;
// Check the current status
switch (status) {
// If we are outside of a tag definition
case eOutsideTag:
// Check what type of token we obtained
switch (token.type) {
// If we have found text or quoted text
case eTokenText:
case eTokenQuotedText:
case eTokenEquals:
if (text == nullptr)
text = token.pStr;
break;
// If we found a start tag '<' and declarations '<?'
case eTokenTagStart:
case eTokenDeclaration:
// Cache whether this new element is a declaration or not
is_declaration = token.type == eTokenDeclaration;
// If we have node text then add this to the element
if (text != nullptr) {
size_t length = StripRight(text, token.pStr - text);
node.AddText(text, length);
text = nullptr;
}
// Find the name of the tag
token = GetNextToken(pXML);
// Return an error if we couldn't obtain the next token or
// it wasnt text
if (token.type != eTokenText) {
pXML->error = eXMLErrorMissingTagName;
return false;
}
// If the name of the new element differs from the name of
// the current element we need to add the new element to
// the current one and recurse
pNew = &node.AddChild(token.pStr, token.length,
is_declaration);
while (true) {
// Callself to process the new node. If we return
// FALSE this means we dont have any more
// processing to do...
if (!ParseXMLElement(*pNew, pXML)) {
return false;
} else {
// If the call to recurse this function
// evented in a end tag specified in XML then
// we need to unwind the calls to this
// function until we find the appropriate node
// (the element name and end tag name must
// match)
if (pXML->cbEndTag) {
// If we are back at the root node then we
// have an unmatched end tag
if (node.GetName() == nullptr) {
pXML->error = eXMLErrorUnmatchedEndTag;
return false;
}
//.........这里部分代码省略.........