PDA

View Full Version : YAML for FPC/Delphi?



Robert Kosek
09-09-2008, 02:42 PM
Hey all, I was thinking about using YAML (http://www.yaml.org/) as a configuration language for a project. YAML is simpler than XML, so it should be simple enough to do.

However, I cannot find if anyone has converted either headers for LibYAML or have made a native parser. It isn't even on Torry, which means it probably hasn't been released yet.

I'd kind of rather find completed, or even beta, work than try my own hand. :lol:

Edit: Syck (http://whytheluckystiff.net/syck/) might do well if I could find someone to compile it for me. I haven't got the tools. (C or C++, I dunno which.)

grudzio
12-09-2008, 05:35 PM
How about using JSON (www.json.org)? It is not as powerfull as YAML but there are two toolkits (http://www.torry.net/quicksearchd.php?String=json&Title=Yes) for Delphi/FPC available.

paul_nicholls
13-09-2008, 03:53 AM
Hi Robert,
I have used Lua (www.lua.org) as a configuration language in the past.
One example was for an Abalone OpenGL 3d game I was making. See the saved game example text file below:



CreateBoard(
" 1 1 1 1 1 " ,
" 1 1 1 1 1 1 " ,
" . . 1 1 1 . . " ,
" . . . . . . . . " ,
". . . . 3 . . . ." ,
" . . . . . . . . " ,
" . . 2 2 2 . . " ,
" 2 2 2 2 2 2 " ,
" 2 2 2 2 2 ")

ClearActivePlayers()

AddActivePlayer(1,180)
AddActivePlayer(2,0)

SoundManager.LoadSound("Marble-Marble","Marble-Marble.wav")
SoundManager.LoadSound("Marble-Board" ,"Marble-Board.wav")



I linked routines in the Delphi program to Lua and called them like so above.

I have also used Lua for just simple stuff like:



ScreenWidth=320
ScreenHeight=240
FullScreen=true


where I have read in the global Lua variables and used them to configure the program :)

You can make it as simple, or as complex as you want really.
cheers,
Paul