tree_check_attribute_value_exist

 

Description

check if value exist in tree node attribute

Syntax

bool tree_check_attribute_value_exist( const TreeNode & tr, LPCSTR lpcszVal, LPCSTR lpcszAttrib, bool bCaseSensitive = false, bool bRecursive = false )

Parameters

tr
[input]TreeNode to walk
lpcszVal
[input]attribute value to be matched
lpcszAttrib
[input]attribute to be found in
bCaseSensitive
[input]true, case sensitive, false, not
bRecursive
[input]true, will recursive, false, not

Return

true, if value found in treenode attribute

Examples

EX1

void tree_check_attribute_value_exist_ex1()
{
        Tree myTree;
        TreeNode tn1, tn2, tn3,tn4,tn5;
        
        tn1 =myTree.AddTextNode("a", "node1", 1);
        tn1.SetAttribute("AttribID", "Spring");
        
        tn2 = myTree.AddTextNode("b", "node2", 2);
        tn2.SetAttribute("AttribID", "Hello");
    
        tn3 = tn1.AddTextNode("c", "node3", 3);
        tn3.SetAttribute("AttribID", "originlab");
        
        tn4 = tn3.AddTextNode("d", "node4", 4);
        tn4.SetAttribute("AttribID", "Hi");
        
        tn5= tn2.AddTextNode("e", "node5", 5);
        tn5.SetAttribute("AttribID", "Why");

        if( tree_check_attribute_value_exist(myTree, "Spring", "AttribID") )
                out_str("Yes!");
        else
                out_str("No");
        
        if( tree_check_attribute_value_exist(myTree, "spring", "AttribID", true) )
                out_str("Yes!");
        else
                out_str("No");
        
        if( tree_check_attribute_value_exist(myTree, "Hi", "AttribID", false, false) )
                out_str("Yes!");
        else
                out_str("No");
        
        if( tree_check_attribute_value_exist(myTree, "Hi", "AttribID", false, true) )
                out_str("Yes!");
        else
                out_str("No");
}

Remark

See Also

header to Include

origin.h

Reference