About merging and overriding

Alexis Guillaume <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
Hi everyone.

I was asked at work to implement some network protocol using a INI format. I was almost resigned when I heard for the first time about yaml and almost fell in love with it ;-) It's been a week now and I am trying to make a good case to use yaml instead of INI. As INI was chosen because of its extreme simplicity, one of the point I now have to make is that it is not *that* hard to load a yaml stream in memory (we have to use C++). That goal in mind, I am currently working on a test program which allows simple queries on *any* yaml file. It loads the yaml file (using libyaml) in a graph ; basically, each node is either a std::string (scalar), a std::vector of nodes (yaml sequence), a std::map of nodes (mapping) or pointer to another node (alias). In our final application, that graph would of
  course be used by a higher-level to read and write message according to our protocole description.

These are the few things that I still don't understand with yaml ; I haven't been able to find these answers by myself, yet I might have just not seen them in the various documents I read... Don't be afraid to RTFM me ! 

1) Am I right about aliasing ? When the parser sends me an alias event, should I create a fully duplicated node, should I keep a pointer to the original node or should that decision be taken at a higher application level ?

2) Is merging really supported in yaml ? It is not mentioned in the yaml spec and no specific merge event is sent by the parser. Currently, when my program finds a merge key (<<), it replaces it by a *copy* of all the key-value pairs of the referenced mapping. Is it the right thing to do or should I keep the merge key as if it were any other key and let a higher level of application handle the merging part ?  

3) When loading a mapping, how should my program behave when it encounters a duplicated key ? Should it produce an error and exit, allow the identical keys to peacefully cohabit in the graph, overrides the old key by the new one or, again, let a higher power decide of what to do ?


Thank you for you attention...
Alexis Guillaume.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.