2.1.26.59 tree_read_values_with_ids


Description

Read the id-value pair from file

Syntax

bool tree_read_values_with_ids( LPCSTR lpcszFilename, vector<int> & vnIDs, vector<string> & vsValues, string & strComment = NULL )

Parameters

lpcszFilename
[input]full file name to store data pairs
vnIDs
[output]vector of IDs.
vsValues
[output] vector of string values, must be the same size of vnIDs.
strComment
[output] storage the tree file comment.

Return

true if succeed

Examples

EX1

void tree_read_values_with_ids_ex1()
{
	string strCreateFile = okutil_get_origin_path(USER_FOLDER) +"temp.ini";
	if( !strCreateFile.IsFile() )
	{
		out_str("can't open the file!please check it");
		return ;
	}
	vector<int> vnIDs = {1, 2};
	vector<string> vsValues = {"1.1", "2.2"};
	vector<string> vsLabels = {"L1", "L2"};
	vector<int> vnIDtemp;
	vector<string> vsVtemp;
	if( tree_save_values_with_ids( strCreateFile, vnIDs, vsValues, vsLabels) )
	{
		if( tree_read_values_with_ids( strCreateFile, vnIDtemp, vsVtemp) )
			out_str("read successfully!");
		else
			out_str("read failure");
	}
	else
		out_str("save failure");
}

Remark

See Also

Header to Include

origin.h

Reference