• Advertisement
Sign in to follow this  

INI Files

This topic is 4725 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Before I go and make my own INI file class wrapper type thing, does anyone have any lightweight solutions?

Share this post


Link to post
Share on other sites
Advertisement
The win32 api has some basic functions built in for dealing with initialization files, which may make your job easier.

MSDN Reference (scroll down to the Get/WritePrivateProfile*() stuff)

Share this post


Link to post
Share on other sites
Under windows, you can use the GetPrivateProfileString()/WritePrivateProfileString() set of functions for accessing ini files. They're marked as obsolete, but it's unlikely they will be removed anytime soon because they're used by lots of people.

Anyway, I wrote a lightweight ini/cfg file parser some time ago which allows you to navigate an ini file through a simple object model, much like TinyXML for xml files:

int main() {
Confix::Configuration CFG(
"# Simple configuration file\n"
"[SomeSection]\n"
"Hello = World\n"
"Test = 0x40\n"
);

std::string text = CFG.getSection("SomeSection").getVariable("Hello");
size_t number = CFG.getSection("SomeSection").getVariable("Test");
}



Might still be a bit larger than what you're looking for, but if you want to check it out: Confix ini file parser (full source is included)

-Markus-

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement