Skip to main content
gamedev.net
🔒 Locked

SDL_Config 0.4

Started by Koshmaar Oct 19, 2005 at 4:23 PM 13 replies 2.3k views
Original Post
Koshmaar
Koshmaar
SDL_Config is a library designed for reading and writing configuration files in an easy, cross-platform way. Visit its homepage: Download it from SourceForge.
Changelog from version 0.3:


 Major:

 - added function which returns the number of groups (CFG_GetGroupCount())
 - added functions for iterating through all groups (CFG_StartGroupIteration(),
    CFG_SelectNextGroup(), CFG_IsLastGroup(), CFG_RemoveSelectedGroup())
    and removing selected groups when iterating (CFG_RemoveSelectedGroup())
 - added function for changing the direction of iteration (CFG_SetIterationDirection())
 - added functions which return currently selected file (CFG_GetSelectedFile()) and its name (CFG_GetSelectedFileName())
 - changed behaviour of CFG_OpenFile and CFG_OpenFile_RW: now, if operation was successfull, new file is always selected
 - added flag CFG_COMPRESS_OUTPUT to CFG_SaveFile(), which removes all spaces, that otherwise would be added to improve readability etc.
 - compile time define CFG_REMOVE_GROUP_SPACES controls whether spaces from within groups will be removed
 - compile time define CFG_ASSERT_NULL_ENABLED which asserts places where pointer to file could be nullified (by programmers error)

 Minor: 

 - fixed bug - additional " (CFG_DOUBLE_QUOTE character) was added after post comment to some text entries
 - fixed bug: now groups are also saved in original order when using CFG_SORT_ORIGINAL
 - integer values that don't fit into Sin32 are now detected also by their exact value (not only length)
 - fixed misc things, which could result in potential bugs
 - improvements in documentation, fixes, clarifications etc., source code more readable, removed some deprecated constructions etc.

Any comments?
BKBen7
BKBen7
Looks really nice, I'm right in assuming this is for config files for our SDL apps? and does it have functions to help with editing those file from an ingame menu?
"Is life so dear, or peace so sweet, as to be purchased at the price of chains and slavery? Forbid it, Almighty God! I know not what course others may take; but as for me, give me liberty or give me death!"~Patrick Henry
DeadXorAlive
DeadXorAlive
I have a vague feeling this is going to help me out. I will give you feedback when I start using it and have something intelligent to say if that ever happens.
- just finished my first SDL game... -

BTW, your game with the funny title totally rocked. (you made that right? with the bunny and all?) The psychedelic stuff became more annoying than fun though, after a while.
Will F
Will F
A couple of comments/questions.

1. I'm a bit confused what this project has to do with SDL.
2. Instead of using the LGPL with the added clause that the library can be statically linked without releasing the source, why not use something like the MIT License?
3. What are the advantages of SDL_Config vs using XML in the config files and something like tinyxml to parse it?

other than that, it's an interesting project
Koshmaar
Koshmaar
Ok, first: thanks guys for your replies :-) Now, answers.

Quote:

Looks really nice, I'm right in assuming this is for config files for our SDL apps? and does it have functions to help with editing those file from an ingame menu?


BKBen7, you are the person who replied first, and so you get the cookie :-)

Yup, SDL_Config was made with SDL apps in mind (just like SDL_TTF, SDL_Image etc.), one reason being that you must link with SDL to fulfill SDL_Config dependency requirments.

I'm not sure what you mean by "functions to help with editing those file from an ingame menu", but here is link to API, so please take a look.

Quote:

BTW, your game with the funny title totally rocked. (you made that right? with the bunny and all?) The psychedelic stuff became more annoying than fun though, after a while.


Hey, thanks :-) yup, I'm the author of Herbata Kto Ty Tak Kroliczek (link in sig), and currently I'm working on its "sequel", which should be much, much better.

Will F:

