| 2.2.3.17.6 TreeNode::CreateDiff
 VersionDescriptionConstruct a new tree that collects all the tree nodes that are different between the two given.
 Syntaxint CreateDiff( const TreeNode & tnTarget, const TreeNode & tnRef, DWORD dwCntrl = 0, int nRealPrecision = 0, LPCSTR lpcszAttribs = NULL ) Parameters tnTarget[input]TreeNode to compare tnRef[input]TreeNode for reference  dwCntrl[input]TRDIFF_CHK_ATTRIB		  	compare both value and attributeTRDIFF_KEEP_INDIVI_TARGET  	consider diff if node missing in tnRef but exsits in tnTarget,if TRDIFF_KEEP_REF_VALUES set, a attribute named STR_TRDIFF_REF_VALUE_ATTRIB will be set, and the attribute value is EmptyTRDIFF_KEEP_INDIVI_REF		consider diff if node missing in tnTarget but exists in tnRefif TRDIFF_KEEP_REF_VALUES set, values will be kept as attribute named STR_TRDIFF_REF_VALUE_ATTRIB, otherwise they will be kept as valueTRDIFF_KEEP_BRANCH_NO_LEAF	keep such branch even if no any childens diff, etc. category branchTRDIFF_KEEP_REF_VALUES		keep the values in tnRef as attribute(named STR_TRDIFF_REF_VALUE_ATTRIB) if the node's value is different from the value of the corresponding node in tnTargetTRDIFF_BY_NODE_INDEX		check diff by index of children node nRealPrecision[input] for compare double valuedefault: 0, means origin default-1, means full precision lpcszAttribs[input] specify one or more attributes to comparemust enable TRDIFF_CHK_ATTRIB first
 Return-1 if error, like tnTarget or tnRef invalid
 0 if no diff
 >0 for number of diff nodes found
 ExamplesEX1
 void test_create_diff_ex1()
{
    Tree tr1;
    tr1.node1.nVal = 1;
    tr1.node2.nVal = 1;
    tr1.node2.SetAttribute("attrib1", 1);
    tr1.node2.SetAttribute("attrib2", 1);
    tr1.branch.node21.dVal = 12.3333333;
    tr1.branch.node22.dVal = 12.3333333;
    tr1.branch.node23.strVal = "abc";
    
    
    Tree tr2;
    tr2.node10.nVal = 1;
    tr2.node2.SetAttribute("attrib1", 1);
    tr2.node2.SetAttribute("attrib2", 2);
    tr2.node2.nVal = 1;
    tr2.branch.node21.dVal = 12.333456;
    tr2.branch.node22.dVal = 12.343333;
    tr2.branch.node23.strVal = "edf";
    
    Tree trDiff;
    trDiff.CreateDiff(tr1, tr2, TRDIFF_KEEP_INDIVI_TARGET | TRDIFF_CHK_ATTRIB, 4, "attrib1|attrib2");
    
    out_tree(tr1);
    out_tree(tr2);
    out_tree(trDiff);
    ASSERT(trDiff.node1.nVal == 1);
    ASSERT(trDiff.node2.nVal == 1);
    ASSERT(trDiff.branch.node22.dVal == 12.3333333);
    ASSERT(trDiff.branch.node23.strVal == "abc");
}RemarkSee AlsoHeader to Includedorigin.h
 |