本文整理汇总了C++中pugi::xml_node::append_copy方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::append_copy方法的具体用法?C++ xml_node::append_copy怎么用?C++ xml_node::append_copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::append_copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppendDocumentCopy
void AppendDocumentCopy(pugi::xml_node& target, pugi::xml_document& doc) {
auto doc_children = doc.children();
for(auto doc_child : doc_children) {
target.append_copy(doc_child);
}
}
示例2: mergeNodes
void mergeNodes(pugi::xml_node toNode, pugi::xml_node& fromNode)
{
// Base case = both nodes are text nodes
pugi::xml_text fromNodeText = fromNode.text();
pugi::xml_text toNodeText = toNode.text();
if (fromNodeText && toNodeText) {
SBLog::info() << "Overwriting template value of \"" << toNode.name() << "\" from \"" << toNodeText.get() << "\" to \"" << fromNodeText.get() << "\"." << std::endl;
toNodeText.set(fromNodeText.get());
return;
}
// Calculate number of children in toNode
unsigned maxDistance = std::distance(toNode.begin(), toNode.end());
// Merge children
for (pugi::xml_node fromNodeChild = fromNode.first_child(); fromNodeChild; fromNodeChild = fromNodeChild.next_sibling()) {
// Find appropriate merge point
pugi::xml_node toNodeChild = findSimilarNode(fromNodeChild, toNode, maxDistance);
if (toNodeChild) {
mergeNodes(toNodeChild, fromNodeChild);
} else {
toNode.append_copy(fromNodeChild);
}
}
// Erase fromNode
removeNode(fromNode);
}
示例3: getAddressMappingResult
int VR_DataAccessorNaviCN::getAddressMappingResult(pugi::xml_node &firstItem, pugi::xml_node &itemsNode, std::string &mappingType)
{
int count = 0;
VR_MappingTypeCN firstResultType = VR_MappingTypeCN::EMPTY;
pugi::xml_node itemNodeTemplate = itemsNode.first_child();
for (pugi::xml_node itemNode = firstItem; !itemNode.empty(); itemNode = itemNode.next_sibling()) {
pugi::xml_node itemAddressNode = itemNode.first_child();
std::string zone = itemAddressNode.child(VR_MSG_NAVI_ZONE).text().as_string();
std::string city = itemAddressNode.child(VR_MSG_NAVI_CITY).text().as_string();
std::string district = itemAddressNode.child(VR_MSG_NAVI_DISTRICT).text().as_string();
std::string street = itemAddressNode.child(VR_MSG_NAVI_STREET).text().as_string();
std::string streetBody = itemAddressNode.child(VR_MSG_NAVI_STREET_BODY).text().as_string();
std::string houseNumber = itemAddressNode.child(VR_MSG_NAVI_HOUSE_NUMBER).text().as_string();
VR_MappingTypeCN currentType = VR_MappingTypeCN::EMPTY;
if (!zone.empty()) {
currentType = VR_MappingTypeCN::TILL_STATE;
if (!street.empty()) {
currentType = VR_MappingTypeCN::TILL_STREET;
if (!houseNumber.empty()) {
currentType = VR_MappingTypeCN::FULL;
}
}
else {
if (!district.empty()) {
currentType = VR_MappingTypeCN::TILL_DISTRICT;
}
else {
if (!city.empty()) {
currentType = VR_MappingTypeCN::TILL_CITY;
}
}
}
}
if (VR_MappingTypeCN::EMPTY == firstResultType) {
if (VR_MappingTypeCN::EMPTY == currentType) {
return count;
}
firstResultType = currentType;
}
if (firstResultType != currentType) {
continue;
}
pugi::xml_node addressNode = itemsNode.append_copy(itemNodeTemplate).child(VR_MSG_NAVI_ADDRESS_ID);
switch (firstResultType) {
case VR_MappingTypeCN::FULL:
addressNode.child(VR_MSG_NAVI_HOUSE_NUMBER).text().set(houseNumber.c_str());
// need add stret info to addressNode
case VR_MappingTypeCN::TILL_STREET:
addressNode.child(VR_MSG_NAVI_STREET).text().set(street.c_str());
addressNode.child(VR_MSG_NAVI_STREET_BODY).text().set(streetBody.c_str());
// need add district info to addressNode
case VR_MappingTypeCN::TILL_DISTRICT:
addressNode.child(VR_MSG_NAVI_DISTRICT).text().set(district.c_str());
// need add city info to addressNode
case VR_MappingTypeCN::TILL_CITY:
addressNode.child(VR_MSG_NAVI_CITY).text().set(city.c_str());
// need add state info to addressNode
case VR_MappingTypeCN::TILL_STATE:
addressNode.child(VR_MSG_NAVI_ZONE).text().set(zone.c_str());
break;
default:
break;
}
++count;
}
// remove the itemNodeTemplate node
itemsNode.remove_child(itemsNode.first_child());
// get mappingType
switch (firstResultType) {
case VR_MappingTypeCN::FULL:
mappingType = VR_MSG_RESPONSE_ADDRESS_MAPPING_TYPE_FULL;
break;
case VR_MappingTypeCN::TILL_STREET:
mappingType = VR_MSG_RESPONSE_ADDRESS_MAPPING_TYPE_TILL_STREET;
break;
case VR_MappingTypeCN::TILL_DISTRICT:
mappingType = VR_MSG_RESPONSE_ADDRESS_MAPPING_TYPE_TILL_DISTRICT;
break;
case VR_MappingTypeCN::TILL_CITY:
mappingType = VR_MSG_RESPONSE_ADDRESS_MAPPING_TYPE_TILL_CITY;
break;
case VR_MappingTypeCN::TILL_STATE:
mappingType = VR_MSG_RESPONSE_ADDRESS_MAPPING_TYPE_TILL_STATE;
break;
default:
break;
}
return count;
}