本文整理汇总了C++中ArchiveTreeNode::merge方法的典型用法代码示例。如果您正苦于以下问题:C++ ArchiveTreeNode::merge方法的具体用法?C++ ArchiveTreeNode::merge怎么用?C++ ArchiveTreeNode::merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArchiveTreeNode
的用法示例。
在下文中一共展示了ArchiveTreeNode::merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge
/* ArchiveTreeNode::merge
* Merges [node] with this node. Entries within [node] are added
* at [position] within this node. Returns false if [node] is invalid,
* true otherwise
*******************************************************************/
bool ArchiveTreeNode::merge(ArchiveTreeNode* node, unsigned position, int state)
{
// Check node was given to merge
if (!node)
return false;
// Merge entries
for (unsigned a = 0; a < node->numEntries(); a++)
{
if (node->getEntry(a))
{
string name = Misc::lumpNameToFileName(node->getEntry(a)->getName());
node->getEntry(a)->setName(name);
}
ArchiveEntry* nentry = new ArchiveEntry(*(node->getEntry(a)));
addEntry(nentry, position);
nentry->setState(state);
if (position < entries.size())
position++;
}
// Merge subdirectories
for (unsigned a = 0; a < node->nChildren(); a++)
{
ArchiveTreeNode* child = (ArchiveTreeNode*)STreeNode::addChild(node->getChild(a)->getName());
child->merge((ArchiveTreeNode*)node->getChild(a));
child->getDirEntry()->setState(state);
}
return true;
}
示例2: doUndo
bool doUndo()
{
if (created)
return archive->removeDir(path);
else
{
// Create directory
ArchiveTreeNode* dir = archive->createDir(path);
// Restore entries/subdirs if needed
if (dir && cb_tree)
dir->merge(cb_tree->getTree(), 0, 0);
dir->getDirEntry()->setState(0);
return !!dir;
}
}