okutil_read_file_section
Description
Read an ASCII text file that are like LabTalk OGS files with sections
Syntax
int okutil_read_file_section( LPCSTR lpcszFilename, LPCSTR lpcszSecName, string * pstr, string * pstrComments, bool bWholeSection = false, bool bExposeSectionName = false )
Parameters
- lpcszFilename
- [input] fullpath file name
- lpcszSecName
- [input] section name, [] not needed
- pstr
- [output] content of the section
- pstrComments
- bWholeSection
- [input] if true, the comments will not be separated out, but instead the whole section will be put into *pstr.
- bExposeSectionName
- [input] if true, it can find section name with pair "[]" inside
Return
size of *pstr if success, or
-1 = section not found
-2 = file not found
Examples
EX1
void okutil_read_file_section_ex1()
{
string strFile = "C:\junk.txt";
// Write a section with comments into file,
int nn = okutil_write_file_section(strFile,"SQL","select * from files","select any from file");
nn = okutil_write_file_section(strFile,"MySQL","select name from files","select name from file");
string strSec, strComments;
okutil_read_file_section(strFile, "SQL", &strSec, &strComments);
vector<string> vsSecNames;
okutil_get_file_sections(strFile, &vsSecNames);
}
Remark
See Also
okutil_write_file_section, okutil_get_file_sections
header to Include
origin.h
Reference
|