Jump to content
  • Advertisement
Sign in to follow this  
gtype

Config file standards?

This topic is 3639 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

Hey there, I would like to know if there are any kind of convention or standards or something regarding to how to make config files. For example, how should I make a config file for a program? An ini file? A text file with fields like "Something=somesetting"? A minimalistic file with all the settings one after another separated by the bit 0? Is there any convention to this? Cause I am kind of perfectionist, I'm not content with things working, and I'm not keen on reinventing the well either. So, I was wondering if there is any way that has proven to be easy to use, fast, and produce cool code. Thanks

Share this post


Link to post
Share on other sites
Advertisement
oh right, I forgot. I'm talking about a cross platform proggie, so it has to be a file :) thanks

Share this post


Link to post
Share on other sites
XML will come closest to anything standardized.

Note that XML compliance has two aspects: well-formed and valid. First means only that tags match, attributes are properly formatted and the rest is written in accordance with encoding.

Valid XML however requires definition of a schema and all of accompanying information. Things get a bit trickier since most XML parsers can barely handle well-formed documents. The "Big Iron" libraries with full validation tend to offer fairly complete support, but even with those I've had problems with character encodings.

One problem you may find tedious with valid XML is that parsing may fail for obscure reasons. Another important note is that libraries to handle valid XML are huge. Things like minimalistic XML parsers simply do not care about compliance, or choose not be compliant for sake of simplicity.

From what I've seen in recent thread here, files produced by boost's XML serialization are valid XML, although I won't guarantee it (I never checked in detail).

Share this post


Link to post
Share on other sites
hmmm thanks, but i was looking for something that doesn't require aditional libraries.. maybe I'll just go with the typical SomeOption=SomeSetting, one option per line :/

Share this post


Link to post
Share on other sites
Quote:
Original post by gtype
hmmm thanks, but i was looking for something that doesn't require aditional libraries..


In that case, there is nothing. C++ offers no support for configuration files or anything like that. That is, of course, assuming you're using C++. Other languages have INI, XML, or JSON parsers built in.

Share this post


Link to post
Share on other sites
Quote:
Original post by gtype
hmmm thanks, but i was looking for something that doesn't require aditional libraries.
A simple key=value setup will work fine for most cases, but you do have to write the parser yourself :)

I would highly suggest you checkout JSON, as it is very lightweight, and there are quite a number of small C++ libraries to parse it.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!