本文整理汇总了C++中DomNode::get_parent_node方法的典型用法代码示例。如果您正苦于以下问题:C++ DomNode::get_parent_node方法的具体用法?C++ DomNode::get_parent_node怎么用?C++ DomNode::get_parent_node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomNode
的用法示例。
在下文中一共展示了DomNode::get_parent_node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: destroy_resource
void XMLResourceDocument::destroy_resource(const std::string &resource_id)
{
std::map<std::string, XMLResourceNode>::iterator it;
it = impl->resources.find(resource_id);
if (it == impl->resources.end())
return;
DomNode cur = it->second.get_element();
impl->resources.erase(it);
DomNode parent = cur.get_parent_node();
while (!parent.is_null())
{
parent.remove_child(cur);
if (parent.has_child_nodes())
break;
cur = parent;
parent = parent.get_parent_node();
}
}
示例2: if
ResourceItem *TexturePacker::load_resource(Canvas &canvas, std::string &resource_id, Resource &resource, ResourceManager &resources)
{
ResourceItem *item = 0;
try
{
std::string type = resource.get_type();
if(type == "sprite")
{
item = load_sprite(canvas, resource_id, resource, resources);
}
else if(type == "image")
{
item = load_image(canvas, resource_id, resource, resources);
}
else
{
throw Exception(string_format("Resourcetype %1 is not supported", type));
}
}
catch(Exception ex)
{
item = new NotSupportedResourceItem(resource, ex.message);
}
// Find resource path by traversing parents
DomElement &dom_element = resource.get_element();
DomNode parent = dom_element.get_parent_node();
while (!parent.is_null())
{
DomElement parent_element = parent.to_element();
std::string parent_name = parent_element.get_attribute("name");
if(parent_name.length() > 0)
item->resource_path = string_format("%1/%2", parent_name, item->resource_path);
parent = parent.get_parent_node();
}
return item;
}