本文整理汇总了C++中tree::append_child方法的典型用法代码示例。如果您正苦于以下问题:C++ tree::append_child方法的具体用法?C++ tree::append_child怎么用?C++ tree::append_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tree
的用法示例。
在下文中一共展示了tree::append_child方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy_branch
/**
Copy for duplicating a branch
*/
void copy_branch(tree<AstNode>::iterator where, tree<AstNode>::iterator from, tree<AstNode>& tr_where)
{
if (tr_where.number_of_children(from) == 0) {
// simply add the node to it
tr_where.append_child(where, *from);
}
else {
where = tr_where.append_child(where, *from);
tree<AstNode>::sibling_iterator cter;
for (cter = tr_where.begin(from); cter != tr_where.end(from); ++cter) {
copy_branch(where, cter, tr_where);
}
}
}
示例2: treeFromJava
void treeFromJava(JNIEnv * env, const jobject & jnode, tree<J_NVItem>::iterator_base & it, const JMultiTreeNode & fields, tree<J_NVItem> & tre)
{
// LOGI("Enter %s %p\n",__FUNCTION__, &it);
//转换当前节点
fields.java2Cpp(env, jnode, *it);
//处理子节点
jobject childList = env->GetObjectField(jnode, fields.m_Childs_id);
jclass clsArrayList = env->FindClass(JCLSNAME_ArrayList);
jmethodID sizeList_mid = env->GetMethodID(clsArrayList, "size", "()I");
jmethodID getList_mid = env->GetMethodID(clsArrayList, "get", "(I)Ljava/lang/Object;");
int childCount = env->CallIntMethod(childList, sizeList_mid);
J_NVItem item;
for(int i = 0; i < childCount; i++)
{
jobject jchild = env->CallObjectMethod(childList, getList_mid, i);
tree<J_NVItem>::iterator_base itchild = tre.append_child(it, item);
treeFromJava(env, jchild, itchild, fields, tre);
env->DeleteLocalRef(jchild);
}
// LOGI("Leave %s %p\n",__FUNCTION__, &it);
}
示例3: AddItem
FILE_ITEM CFileTree::AddItem(char *absolutePath, unsigned char* handle)
{
FILE_ITEM item;
item.handle = handle;
item.bCached = false;
if (filesTree.empty()) {
item.path = new char[strlen(absolutePath) + 1];
strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
item.nPathLen = strlen(item.path);
filesTree.set_head(item);
topNode = filesTree.begin();
}
else {
std::string sPath(absolutePath);
tree_node_<FILE_ITEM>* parentNode = findParentNodeFromRootForPath(absolutePath);
std::string splittedPath = sPath.substr(sPath.find_last_of('\\') + 1);
item.path = new char[splittedPath.length() + 1];
strcpy_s(item.path, (splittedPath.length() + 1), splittedPath.c_str());
if (parentNode) {
filesTree.append_child(tree<FILE_ITEM>::iterator_base(parentNode), item);
} else {
//printf("Parent node found for %s", absolutePath);
}
}
DisplayTree(topNode.node, 0);
return item;
}
示例4: WeaveNet
void WeaveNet(SQcont<T> const &incont, tree<T> &outnet)
{
outnet.clear();
auto top(outnet.begin());
auto now(outnet.insert(top, *incont.cbegin()));
for(auto c = incont.cbegin()+1;c != incont.cend();++c)
now = outnet.append_child(now, *c);
}
示例5: WeaveNets
void WeaveNets(SQcont<SQcont<T> > &incont, tree<T> &outnet)
{
outnet.clear();
auto top(outnet.begin());
for(auto c = incont.begin();c != incont.end();++c){
if(c->size()){
auto now(outnet.insert(top, c->at(0)));
for(size_t num = 1;num < c->size();++num)
now = outnet.append_child(now, c->at(num));
} // End if
} // End c
}
示例6: insert_statement
/**
Insert a new statement.
- Create a new inner_statement_list
- Add the statement under it
*/
bool insert_statement(const tree<AstNode>::iterator& where, const tree<AstNode>::iterator& what, tree<AstNode>& tr)
{
if (where->getType() == "text" && where->getValue() == "$enter_the_new_statement") {
// rewind to the inner_statement_list
tree<AstNode>::iterator top = where;
do {
top = tr.parent(top);
} while (top->getType() != "inner_statement" && tr.child(top,0)->getType() != "statement");
top = tr.parent(top);
if (top->getType() != "inner_statement_list")
return false;
else {
top = tr.append_child(top, AstNode("inner_statement_list"));
top = tr.append_child(top, AstNode("inner_statement"));
if (what->getType() == "statement") {
top = tr.append_child(top, AstNode("statement"));
//cout << "Seems to be okay..." << endl;
move_branch(top, what, tr);
}
}
return true;
}
return false;
}
示例7: AddItem
FILE_ITEM CFileTree::AddItem(char *absolutePath, unsigned char* handle)
{
FILE_ITEM item;
item.handle = handle;
item.bCached = false;
// If the tree is empty just add the new path as node on the top level.
if (filesTree.empty()) {
item.path = new char[strlen(absolutePath) + 1];
strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
item.nPathLen = strlen(item.path);
filesTree.set_head(item);
topNode = filesTree.begin();
}
else {
// Check if the requested path belongs to an already registered parent node.
std::string sPath(absolutePath);
tree_node_<FILE_ITEM>* parentNode = findParentNodeFromRootForPath(absolutePath);
std::string splittedPath = _basename_932(sPath);
//printf("spl %s %s\n", splittedPath.c_str(), absolutePath);
item.path = new char[splittedPath.length() + 1];
strcpy_s(item.path, (splittedPath.length() + 1), splittedPath.c_str());
// If a parent was found use th parent.
if (parentNode) {
//printf("parent %s\n", parentNode->data.path);
filesTree.append_child(tree<FILE_ITEM>::iterator_base(parentNode), item);
} else {
// Node wasn't found - most likely a new root - add it to the top level.
//printf("No parent node found for %s. Adding new sibbling.", absolutePath);
item.path = new char[strlen(absolutePath) + 1];
strcpy_s(item.path, (strlen(absolutePath) + 1), absolutePath);
item.nPathLen = strlen(item.path);
filesTree.insert(tree<FILE_ITEM>::iterator_base(topNode), item);
topNode = filesTree.begin();
}
}
DisplayTree(topNode.node, 0);
return item;
}
示例8: RenameItem
void CFileTree::RenameItem(char *absolutePathFrom, char *absolutePathTo)
{
tree_node_<FILE_ITEM>* node = findNodeFromRootWithPath(absolutePathFrom);
tree_node_<FILE_ITEM>* parentNode = findParentNodeFromRootForPath(absolutePathTo);
if (parentNode != NULL && node != NULL) {
if (filesTree.number_of_children(parentNode) < 1) {
FILE_ITEM emptyItem;
emptyItem.nPathLen = 0;
emptyItem.path = const_cast<char*>("");
filesTree.append_child(tree<FILE_ITEM>::iterator_base(parentNode), emptyItem);
}
tree<FILE_ITEM>::iterator firstChild = filesTree.begin(parentNode);
filesTree.move_after(firstChild, tree<FILE_ITEM>::iterator(node));
std::string sPath(absolutePathTo);
std::string splittedPath = sPath.substr(sPath.find_last_of('\\') + 1);
node->data.path = new char[splittedPath.length() + 1];
strcpy_s(node->data.path, (splittedPath.length() + 1), splittedPath.c_str());
}
DisplayTree(topNode.node, 0);
}
示例9: getData
//.........这里部分代码省略.........
//
else if(label_case==2){
//
//read EDF file and create object with header values and image
//
edf_reader Edf = edf_reader(infile);
//
//check the size of image
//
int image_dim[1]={Edf.get_image_size()};
//
//store image in the place of the NeXus hierarchy from the command was invoked in .xml file
//
Node node_data("Image", (void*)Edf.get_image(), 1, image_dim, NX_INT8);
tr.insert(tr.end(),node_data);
}
//
//case for storing every keys from header with an image
//
else{
double valueD[1];
double double_value;
string string_value;
int dims1[1]={1};
//
//create object with header values and Image
//
edf_reader Edf = edf_reader(infile);
string key;
//
//get size of both dictionaries
//
int double_map_size = Edf.size_map_double();
int string_map_size = Edf.size_map_string();
//
//iterators used for creation of hierarchical subtree
//
tree<Node>::iterator root, log, data;
//
//create NXentry root group, in the place where command was invoked,
//
Node node("empty", "NXentry");
root = tr.insert(tr.end(),node);//insert root to the tree
//
//create NXlog group for storing header values
//group is a sub group of NXentry root group
//
Node log_node("EDF_log", "NXlog");
log = tr.append_child(root,log_node);
//
//create NXdata group for storing EDF image
//group is a sub group of NXentry root group
//
Node data_node("EDF_image", "NXdata");
data = tr.append_child(root,data_node);
//
//get every keys and values from dicitonary of double values
//
for(int i=1; i<double_map_size+1; i++){
key=Edf.get_key_double(i, double_value);
valueD[0]=double_value;
//
//store pairs key-double value in NXlog group
//
Node node_child(key, (void*)valueD, 1, dims1, NX_FLOAT64);
tr.append_child(log,node_child);
}
//
//get every keys and values from dicitonary of string values
//
for(int i=1; i<string_map_size+1; i++){
key=Edf.get_key_string(i, string_value);
int size=string_value.size();
dims1[0]=size;
std::vector<char> valueS(size);
//
//convert C++ string into C-style string, NXtranslate convention
//
for(int i=0; i<size; i++){
valueS[i]=string_value[i];
}
//
//store pairs key-string value in NXlog group
//
Node node_child(key, (void*)&(valueS[0]), 1, dims1, NX_CHAR);
tr.append_child(log,node_child);
}
//
//prepare image size
//
int image_dim[1]={Edf.get_image_size()};
//
//store edf-image in NXdata group
//
Node node_data("Image", (void*)Edf.get_image(), 1, image_dim, NX_INT8);
tr.append_child(data,node_data);
}
}