本文整理汇总了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;
}
示例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());
}
示例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
}