2.2.3.17.7 TreeNode::DataID

ClassName

TreeNode

AccessType

public

Name

DataID

Declaration

int DataID

Remark

DataID is an treenode attribute. This ID not specific meaning. Unique or repeated also can be decided by user.

Examples

EX1

void TreeNode_DataID_ex1()
{
    Tree tr;
    TreeNode tn1;
    tn1 = tr.AddNode("abc");
    tn1.DataID = 1;										// write tn1.DataID
    out_int("tn1.DataID = ", tn1.DataID);				// read tn1.DataID
 
    // access DataID by TreeNode::SetAttribute and TreeNode::GetAttribute
    TreeNode tn2 = tr.AddNode("def");
    tn2.SetAttribute(STR_DATAID_ATTRIB, 10);			//Set tn2.DataID to 10
    int dataid;
    if( tn2.GetAttribute(STR_DATAID_ATTRIB, dataid) )	//Get tn2.DataID
    {
        out_int("tn2.DataID = ", dataid);
    }
    else
    {
        out_str("Error, tn2.DataID attribute is not existed.");
    }
}

Description

Read or write treenode's DataID attribute.

Header to Include

origin.h

See Also

TreeNode::ID, TreeNode::GetAttribute, TreeNode::SetAttribute, TreeNode::AddNode

Reference