Quote:
1. I'm a bit confused what this project has to do with SDL.


- type sharing (Uint32, Sint32 etc.)
- I'm using SDL_SetError and SDL_GetError for public error handling (renamed to CFG_SetError and CFG_GetError)
- support for SDL_RWops
- API written in C, lib can be used in C/C++ and any other compatible language (like SDL)
- API similiar to SDL, SDL_Image, SDL_TTF etc.
- license (LGPL), same as SDL and other libs

Enough? :->

Quote:
2. Instead of using the LGPL with the added clause that the library can be statically linked without releasing the source, why not use something like the MIT License?


Nothing important, I'm used to releasing all of my projects under GPL/LGPL, and so I couldn't resist to do the same in this case, too.

Quote:
3. What are the advantages of SDL_Config vs using XML in the config files and something like tinyxml to parse it?


There are many differences between them, but instead of writing tons of essays, I will link here.

Generally speaking, (assuming you're an experienced programmer, who knows XML etc.) if you don't need the whole power of XML, you may use config files. Heck, config files == INI files, and they were used rather often by authors of Windows and are used even now, by many programs (eg. DevCpp, open any .dev file in Notepad and you'll see). Also, parsing config files should be faster and more memory efficient than XML. They are simplier to write/edit, should be enough easiliy understandable by end-user, so that he should be able to edit them without problems. Ie.

[Video]    screen_size_x = 640    screen_size_y = 480    color_depth = 32

Koshmaar
Koshmaar
Hmmm, one little question. What would be your candidate for implementation in next SDL_Config version?

1. Unicode string handling
2. Multiple value entries, ie.

  // each value is separated by a colon  map_rotator = "level_001.lev", "level_004.lev", "test.lev"  vertex_color = 255, 244, 128, 255 


3. "Definitions", ie.

  system_path = "C:\Windows\"  temp_path = ${system_path}"temp\" // after substituting ${system_path} with "C:\Windows\",                                    // temp_path will be equal to "C:\Windows\temp" 



So, what is your oppinion? I can implement only one of them at a time...
Ilankt
Ilankt
Sound preety nice, I'll have a look at it.
It may be the thing I just need for my project, will save me some time.
How appropriate, you fight like a cow!
Ilankt
Ilankt
Huh? what survey?
How appropriate, you fight like a cow!
Koshmaar
Koshmaar
Hmmm, not survey, but "survey" - see my post which is immediately above your first one.

TDragon: yes, that's true, it will be hard to incorporate "definitions" into SDL_Config, especially knowing all about its implementation... [embarrass] However, "definitions", if implemented properly, could become quite powerfull feature (for the same reasons that #define roxxx in C/C++ [wink], but without problems [usually accompanied] with them in programming languages).

And that's why I want to hear from "potential users" what they want most - so far, there's 0:1:0 in Unicode:multiple_values:definitions match.
Ilankt
Ilankt
Defenetly multiple values :-P
How appropriate, you fight like a cow!
Iftah
Iftah
I vote: multi value lines

I will use your lib for simple configs (such as keyboard setup and resolution) so i dont need "definitions". Unicode may be nice since Im planning to make my game in more than english.

I see you added an example on how to use the lib, excellent :)
I appreciate the hard work you put into the API docs but I much more prefer examples/tutorials.
So if you ask me I prefer more example of existing features before new features.


Iftah.


Koshmaar
Koshmaar
Ok, thanks for your oppinion :-)

Once I planned to add one little example, below description of every function in API, of how it should be used - but OTOH, it would increase size of API for more than 40%, and would make navigation more troublesome. So, I asked about it here on forums, but no one answered - and because of it, I decided to wait with it at least to next lib version.

Sooo... now it looks that TODO list should look like this:

1. Improve documentation (examples)
2. Multiple values per entry
3. Unicode
4. "Definitions"

Hopefully, 1 && 2 will go to the SDL_Config 0.5.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.