AGS Engine

Further development of AGS engine

Feature Issue: INI File Reader/Writer

Pages: [1]

Crimson Wizard

  • AGSer
  • Posts: 2,536
  • not et suppotreD
« on: 09 Jul 2012, 14:29 »
A separate class for reading values by keys from ini file (for reading ASG setup).

Probably this would be nice if there was a parent class for reading keys/values from a tree-like data structure. Then it will be easier to chnage underlying implementation from ini file to something else if we want in the future.

Joseph DiPerla

  • AGSer
  • Posts: 1,083
  • Joseph DiPerla, Adventure Game Creator Wannabe!
« Reply #1 on: 09 Jul 2012, 15:04 »
How about an XML reading class?
Joseph DiPerla--- http://www.adventurestockpile.com
Member in this community since before 1999.
-The oldest member without ever making a full game...

Crimson Wizard

  • AGSer
  • Posts: 2,536
  • not et suppotreD
« Reply #2 on: 09 Jul 2012, 15:23 »
How about an XML reading class?
That's something I implied by saying "Then it will be easier to chnage underlying implementation from ini file to something else if we want in the future.", but since I do not know for sure if we ever need reading XML, I used that abstract "something else" ;)

JJS

  • AGSer
  • Posts: 303
« Reply #3 on: 09 Jul 2012, 16:25 »
Does it really have to be tree-like with arbitrary depth or doesn't ini-like with "category -> name -> value" suffice? I think this would be enough, especially since an ini file cannot represent a tree structure.

I don't like the idea of introducing an xml-parser dependency just for reading values that are equally well represented in an ini file.

But deriving from a generic base class is a good idea. I would allow handling of ini-files and maybe the Windows registry in derived classes.
Ask me about AGS on PSP, Android and iOS! Source, Bug tracker, Daily builds

Crimson Wizard

  • AGSer
  • Posts: 2,536
  • not et suppotreD
« Reply #4 on: 10 Jul 2012, 10:07 »
Does it really have to be tree-like with arbitrary depth or doesn't ini-like with "category -> name -> value" suffice? I think this would be enough, especially since an ini file cannot represent a tree structure.

I don't like the idea of introducing an xml-parser dependency just for reading values that are equally well represented in an ini file.
Yes, on second thought full XML-like support in base class is too much.
However, I suppose that simple tree-like structure could be useful for other purposes (including registry reading, which, unlike ini-file, can have nested "categories") and, on other hand, won't make reading from ini unnecessarily heavy code-wise; I am thinking about something like this:
(hypothetical example)
Code: C++
  1. CKeyValueTree *root = CKeyValueTree::Open(filename);
  2. CKeyValueTree *gfx = root->FindTree("graphics");
  3.  
  4. if (gfx)
  5. {
  6.    screen_width = gfx->ReadInt32("screenwidth", 320 /*default value*/);
  7.    screen_height = gfx->ReadInt32("screenheight", 240);
  8.    screen_bpp = gfx->ReadInt8("bpp", 16);
  9. }
  10.  
  11. CKeyValueTree *snd = root->FindTree("sound");
  12.  
  13. if (sound)
  14. {
  15.    sound_enabled = gfx->ReadBool("soundon", true);
  16. }
  17. ... etc ...
  18.  

Pages: [1]

Issue Details

  • Reported
    09 Jul 2012, 14:29
  • Updated
    10 Jul 2012, 10:07
  • View Status
    Public
  • Type
    Feature
  • Status
    New
  • Priority
    Normal
  • Version
    github.com/adventuregamestudio/ags
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    Internal

Tags



Powered by: SMF Project Tools 0.5.3 © Niko Pahajoki 2007-2011