INI Files

Started by
2 comments, last by Cygon 19 years, 1 month ago
Before I go and make my own INI file class wrapper type thing, does anyone have any lightweight solutions?
Rob Loach [Website] [Projects] [Contact]
Advertisement
On the one hand, have you looked into the WTL? It's likely to have a CIniFile class. On the other hand, have you searched The Code Project?
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)
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-
Professional C++ and .NET developer trying to break into indie game development.
Follow my progress: http://blog.nuclex-games.com/ or Twitter - Topics: Ogre3D, Blender, game architecture tips & code snippets.

This topic is closed to new replies.

Advertisement