[SDL] Re: SDL_Config: call for comments
Anders F Björklund
afb at algonet.se
Thu Jul 7 03:09:25 PDT 2005
Koshmaar wrote:
> Have you noticed that there aren't many open-source libraries for
> parsing configuration files? I've googled for a while and found only
> standard WinAPI functions on Windows, and CFL library on Linux
> distros (but I wasn't searching very long).
Yes, I did notice - and most of the available ones use XML or C++...
(which made them all _way_ too heavy for my intended use that I had)
> I thought that it would
> be nice, if there was open-source, portable C/C++ library for
> reading/writing configuration files. By "configuration files" I mean
> .ini files known from Win, ie.
Funny, as I had the same exact thought with our "SpriteWorld X"... :-)
I wanted something that was plain ANSI C, and under a BSD-ish license.
> I decided to write such library... which will be called SDL_Config
> (shamelessly plugging into SDL fame :-) ), distributed as GNU GPL,
> and hosted on Sourceforge. After few days of planning, it became
> obvious, that there are things which should be discussed with group
> of potential users.
I don't think such a library would require a few days of planning ?
(then again, maybe yours is more advanced but mine took a few hours)
> 1. Author of TinyXML (which is small library for parsing XML files)
> decided to give user ability to choose, whether: TinyXML will be
> using STL containers or self-made versions, and whether to use
> std::iostreams, or FILE.
Too many options. Just use SDL_rwops ?
> 2. Bool type - there's nothing like "bool" in C, and this library is
> going to be compiled in C.
> [...]
> Which one do you like more? Is there any third (better) way?
Yes, just use the SDL_bool type ? (int)
> 3. Because this library is more or less, just a bunch of plain C
> functions, and file state is stored in global variables, only one
> config file can be opened at a time. So, ie. you won't be able to
> write to file "aaaa.cfg" and read from "bbbb.cfg" simultaneously -
> you will have to write all to "aaaa.cfg", close it, and then open
> "bbbb.cfg" etc.
Global variables suck, so use a struct... (even a hash is overkill)
> 4. This one is easy: will you want to use such library? :-) If
> there's no interest, there's no need to write it, simple.
If you want to use ours, it's available under zlib/libpng license at:
http://cvs.sourceforge.net/viewcvs.py/spriteworldx/
spriteworldx/Utils/SWProperties.h?view=auto
It has some custom "SWError" and "SWBoolean" compatibility types,
but you can change those for "int" if using it somewhere else...
Also, the implementation is not exactly robust but seems to work ?
--anders
PS.
For the project home page, look here:
http://spriteworldx.sourceforge.net/
(there's also some standalone SDL/GL
stuff in the "BlitKernel" subproject)
More information about the SDL
mailing list