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


C++ XMLAttribute::name方法代码示例

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


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

示例1: proceedNode

bool Parser::proceedNode(Node* node, rapidxml::xml_node<>* xml_node)
{
	if (node && xml_node)
	{
		// Check required attributes
		for (std::map<std::string, bool>::const_iterator it = node->getAttributes().begin(); it != node->getAttributes().end(); ++it)
		{
			XMLAttribute* attr = xml_node->first_attribute(it->first.c_str());

			if (attr == NULL && it->second)
			{
				std::cout << "Error: Attribute `" << it->first << "` in node `" << node->getName() << "` is required." << std::endl;
				return false;
			}
		}

		// Check unsupported attributes
		for (XMLAttribute* attr = xml_node->first_attribute(); attr; attr = attr->next_attribute())
		{
			if (!node->hasAttribute(attr->name()))
				std::cout << "Warning: Attribute `" << attr->name() << "` in node `" << node->getName() << "` not supported." << std::endl;
		}

		// Node callback
		if (node->getName().compare(xml_node->name()) == 0)
			(*node)(xml_node);

		// Proceed sibling nodes
		XMLNode* sibling = xml_node->next_sibling();
		if (sibling && sibling->name())
		{
			if (node->hasSibling(sibling->name()))
			{
				if (!this->proceedNode(node->getSibling(sibling->name()), sibling))
					return false;
			}
			else
				std::cout << "Warning: Sibling `" << sibling->name() << "` of `" << node->getName() << "` not supported." << std::endl;
		}

		// Proceed child nodes
		XMLNode* child = xml_node->first_node();
		if (child && child->name())
		{
			if (node->hasChild(child->name()))
			{
				if (!this->proceedNode(node->getChild(child->name()), child))
					return false;
			}
			else
				std::cout << "Warning: Child `" << child->name() << "` of `" << node->getName() << "` not supported." << std::endl;
		}
	}
	return true;
}
开发者ID:Inozuma,项目名称:SkinEngine,代码行数:55,代码来源:Parser.cpp

示例2: getXMLTypeAttribute

std::string getXMLTypeAttribute(const XMLNode& node)
{
	if (rapidxml::count_attributes(const_cast<XMLNode*>(&node)) != 1)
		raiseXMLException(node, "Expected 1 attribute");

	XMLAttribute* attr = node.first_attribute();
	if (strcmp(attr->name(), "type"))
		raiseXMLException(node, "Missing \"type\" attribute");

	return std::string(attr->value());
}
开发者ID:dsmo7206,项目名称:genesis,代码行数:11,代码来源:xml.cpp

示例3: buildFromXMLNode

Shape* Shape::buildFromXMLNode(XMLNode& node)
{
	if (rapidxml::count_attributes(&node) != 1)
		raiseXMLException(node, "Expected 1 attribute");

	XMLAttribute* attr = node.first_attribute();
	if (strcmp(attr->name(), "type"))
		raiseXMLException(node, "Missing \"type\" attribute");

	const std::string type(attr->value());

	if (type == "Planet")
		return Planet::buildFromXMLNode(node);
	else if (type == "Star")
		return Star::buildFromXMLNode(node);

	raiseXMLException(node, std::string("Invalid type: ") + type);
	return nullptr; // Keep compiler happy
}
开发者ID:dsmo7206,项目名称:genesis,代码行数:19,代码来源:shapes.cpp


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