本文整理汇总了C++中pugi::xml_document::first_element_by_path方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_document::first_element_by_path方法的具体用法?C++ xml_document::first_element_by_path怎么用?C++ xml_document::first_element_by_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_document
的用法示例。
在下文中一共展示了xml_document::first_element_by_path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertXIBToNib
void ConvertXIBToNib(FILE* fpOut, pugi::xml_document& doc) {
pugi::xml_node dataNode = doc.first_element_by_path("/archive/data");
XIBObject* root = new XIBObject();
root->ScanXIBNode(dataNode);
XIBObject::ParseAllXIBMembers();
XIBObject* Objects = root->FindMember("IBDocument.Objects");
XIBObject* objectRecords = Objects->FindMember("objectRecords");
XIBDictionary* properties = (XIBDictionary*)Objects->FindMember("flattenedProperties");
XIBObject* orderedObjects = objectRecords->FindMember("orderedObjects");
// Go through each ordered object to find replacements
for (memberList::iterator cur = orderedObjects->_members.begin(); cur != orderedObjects->_members.end(); cur++) {
XIBMember* curMember = *cur;
XIBObject* curObject = curMember->_obj;
if (strcmp(curObject->ClassName(), "IBObjectRecord") == 0) {
XIBObject* obj = curObject->FindMember("object");
if (obj) {
XIBObject* objectId = curObject->FindMember("objectID");
if (!objectId) {
objectId = curObject->FindMember("id");
}
int objId = objectId->intValue();
// Attempt to find any associated custom class name
char szPropName[255];
sprintf(szPropName, "%d.CustomClassName", objId);
const char* pClassName = obj->ClassName();
XIBObject* customName = properties->ObjectForKey(szPropName);
if (customName) {
const char* pCustomName = customName->stringValue();
obj->SetSwappedClassName(pCustomName);
}
for (memberList::iterator prop = properties->_members.begin(); prop != properties->_members.end(); prop++) {
char szMeta[255];
sprintf(szMeta, "%d.", objId);
if (strncmp(szMeta, (*prop)->_name, strlen(szMeta)) == 0) {
obj->AddMember(&(*prop)->_name[strlen(szMeta)], (*prop)->_obj);
}
}
}
}
}
// Create connections list
XIBArray* connections = new XIBArray();
XIBObject* connectionrecords = Objects->FindMember("connectionRecords");
for (memberList::iterator cur = connectionrecords->_members.begin(); cur != connectionrecords->_members.end(); cur++) {
XIBMember* curMember = *cur;
XIBObject* curObject = curMember->_obj;
if (strcmp(curObject->ClassName(), "IBConnectionRecord") == 0) {
XIBObject* obj = curObject->FindMember("connection");
if (obj) {
connections->AddMember(NULL, obj);
}
}
}
// Sort connection records alphabetically using stable, uh, bubble sort
for (;;) {
bool didSwap = false;
for (memberList::iterator cur = connections->_members.begin(); cur != connections->_members.end(); cur++) {
if ((cur + 1) == connections->_members.end())
break;
XIBMember* curMember = (*cur);
XIBMember* nextMember = (*(cur + 1));
if (curMember->_name != NULL)
continue;
// Event connections first
if (strcmp(curMember->_obj->_className, "IBCocoaTouchOutletConnection") == 0 &&
strcmp(nextMember->_obj->_className, "IBCocoaTouchEventConnection") == 0) {
*cur = nextMember;
*(cur + 1) = curMember;
didSwap = true;
continue;
}
if (strcmp(curMember->_obj->_className, nextMember->_obj->_className) == 0) {
const char* label1 = curMember->_obj->FindMember("label")->stringValue();
const char* label2 = nextMember->_obj->FindMember("label")->stringValue();
if (strcmp(label1, label2) > 0) {
*cur = nextMember;
*(cur + 1) = curMember;
didSwap = true;
}
}
}
//.........这里部分代码省略.........