本文整理汇总了C++中pugi::xml_node::last_child方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::last_child方法的具体用法?C++ xml_node::last_child怎么用?C++ xml_node::last_child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::last_child方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadNode
void Root::loadNode(int id, const pugi::xml_node &node) {
auto n = m_nodeMap[id];
if(!std::strcmp(node.attribute("entry").as_string(), "true"))
m_rootNode = n;
for(auto a = node.first_child(); ; a = a.next_sibling()) {
auto action = loadAction(a);
if(a == node.last_child()) break;
}
}
示例2: AddNode
void XMLFile::AddNode(const pugi::xml_node& patch, const pugi::xpath_node& original) const
{
// If pos is null, append or prepend add as a child, otherwise add before or after, the default is to append as a child
pugi::xml_attribute pos = patch.attribute("pos");
if (!pos || strlen(pos.value()) <= 0 || strcmp(pos.value(), "append") == 0)
{
pugi::xml_node::iterator start = patch.begin();
pugi::xml_node::iterator end = patch.end();
// There can not be two consecutive text nodes, so check to see if they need to be combined
// If they have been we can skip the first node of the nodes to add
if (CombineText(patch.first_child(), original.node().last_child(), false))
start++;
for (; start != end; start++)
original.node().append_copy(*start);
}
else if (strcmp(pos.value(), "prepend") == 0)
{
pugi::xml_node::iterator start = patch.begin();
pugi::xml_node::iterator end = patch.end();
// There can not be two consecutive text nodes, so check to see if they need to be combined
// If they have been we can skip the last node of the nodes to add
if (CombineText(patch.last_child(), original.node().first_child(), true))
end--;
pugi::xml_node pos = original.node().first_child();
for (; start != end; start++)
original.node().insert_copy_before(*start, pos);
}
else if (strcmp(pos.value(), "before") == 0)
{
pugi::xml_node::iterator start = patch.begin();
pugi::xml_node::iterator end = patch.end();
// There can not be two consecutive text nodes, so check to see if they need to be combined
// If they have been we can skip the first node of the nodes to add
if (CombineText(patch.first_child(), original.node().previous_sibling(), false))
start++;
// There can not be two consecutive text nodes, so check to see if they need to be combined
// If they have been we can skip the last node of the nodes to add
if (CombineText(patch.last_child(), original.node(), true))
end--;
for (; start != end; start++)
original.parent().insert_copy_before(*start, original.node());
}
else if (strcmp(pos.value(), "after") == 0)
{
pugi::xml_node::iterator start = patch.begin();
pugi::xml_node::iterator end = patch.end();
// There can not be two consecutive text nodes, so check to see if they need to be combined
// If they have been we can skip the first node of the nodes to add
if (CombineText(patch.first_child(), original.node(), false))
start++;
// There can not be two consecutive text nodes, so check to see if they need to be combined
// If they have been we can skip the last node of the nodes to add
if (CombineText(patch.last_child(), original.node().next_sibling(), true))
end--;
pugi::xml_node pos = original.node();
for (; start != end; start++)
pos = original.parent().insert_copy_after(*start, pos);
}
}