*.ini files
Does anybody now how to load a *.ini file without using a lot of memory? I tried to but I used a lot of memeory. And memory is limited. So if anybody has an idea. Mail me:
thedwarf15@hotmail.com
MSDN for WritePrivateProfileString() and ReadPrivateProfileString()
Handling of INI files in windows is possible through Kernel level functions
Handling of INI files in windows is possible through Kernel level functions
quote:Original post by daerid
MSDN for WritePrivateProfileString() and ReadPrivateProfileString()
Handling of INI files in windows is possible through Kernel level functions
Kernel level functions?
[How To Ask Questions|STL Programmer''s Guide|Bjarne FAQ|C++ FAQ Lite|C++ Reference|MSDN]
Take a look at superpig''s enginuity articles and look at his settings class. It might work for you with a few modifications.
[JESUS SAVES]
[JESUS SAVES]
are you looking to read/load the whole thing ... or to extract 1-10 settings out of a large file ???
just like the rules for parsing an XML file ... in xml DOM is best for things where you need to (and can afford to) load the whole file into memory, and read pieces in random orders or more than once ... but SAX is best for things which can be processed once, as read ... or only need to extract specific pieces ...
an INI file can be read like sax ... simply write your search routine to do something like keep track of what [group] you are in ... in some global/class variable or something ... and call a hook function when each actual setting is read ... and when a group change tag is read ... or something like that ...
then your hook could do something like:
if(iniFile.CurrentGroup() == "right_group")
if(iniFile.CurrentSettingLavel() == "right_setting")
DOSOMETHING();
and there is no need to store the actual file contents while reading ... except the current group and current line ...
just like the rules for parsing an XML file ... in xml DOM is best for things where you need to (and can afford to) load the whole file into memory, and read pieces in random orders or more than once ... but SAX is best for things which can be processed once, as read ... or only need to extract specific pieces ...
an INI file can be read like sax ... simply write your search routine to do something like keep track of what [group] you are in ... in some global/class variable or something ... and call a hook function when each actual setting is read ... and when a group change tag is read ... or something like that ...
then your hook could do something like:
if(iniFile.CurrentGroup() == "right_group")
if(iniFile.CurrentSettingLavel() == "right_setting")
DOSOMETHING();
and there is no need to store the actual file contents while reading ... except the current group and current line ...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement