当前位置: 首页>>代码示例>>C++>>正文


C++ XMLNode::ParseDeep方法代码示例

本文整理汇总了C++中XMLNode::ParseDeep方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLNode::ParseDeep方法的具体用法?C++ XMLNode::ParseDeep怎么用?C++ XMLNode::ParseDeep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLNode的用法示例。


在下文中一共展示了XMLNode::ParseDeep方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ParseDeep

	char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
	{
		// This is a recursive method, but thinking about it "at the current level"
		// it is a pretty simple flat list:
		//		<foo/>
		//		<!-- comment -->
		//
		// With a special case:
		//		<foo>
		//		</foo>
		//		<!-- comment -->
		//
		// Where the closing element (/foo) *must* be the next thing after the opening
		// element, and the names must match. BUT the tricky bit is that the closing
		// element will be read by the child.
		//
		// 'endTag' is the end tag for this node, it is returned by a call to a child.
		// 'parentEnd' is the end tag for the parent, which is filled in and returned.

		while( p && *p ) {
			XMLNode* node = 0;

			p = _document->Identify( p, &node );
			if ( p == 0 || node == 0 ) {
				break;
			}

			StrPair endTag;
			p = node->ParseDeep( p, &endTag );
			if ( !p ) {
				DELETE_NODE( node );
				node = 0;
				if ( !_document->Error() ) {
					_document->SetError( XML_ERROR_PARSING, 0, 0 );
				}
				break;
			}

			// We read the end tag. Return it to the parent.
			if ( node->ToElement() && node->ToElement()->ClosingType() == XMLElement::CLOSING ) {
				if ( parentEnd ) {
					*parentEnd = static_cast<XMLElement*>(node)->_value;
				}
				node->_memPool->SetTracked();	// created and then immediately deleted.
				DELETE_NODE( node );
				return p;
			}

			// Handle an end tag returned to this level.
			// And handle a bunch of annoying errors.
			XMLElement* ele = node->ToElement();
			if ( ele ) {
				if ( endTag.Empty() && ele->ClosingType() == XMLElement::OPEN ) {
					_document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
					p = 0;
				}
				else if ( !endTag.Empty() && ele->ClosingType() != XMLElement::OPEN ) {
					_document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
					p = 0;
				}
				else if ( !endTag.Empty() ) {
					if ( !XMLUtil::StringEqual( endTag.GetStr(), node->Value() )) {
						_document->SetError( XML_ERROR_MISMATCHED_ELEMENT, node->Value(), 0 );
						p = 0;
					}
				}
			}
			if ( p == 0 ) {
				DELETE_NODE( node );
				node = 0;
			}
			if ( node ) {
				this->InsertEndChild( node );
			}
		}
		return 0;
	}
开发者ID:dominik-uebele,项目名称:E1,代码行数:77,代码来源:tinyxml2.cpp


注:本文中的XMLNode::ParseDeep方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。