本文整理汇总了C++中pugi::xml_node::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ xml_node::parent方法的具体用法?C++ xml_node::parent怎么用?C++ xml_node::parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pugi::xml_node
的用法示例。
在下文中一共展示了xml_node::parent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: path
std::string xvnu::path(const pugi::xml_node& node)
{
// Get the string for this node
string str = "(" + std::to_string(xvnu::index(node)) + ")" + string(node.name());
// If the node has a parent, recursivly call this function, adding this nodes location to the end of the string
if(node.parent() && node.parent().type() != xml_node_type::node_document)
return xvnu::path(node.parent()) + " " + str;
// If the node has no parent, return and empty string and end the recursive loop
else
return string();
}
示例2: writeProjectItems
void VCProject::writeProjectItems(pugi::xml_node& node) const
{
pugi::xml_node tempNode = node.parent().append_child("Temp");
for (auto item : m_items) {
item->writeDescription(tempNode);
}
mergeNodes(node, tempNode);
}
示例3: writeProperties
void VCProjectConfiguration::writeProperties(pugi::xml_node& proto) const
{
// Insert nodes after the bookmark
pugi::xml_node parent = proto.parent();
pugi::xml_node prevSibling = proto;
for (auto platform : m_platforms) {
std::string configCond = getVSConfigurationPlatformCond(m_name, platform.first);
pugi::xml_node configPropsGroup = parent.insert_copy_before(proto, prevSibling);
configPropsGroup.append_attribute("Condition") = configCond.c_str();
pugi::xml_node tempNode = proto.parent().append_child("Temp");
writePropertiesMap(platform.second->getProperties(), tempNode);
mergeNodes(configPropsGroup, tempNode);
prevSibling = configPropsGroup;
}
}
示例4: writeBuildExtensionTargets
void VCProject::writeBuildExtensionTargets(pugi::xml_node& node) const
{
pugi::xml_node tempNode = node.parent().append_child("Temp");
for (auto ext : m_buildExtensions) {
if (sb_fextension(ext) == "targets") {
pugi::xml_node propsFile = tempNode.append_child("Import");
propsFile.append_attribute("Project") = ext.c_str();
}
}
mergeNodes(node, tempNode);
}
示例5: if
OMRGCObjectType
GCConfigTest::parseObjectType(pugi::xml_node node)
{
OMRPORT_ACCESS_FROM_OMRPORT(gcTestEnv->portLib);
const char *namePrefixStr = node.attribute("namePrefix").value();
const char *typeStr = node.attribute("type").value();
const char *parentStr = node.parent().name();
const char *parentTypeStr = node.parent().attribute("type").value();
OMRGCObjectType objType = INVALID;
if (0 == strcmp(typeStr, "root")) {
if (0 == strcmp(parentStr, "allocation")) {
objType = ROOT;
} else {
omrtty_printf("%s:%d Invalid XML input: root object %s can not be child of other object!\n", __FILE__, __LINE__, namePrefixStr);
}
} else if (0 == strcmp(typeStr, "normal")) {
if ((0 == strcmp(parentTypeStr, "root")) || (0 == strcmp(parentTypeStr, "normal"))) {
objType = NORMAL;
} else {
omrtty_printf("%s:%d Invalid XML input: normal object %s has to be child of root or normal object!\n", __FILE__, __LINE__, namePrefixStr);
}
} else if (0 == strcmp(typeStr, "garbage")) {
if (0 == strcmp(parentStr, "allocation")) {
objType = GARBAGE_ROOT;
} else if ((0 == strcmp(parentTypeStr, "normal")) || (0 == strcmp(parentTypeStr, "root"))){
objType = GARBAGE_TOP;
} else if (0 == strcmp(parentTypeStr, "garbage")) {
objType = GARBAGE_CHILD;
} else {
omrtty_printf("%s:%d Invalid XML input: garbage object %s has to be child of root, normal or allocation node!\n", __FILE__, __LINE__, namePrefixStr);
}
} else {
omrtty_printf("%s:%d Invalid XML input: object %s type should be root, normal or garbage .\n", __FILE__, __LINE__, namePrefixStr);
}
return objType;
}
示例6: writeSharedProjects
void VCProject::writeSharedProjects(pugi::xml_node& node) const
{
std::string projectPath = getPath();
std::string projectDir = sb_dirname(projectPath);
pugi::xml_node tempNode = node.parent().append_child("Temp");
for (auto sproj : m_sharedProjects) {
std::string sprojRelativePath = getRelativePath(projectDir, sproj->getPath());
pugi::xml_node importProj = tempNode.append_child("Import");
importProj.append_attribute("Project") = sprojRelativePath.c_str();
importProj.append_attribute("Label") = "Shared";
}
mergeNodes(node, tempNode);
}
示例7: writePropertySheets
void VCProjectConfiguration::writePropertySheets(pugi::xml_node& proto) const
{
// Insert nodes after the bookmark
pugi::xml_node parent = proto.parent();
pugi::xml_node prevSibling = proto;
for (auto platform : m_platforms) {
std::string configCond = getVSConfigurationPlatformCond(m_name, platform.first);
pugi::xml_node importGroup = parent.insert_copy_before(proto, prevSibling);
importGroup.append_attribute("Condition") = configCond.c_str();
prevSibling = importGroup;
}
}
示例8: index
int xvnu::index(const pugi::xml_node& node)
{
// If node has a parent
if(node.parent())
{
// Iterate over all the parents children, incrementing index
int idx = 0;
for(auto& child : node.parent())
{
// If the child node matches the node parameter, reutrn the index of the node
if(child == node)
return idx;
// If it is not a match, incremement the counter and continue
else
idx++;
}
// Should never reach here
return -1;
}
// If the node has no parent return -1
else
return -1;
}
示例9: writeFilterItemDescriptions
void VCProject::writeFilterItemDescriptions(pugi::xml_node& node) const
{
pugi::xml_node tempNode = node.parent().append_child("Temp");
for (auto item : m_items) {
std::string itemName = item->getItemName();
std::string includePath = item->getIncludePath();
std::string filterPath = item->getFilterPath();
pugi::xml_node fItem = tempNode.append_child(itemName.c_str());
fItem.append_attribute("Include") = includePath.c_str();
if (!filterPath.empty() && filterPath != ".") {
appendNodeWithText(fItem, "Filter", winPath(filterPath));
}
}
mergeNodes(node, tempNode);
}
示例10: LoadChildren
BOOL CDuiListBox::LoadChildren(pugi::xml_node xmlNode)
{
if(!xmlNode) return TRUE;
pugi::xml_node xmlParent=xmlNode.parent();
pugi::xml_node xmlItem=xmlParent.child("items");
while(xmlItem)
{
LPLBITEM pItemObj = new LBITEM;
LoadItemAttribute(xmlItem, pItemObj);
InsertItem(-1, pItemObj);
xmlItem = xmlItem.next_sibling();
}
int nSelItem=xmlParent.attribute("cursel").as_int(-1);
SetCurSel(nSelItem);
return TRUE;
}
示例11: LoadChildren
BOOL CDuiSplitWnd::LoadChildren( pugi::xml_node xmlNode )
{
if(!xmlNode) return FALSE;
pugi::xml_node xmlParent=xmlNode.parent();
DUIASSERT(xmlParent);
pugi::xml_node xmlPane=xmlParent.child("pane");
while(xmlPane)
{
CDuiSplitPane *pPane=new CDuiSplitPane();
InsertChild(pPane);
if(pPane->Load(xmlPane))
{
pPane->AddRef();
m_arrPane.Add(pPane);
}
xmlPane=xmlPane.next_sibling("pane");
}
return TRUE;
}
示例12: writeFilterDescriptions
void VCProject::writeFilterDescriptions(pugi::xml_node& node) const
{
StringSet filters;
for (auto item : m_items) {
recordFilterPath(item->getFilterPath(), filters);
}
pugi::xml_node tempNode = node.parent().append_child("Temp");
for (auto filter : filters) {
// Generate a unique id
std::string id = sole::uuid4().str();
// Fix up the filter path to be Windows-style
std::string winFilterPath = winPath(filter);
// Create a filter description node
pugi::xml_node filterDesc = tempNode.append_child("Filter");
filterDesc.append_attribute("Include") = winFilterPath.c_str();
appendNodeWithText(filterDesc, "UniqueIdentifier", formatVSGUID(id));
}
mergeNodes(node, tempNode);
}
示例13: LoadChildren
BOOL CDuiItemBox::LoadChildren(pugi::xml_node xmlNode)
{
if(!xmlNode) return FALSE;
RemoveAllItems();
pugi::xml_node xmlParent=xmlNode.parent();
pugi::xml_node xmlItem=xmlParent.child("item");
while(xmlItem)
{
CDuiPanel *pChild=new CDuiPanel;
InsertChild(pChild);
pChild->Load(xmlItem);
pChild->SetVisible(TRUE);
pChild->SetFixSize(m_nItemWid,m_nItemHei);
xmlItem=xmlItem.next_sibling("item");
}
return TRUE;
}
示例14: sizeof
int32_t
GCConfigTest::processObjNode(pugi::xml_node node, const char *namePrefixStr, OMRGCObjectType objType, AttributeElem *numOfFieldsElem, AttributeElem *breadthElem, int32_t depth)
{
OMRPORT_ACCESS_FROM_OMRPORT(gcTestEnv->portLib);
int32_t rt = 1;
int32_t numOfParents = 0;
/* Create objects and store them in the root table or the slot object based on objType. */
if ((ROOT == objType) || (GARBAGE_ROOT == objType)) {
for (int32_t i = 0; i < breadthElem->value; i++) {
uintptr_t sizeCalculated = numOfFieldsElem->value * sizeof(fomrobject_t) + sizeof(uintptr_t);
ObjectEntry *objectEntry = createObject(namePrefixStr, objType, 0, i, sizeCalculated);
if (NULL == objectEntry) {
goto done;
}
numOfFieldsElem = numOfFieldsElem->linkNext;
/* Add object to root hash table. If it's the root of the garbage tree, temporarily keep it as root for allocating
* the rest of the tree. Remove it from the root set after the entire garbage tree is allocated.*/
RootEntry rEntry;
rEntry.name = objectEntry->name;
rEntry.rootPtr = objectEntry->objPtr;
if (NULL == hashTableAdd(exampleVM->rootTable, &rEntry)) {
omrtty_printf("%s:%d Failed to add new root entry to root table!\n", __FILE__, __LINE__);
goto done;
}
/* insert garbage per node */
if ((ROOT == objType) && (0 == strcmp(gp.frequency, "perObject"))) {
int32_t grt = insertGarbage();
OMRGCTEST_CHECK_RT(grt);
}
}
} else if ((NORMAL == objType) || (GARBAGE_TOP == objType) || (GARBAGE_CHILD == objType)) {
char parentName[MAX_NAME_LENGTH];
omrstr_printf(parentName, MAX_NAME_LENGTH, "%s_%d_%d", node.parent().attribute("namePrefix").value(), 0, 0);
for (int32_t i = 0; i < breadthElem->value; i++) {
uintptr_t sizeCalculated = numOfFieldsElem->value * sizeof(fomrobject_t) + sizeof(uintptr_t);
ObjectEntry *childEntry = createObject(namePrefixStr, objType, 0, i, sizeCalculated);
if (NULL == childEntry) {
goto done;
}
ObjectEntry *parentEntry = find(parentName);
if (NULL == parentEntry) {
omrtty_printf("%s:%d Could not find object %s in hash table.\n", __FILE__, __LINE__, parentName);
goto done;
}
if (0 != attachChildEntry(parentEntry, childEntry)) {
goto done;
}
numOfFieldsElem = numOfFieldsElem->linkNext;
/* insert garbage per node */
if ((NORMAL == objType) && (0 == strcmp(gp.frequency, "perObject"))) {
int32_t grt = insertGarbage();
OMRGCTEST_CHECK_RT(grt);
}
}
} else {
goto done;
}
/* Create the rest of the tree, if any, defined with depth. First, we set the child object with correct objType. */
if (ROOT == objType) {
objType = NORMAL;
} else if ((GARBAGE_TOP == objType) || (GARBAGE_ROOT == objType)) {
objType = GARBAGE_CHILD;
}
numOfParents = breadthElem->value;
breadthElem = breadthElem->linkNext;
for (int32_t i = 1; i < depth; i++) {
int32_t nthInRow = 0;
for (int32_t j = 0; j < numOfParents; j++) {
char parentName[MAX_NAME_LENGTH];
omrstr_printf(parentName, sizeof(parentName), "%s_%d_%d", namePrefixStr, (i - 1), j);
for (int32_t k = 0; k < breadthElem->value; k++) {
uintptr_t sizeCalculated = sizeof(omrobjectptr_t) + numOfFieldsElem->value * sizeof(fomrobject_t);
ObjectEntry *childEntry = createObject(namePrefixStr, objType, i, nthInRow, sizeCalculated);
if (NULL == childEntry) {
goto done;
}
ObjectEntry *parentEntry = find(parentName);
if (NULL == parentEntry) {
omrtty_printf("%s:%d Could not find object %s in hash table.\n", __FILE__, __LINE__, parentName);
goto done;
}
if (0 != attachChildEntry(parentEntry, childEntry)) {
goto done;
}
numOfFieldsElem = numOfFieldsElem->linkNext;
nthInRow += 1;
/* insert garbage per node */
if ((NORMAL == objType) && (0 == strcmp(gp.frequency, "perObject"))) {
int32_t grt = insertGarbage();
OMRGCTEST_CHECK_RT(grt);
}
}
}
//.........这里部分代码省略.........
示例15: atoi
int32_t
GCConfigTest::allocationWalker(pugi::xml_node node)
{
OMRPORT_ACCESS_FROM_OMRVM(exampleVM->_omrVM);
int32_t rt = 0;
AttributeElem *numOfFieldsElem = NULL;
AttributeElem *breadthElem = NULL;
int32_t depth = 0;
OMRGCObjectType objType = INVALID;
const char *namePrefixStr = node.attribute("namePrefix").value();
const char *numOfFieldsStr = node.attribute("numOfFields").value();
const char *typeStr = node.attribute("type").value();
const char *breadthStr = node.attribute("breadth").value();
const char *depthStr = node.attribute("depth").value();
if (0 != strcmp(node.name(), "object")) {
/* allow non-object node nested inside allocation? */
goto done;
}
if ((0 == strcmp(namePrefixStr, "")) || (0 == strcmp(typeStr, "")) || (0 == strcmp(numOfFieldsStr, ""))) {
rt = 1;
omrtty_printf("%s:%d Invalid XML input: please specify namePrefix, type and numOfFields for object %s.\n", __FILE__, __LINE__, namePrefixStr);
goto done;
}
/* set default value for breadth and depth to 1 */
if (0 == strcmp(breadthStr, "")) {
breadthStr = "1";
}
if (0 == strcmp(depthStr, "")) {
depthStr = "1";
}
depth = atoi(depthStr);
objType = parseObjectType(node);
rt = parseAttribute(&numOfFieldsElem, numOfFieldsStr);
OMRGCTEST_CHECK_RT(rt)
rt = parseAttribute(&breadthElem, breadthStr);
OMRGCTEST_CHECK_RT(rt);
/* process current xml node, perform allocation for single object or object tree */
rt = processObjNode(node, namePrefixStr, objType, numOfFieldsElem, breadthElem, depth);
OMRGCTEST_CHECK_RT(rt);
/* only single object can contain nested child object */
if ((0 == strcmp(breadthStr, "1")) && (0 == strcmp(depthStr, "1"))) {
for (pugi::xml_node childNode = node.first_child(); childNode; childNode = childNode.next_sibling()) {
rt = allocationWalker(childNode);
OMRGCTEST_CHECK_RT(rt);
}
}
/* After the entire garbage tree is allocated, remove garbage root object from the root set
* or remove garbage top object from the slot of its parent object. */
if (GARBAGE_ROOT == objType) {
for (int32_t i = 0; i < breadthElem->value; i++) {
char objName[MAX_NAME_LENGTH];
omrstr_printf(objName, MAX_NAME_LENGTH, "%s_%d_%d", namePrefixStr, 0, i);
rt = removeObjectFromRootTable(objName);
OMRGCTEST_CHECK_RT(rt);
}
} else if (GARBAGE_TOP == objType) {
char parentName[MAX_NAME_LENGTH];
omrstr_printf(parentName, MAX_NAME_LENGTH, "%s_%d_%d", node.parent().attribute("namePrefix").value(), 0, 0);
ObjectEntry *parentEntry;
rt = objectTable.find(&parentEntry, parentName);
if (0 != rt) {
omrtty_printf("%s:%d Could not find object %s in hash table.\n", __FILE__, __LINE__, parentName);
goto done;
}
omrobjectptr_t parentPtr = parentEntry->objPtr;
for (int32_t i = 0; i < breadthElem->value; i++) {
char objName[MAX_NAME_LENGTH];
omrstr_printf(objName, MAX_NAME_LENGTH, "%s_%d_%d", namePrefixStr, 0, i);
rt = removeObjectFromParentSlot(objName, parentPtr);
OMRGCTEST_CHECK_RT(rt);
}
}
/* insert garbage per tree */
if ((0 == strcmp(gp.frequency, "perRootStruct")) && (ROOT == objType)){
rt = insertGarbage();
OMRGCTEST_CHECK_RT(rt);
}
done:
freeAttributeList(breadthElem);
freeAttributeList(numOfFieldsElem);
return rt;
}