【お知らせ】この部分は英語原文のみでの提供となります。何卒ご了承ください。
2.2.3.17.36 TreeNode::SetAttribute
Contents
Version
Minimum Origin Version Required: Origin 9.0
BOOL SetAttribute( LPCSTR lpcszAttrName, __int64 nVal )
BOOL SetAttribute( LPCSTR lpcszAttrName, void *pVal)
Minimum Origin Version Required: Origin 9.2 Beta1
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<int>& vnVals)
Minimum Origin Version Required: Origin 9.4
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<double>& vals)
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<float>& vals)
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<short>& vals)
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<char>& vals)
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<string>& vals)
Description
Sets the integer value of a node.
Sets the 64-bit integer value of a node.
Sets the void pointer value of a node.
Sets the double value of a node.
Sets the string attribute of the node.
Sets the integer vector value of a node.
Sets the double vector value of a node.
Sets the float vector value of a node.
Sets the short vector value of a node.
Sets the char vector value of a node.
Sets the string vector value of a node.
Syntax
BOOL SetAttribute( LPCSTR lpcszAttrName, int nVal )
BOOL SetAttribute( LPCSTR lpcszAttrName, __int64 nVal )
BOOL SetAttribute( LPCSTR lpcszAttrName, void *pVal)
BOOL SetAttribute( LPCSTR lpcszAttrName, double dVal )
BOOL SetAttribute( LPCSTR lpcszAttrName, LPCSTR strVal )
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<int>& vnVals)
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<double>& vals)
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<float>& vals)
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<short>& vals)
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<char>& vals)
BOOL SetAttribute(LPCSTR lpcszAttrName, const vector<string>& vals)
Parameters
- lpcszAttrName
- [input] name of the node
- nVal
- [input] contains the integer value to be set into the node.
- lpcszAttrName
- [input] name of the node
- nVal
- [input] contains the 64-bit integer value to be set into the node.
- lpcszAttrName
- [input] name of the node
- pVal
- [input] contains the void pointer value to be set into the node.
- lpcszAttrName
- [input]name of the node
- dVal
- [input] contains the double value to be set into the node.
- lpcszAttrName
- [input]name of the node
- strVal
- [input] contains the string value to be set into the node.
- lpcszAttrName
- [input]name of the node
- vnVals
- [input] contains the integer vector value to be set into the node.
- lpcszAttrName
- [input]name of the node
- vVals
- [input] contains the double vector value to be set into the node.
- lpcszAttrName
- [input]name of the node
- vVals
- [input] contains the float vector value to be set into the node.
- lpcszAttrName
- [input]name of the node
- vVals
- [input] contains the short vector value to be set into the node.
- lpcszAttrName
- [input]name of the node
- vVals
- [input] contains the char vector value to be set into the node.
- lpcszAttrName
- [input]name of the node
- vVals
- [input] contains the stirng vector value to be set into the node.
Return
True if the node is found; FALSE otherwise
Examples
EX1
// Sets the integer value of a node void TreeNode_SetAttribute_ex1() { Tree myTree; TreeNode tn = myTree.AddTextNode("abc", "node1", 2); // add a node // add NodeID attribute tn.SetAttribute("NodeID", 5); // get NodeID attribute int nVal; bool flag = tn.GetAttribute("NodeID", nVal); if( flag) printf("the NodeID attribute of node1 is %d", nVal); else printf("error, fail to find NodeID attribute"); }
EX2
// Sets the double value of a node. void TreeNode_SetAttribute_ex2() { Tree myTree; TreeNode tn = myTree.AddNode("abc"); tn.SetAttribute("Value", 5.345); double dVal; bool flag = tn.GetAttribute("Value", dVal); if( flag ) printf("Value attribute of abc node is %f", dVal); else printf("error, fail to find Value attribute"); }
EX3
//Sets the string attribute of the node. void TreeNode_SetAttribute_ex3() { Tree myTree; TreeNode tn = myTree.AddNode("abc"); tn.SetAttribute("Label", "xyz"); string strVal; bool flag = tn.GetAttribute("Label", strVal); if( flag ) printf("the string value of Label attribute is %s", strVal); else printf("error, fail to find Label attribute"); }
EX4
// Sets the vector value of a node. void TreeNode_SetAttribute_ex4() { 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