| tree_copy_values_to_attributes  Descriptioncopy value to attributes from tree to tree by specific attribute value matching Syntax
bool tree_copy_values_to_attributes( TreeNode & trSrc, TreeNode & trDest, LPCSTR lpcsz2ndAttributeToTransfer = NULL, LPCSTR lpcszDestAttribute = NULL, LPCSTR lpcszAttributeToMatch = NULL, bool bRecursive = true, bool bAllMatched = true, bool bCaseSensitive = false )
 Parameters
    trSrc[input]Source TreeNode copy fromtrDest[modify]TreeNode copied tolpcsz2ndAttributeToTransfer[input]in addition to transfer value to attribute, there is also an option to transfer an attribute from source to destinationlpcszDestAttribute[input]The attribute of target that copy source value to, if NULL, then STR_SHOW_ATTRIB is assumedlpcszAttributeToMatch[input]Match attribute and its value to copy, if NULL, then STR_DATAID_ATTRIB is assumedbRecursive[input]true, go through all the tree node in trSrc;false, just go through the Children of trSrcbAllMatched[input]true, apply to all the match node in trDest;false, only apply to 1st matched in trDestbCaseSensitive[input]true, compare the attribute value case sensitivefalse, not case sensitive Returnfalse if copy none ExamplesEX1 
void tree_copy_values_to_attributes_ex1()
{
    Tree tr;
    TreeNode trSrc, trDest;
    trSrc = tr.AddNode("Math");
    trSrc.Score.strVal = "0";
    trSrc.Score.SetAttribute(STR_DATAID_ATTRIB, "1");
    
    trSrc.Bookname.strVal = "1";
    trSrc.Bookname.SetAttribute(STR_DATAID_ATTRIB, "2");
    
    trDest = tr.AddNode("English");
    trDest.Score.strVal = "90.5";
    trDest.Score.SetAttribute(STR_DATAID_ATTRIB, "1");    
    
    trDest.Bookname.strVal = "English 1";    
    trDest.Bookname.SetAttribute(STR_DATAID_ATTRIB, "2");    
    
    //Copy values {0, 1} from trSrc to the Show attribute of the trDest by matching DataID attribute
    bool bRet = tree_copy_values_to_attributes(trSrc, trDest);
    ASSERT( 0 == trDest.Score.Show);  //copy value 0 form trSrc to the Show attribute of Score matched by DataID
    ASSERT( 1 == trDest.Bookname.Show);     //copy value 1 from trDest to the Show attribute of Bookname matched by DataID
}
RemarkSee Alsoheader to Includeorigin.h Reference |