tree_to_str

 

Description

Output contents of tree table to string

Syntax

int tree_to_str( const TreeNode & tr, string & str, vector<int> & vnDisplayFormat = NULL, DWORD dwCtrl = TREE2STR_DEFAULT, LPCSTR lpcszDoubleValueFormat = NULL )

Parameters

tr
[input] the tree need output
str
[output] the output string
vnDisplayFormat
[input]display format of column header, row header and cell , can be DISPLAY_LEFT, DISPLAY_CENTER, DISPLAY_RIGHT
dwCtrl
[input] additional options from the TREE2STR_* enumeration.
lpcszDoubleValueFormat
[input] double value show fromat, if NULL, it uses the default "*", "*3" mean to set significant digits; Use the . notation to set decimal places, ect

Return

number of output tree node

Examples

EX1

void tree_to_str_ex1()
{
    Tree trd;
    TreeNode tr = trd.AddNode("Temp");
    
    TreeNode trFirstRow = tr.AddNode("FirstRow");
    
    TreeNode trFirst = trFirstRow.AddNode("First");
    trFirst.strVal = "Hello";
    TreeNode trSecond = trFirstRow.AddNode("Second");
    trSecond.strVal = "Hi";
    
    TreeNode trSecondRow = tr.AddNode("SecondRow");
    TreeNode trThird = trSecondRow.AddNode("First");
    trThird.strVal = "world";
    TreeNode trFourth = trSecondRow.AddNode("Second");
    trFourth.strVal = "Hi";
    vector<int> vnTableDisplayFormat = { DISPLAY_CENTER, DISPLAY_RIGHT, DISPLAY_RIGHT};
    string strTreeTable;
    int iRet= tree_to_str(tr,strTreeTable, vnTableDisplayFormat);
    out_str(strTreeTable);
    out_int("The number of the output treenode is ", iRet);
}

Remark

See Also

header to Include

origin.h

Reference