2.1.26.70 tree_write_ini


Description

Write a tree node, that represents an ini file, to an ini file.

Syntax

bool tree_write_ini( TreeNode & trIni, LPCSTR lpcszFile, bool bClearSections = false, bool bLabelAsKey = true )


bool tree_write_ini( TreeNode & trIni, INIFile & iniFile, bool bClearSections = false, bool bLabelAsKey = true )

Parameters

trIni
[input]tree node representing an ini file
lpcszFile
[input]pointer to an ini file name
bClearSections
[input] true will clear eixsting content of the ini section, false will not
bLabelAsKey
[input]true, make tree label attribute as key name; else tagName will be key name.
When bLabelAsKey is false, will use treenode tagName as key name, if want to get label of some special treenodes as key name,
can set STR_COMPLEX_ININAME_ATTRIBUTE attribute as true for these treenodes.


trIni
[input]tree node representing an ini file
iniFile
[output]ini file to be written to
bClearSections
[input] true will clear eixsting content of the ini section, false will not
bLabelAsKey
[input]true, make tree label attribute as key name; else tagName will be key name.
When bLabelAsKey is false, will use treenode tagName as key name, if want to get label of some special treenodes as key name,
can set STR_COMPLEX_ININAME_ATTRIBUTE attribute as true for these treenodes.

Return

true for success, false for error.

Examples

EX1

//Add an user function info to Section "Origin Basic Functions" and write it back to NLSF.ini
void tree_write_ini_ex1()
{    
    Tree trIni;
    if(tree_read_ini(trIni, "NLSF.ini"))
    {
        if(trIni.OriginBasicFunctions)
            trIni.OriginBasicFunctions.AddTextNode("Func2", "Func2");
    }
    if(tree_write_ini(trIni, "NLSF.ini"))
        out_tree(trIni);
    
}


EX2

//Remove "Other" section from origin.ini
void tree_write_ini_ex2()
{    
    Tree trIni;
    INIFile iniFile("Origin.ini");
    if(tree_read_ini(trIni, iniFile))
    {
        trIni.RemoveChild("OTHER");
    }
    if(tree_write_ini(trIni, iniFile))
        out_tree(trIni);
    
}

Remark

See Also

tree_read_ini

Header to Include

origin.h

Reference