2.2.3.17.12 TreeNode::GetAttribute
Contents
Version
Minimum Origin Version Required: Origin 9.0
BOOL GetAttribute( LPCSTR lpcszAttrName, __int64 &nVal )
BOOL GetAttribute( LPCSTR lpcszAttrName, void *&pVal )
Minimum Origin Version Required: Origin 9.2 Beta1
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<int>& vnVals )
Minimum Origin Version Required: Origin 9.4
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<double>& vals )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<float>& vals )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<short>& vals )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<char>& vals )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<string>& vals )
Description
Gets the integer attribute of a node with the specified name.
Gets the 64-bit integer attribute of a node with the specified name.
Gets the void pointer attribute of a node with the specified name.
Gets the double attribute of a node with the specified name.
Gets the string attribute of a node with the specified name.
Gets the integer vector of a node with the specified name.
Gets the double vector of a node with the specified name.
Gets the float vector of a node with the specified name.
Gets the short vector of a node with the specified name.
Gets the char vector of a node with the specified name.
Gets the string vector of a node with the specified name.
Syntax
BOOL GetAttribute( LPCSTR lpcszAttrName, int & nVal )
BOOL GetAttribute( LPCSTR lpcszAttrName, __int64 &nVal )
BOOL GetAttribute( LPCSTR lpcszAttrName, void *&pVal )
BOOL GetAttribute( LPCSTR lpcszAttrName, double & dVal )
BOOL GetAttribute( LPCSTR lpcszAttrName, string & strVal )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<int>& vnVals )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<double>& vals )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<float>& vals )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<short>& vals )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<char>& vals )
BOOL GetAttribute( LPCSTR lpcszAttrName, vector<string>& vals )
Parameters
- lpcszAttrName
- [input]name of the node
- nVal
- [output] contains the integer attribute of the node after the function call is finished
- lpcszAttrName
- [input]name of the node
- nVal
- [output] contains the 64-bit integer attribute of the node after the function call is finished
- lpcszAttrName
- [input]name of the node
- pVal
- [output] contains the void pointer attribute of the node after the function call is finished
- lpcszAttrName
- [input] name of the node
- dVal
- [output] After the method call, dVal contains the double attribute of the node.
- lpcszAttrName
- [input] name of the node
- strVal
- [output]After the method call, strVal contains the string attribute of the node.
- lpcszAttrName
- [input] name of the node
- vnVals
- [output]After the method call, vnVals contains the integer vector attribute of the node.
- lpcszAttrName
- [input] name of the node
- vVals
- [output]After the method call, vVals contains the double vector attribute of the node.
- lpcszAttrName
- [input] name of the node
- vVals
- [output]After the method call, vVals contains the float vector attribute of the node.
- lpcszAttrName
- [input] name of the node
- vVals
- [output]After the method call, vVals contains the short vector attribute of the node.
- lpcszAttrName
- [input] name of the node
- vVals
- [output]After the method call, vVals contains the char vector attribute of the node.
- lpcszAttrName
- [input] name of the node
- vVals
- [output]After the method call, vVals contains the string vector attribute of the node.
Return
True if the attribute is found; FALSE otherwise
Examples
EX1
void TreeNode_GetAttribute_ex1() { Tree tr; TreeNode tn1; tn1 = tr.AddTextNode("Staff", "Infomation", 2); out_tree(tr); tn1.SetAttribute("name", "Amy"); //New a string attribute named "name" and set to "Amy" tn1.SetAttribute("age", 33); //New a int attribute named "age" and set to "35" tn1.SetAttribute("salary", 5303.56);//New a double attribute named "salary" and set to "5303.56" // Gets the string attribute of a node with its name. string strVal; if ( tn1.GetAttribute("name", strVal) ) printf("The name of the staff is %s\n", strVal); // Gets the integer attribute of a node with its name. int nVal; if ( tn1.GetAttribute("age", nVal) ) printf("The age is %d\n", nVal); // Gets the double attribute of a node with its name. double dVal; if ( tn1.GetAttribute("salary", dVal) ) printf("The salary is %g\n", dVal); //Result: //The name of the staff is Amy //The age is 35 //The salary is 5303.56 }
EX2
void TreeNode_GetAttribute_ex2() { Tree tr; TreeNode tn1 = tr.AddNode("node1",1); out_tree(tr); vector<int> vnVals = {1, 2, 3}; tn1.SetAttribute("node1", vnVals); vector<int> vnVals2; if(tn1.GetAttribute("node1", vnVals2)) { for(int nn = 0; nn < vnVals2.GetSize(); nn++) { printf("The value is %d\n", vnVals2[nn]); } } vector<string> vdVals = {"one", "tow", "three"}; tn1.SetAttribute("node2", vdVals); vector<string> vdVals2; if(tn1.GetAttribute("node2", vdVals2)) { for(int nn = 0; nn < vdVals2.GetSize(); nn++) { printf("The value is %s\n", vdVals2[nn]); } } }
Remark
See Also
Header to Include
origin.h