Ways of using config files
Of course, those are only examples - I'm sure you will be able to think of dozens of others uses for config files - you are limited only by your imagination ;-)
One most obvious usage of config files, is to store inside it values across sessions:
current_player = "Player1"
name = "Krzesimir"
score = 34500
key_up = 63
key_down = 65
key_left = 64
key_right = 66
key_fire = 32
name = "Genowefa Ludomira Pigwa"
score = 5678
key_up = 45
key_down = 47
key_left = 46
key_right = 43
key_fire = 44
You might be storing you application settings:
// real life example from my engine Sculpture Clay 2
application_name = "Renderer test"
main_log_name = "ren_log(htm)"
memory_mgr_log_name = "ren_mem_mgr(htm)"
gfx_log_name = "ren_gfx_log(htm)"
name = main
window_size = 800, 600
window_bpp = 32
window_fullscreen = false
caps_min_zbuffer_value = 0.0
caps_max_zbuffer_value = 600.0
caps_surface_type = sw
cameras = main
name = "main"
position = -50.0, -50.0
clipping_rect = 0.0, 0.0, 0.5, 1.0
If you think that I'm the only one using them in this way... think again. Here's the excerpt from SDL_Config.dev (.dev files are used by DevCpp to store project settings) file viewed in notepad:
FileDescription=Developed using the Dev-C++ IDE
Instead of XML files - groups in config files can be fake nested, ie:
// some entries describing robot's general attributes, ie.
name = "Blashak"
type = "Hunter Killer"
[Robot / Appearance]
// other entries that describe how it looks, ie.
model = "robot.md3"
sound = "robot.ogg"
[Robot / AI]
aggresive = true
passive = no
objective = "kill everything that moves"
Separator used in this example is /, but of course, it's fake, there's no real nesting, groups aren't connected in SDL_Config in any way. It's up to you, to know this structure and interpret it correctly after parsing takes place. You can use other separators: . , -, -> etc. as long as they don't mislead parser.
Posted by Koshmaar on December 31 2005 16:06:32 5131 Reads -
Copyright © Hubert "Koshmaar" Rutkowski 2005