tags:

views:

125

answers:

0

I don't quite understand how to use application specific YAML tags, and maybe its because my desired use of them is purely wrong. I am using YAML for a configuration file and was hoping to use tags to provide my configuration loader with a hint as to what datatype it should parse the data into - application specific datatypes.

I'm also using libyaml with C.

So I'm trying to do something like...

shapes:  
  square: "0,4,8,16"  
  circle: "5,10"

In my app I'd like to use tags as hints so I can load the values of square into my square data structure, and the values of circle into my circle data structure (these values mean nothing in this example).

So I'm currently doing:

shapes:  
  square: !square "0,4,8,16"  
  circle: !circle "5,10"

Libyaml will provide a tag of "!square" when I'm passed the scalar "0,4,8,16". Is it valid to use this tag to provide my loader with a hint of how to process the scalar?

Since it does work for me, I'm more curious to know if its proper. And if not, how would I go about making this more proper.

Thanks.