TreeNode::GetNodeFromPath

 

Version

Description

Get tree node from the specified path

Syntax

TreeNode GetNodeFromPath( LPCSTR lpcszPath, BOOL bAddIfNotThere = FALSE, BOOL bCaseSensitive = FALSE )

Parameters

lpcszPath
[input] tree node path
bAddIfNotThere
[input] default: FALSE, if the path does not exist, then add the node
bCaseSensitive
[input] defalut: FALSE, case sensitview

Return

Returns the tree node from the path, if not found and bAddIfNOtThere = TRUE, return NULL

Examples

EX1

void TreeNode_GetNodeFromPath_ex1()
{
    Tree tr;
    tr.branch.node1.nVal = 1;
    
    TreeNode trNode = tr.GetNodeFromPath("branch.Node1", FALSE, FALSE);
    if(trNode)
    {
        out_tree(trNode);
    }
    else
    {
        printf("can not get trNode");
    }
    
    TreeNode trNode2 = tr.GetNodeFromPath("123Branch.Node2", FALSE, TRUE);
    if(trNode2)
    {
        out_tree(trNode2);
    }
    else
    {
        printf("can not get trNode2");
    }
    
    TreeNode trNode3 = tr.GetNodeFromPath("branch.node2", TRUE, FALSE);
    if(trNode3)
    {
        out_tree(tr);
        out_tree(trNode3);
    }
    else
    {
        printf("can not get trNode3");
    }
}

Remark

See Also

header to Included

origin.h