SDL_Config
Navigation
Home
Download
SourceForge project page
Web Links
About
Documentation
Introduction
Features
API

Tutorials:
Roadmap
Users
License
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"
    
      [Player1]
    
        name = "Krzesimir"
        score = 34500
    
        key_up = 63
        key_down = 65
        key_left = 64
        key_right = 66
        key_fire = 32
    
    
      [Player2]
    
        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)"
    
      [Window]
    
         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
    
      [Camera]
    
        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:
      [Project]
    
        FileName=SDL_Config.dev
        Name=SDL_Config
        UnitCount=4
        Type=2
        Ver=1
        ObjFiles=
        Includes=
        Libs=
        PrivateResource=
        ResourceIncludes=
        MakeIncludes=
        Compiler=_@@_
        CppCompiler=_@@_
        Linker=
        IsCpp=1
        Icon=
        ExeOutput=..\bin
        ObjectOutput=..\bin\obj
        OverrideOutput=0
        OverrideOutputName=SDL_Config.a
        HostApplication=
        Folders=
        CommandLine=
        UseCustomMakefile=0
        CustomMakefile=
        IncludeVersionInfo=0
        SupportXPThemes=0
        CompilerSet=0
        CompilerSettings=0000000001000000010100
    
      [Unit2]
    
        FileName=SDL_config_lib.h
        CompileCpp=1
        Folder=SDL_Config
        Compile=1
        Link=1
        Priority=1000
        OverrideBuildCmd=0
        BuildCmd=
    
      [VersionInfo]
    
        Major=0
        Minor=1
        Release=1
        Build=1
        LanguageID=1033
        CharsetID=1252
        CompanyName=
        FileVersion=
        FileDescription=Developed using the Dev-C++ IDE
        InternalName=
        LegalCopyright=
        LegalTrademarks=
        OriginalFilename=
        ProductName=
        ProductVersion=
        AutoIncBuildNr=0
     


  • Instead of XML files - groups in config files can be fake nested, ie:

    
      [Robot]
    
        // 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"
        // etc.
    
    

    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:325162 Reads - Print
Login
Username

Password



Forgotten your password?
Request a new one here.
Banners

SourceForge.net Logo

Get Firefox!

Copyright © Hubert "Koshmaar" Rutkowski 2005