2

as a part of a bigger project i create a graphical yaml-file editor in c++ (and Qt). I use the yaml-cpp library and everything works fine. Ist it possible to parse comments, too? Writing comments is no problem, but i did not find a solution to read them.

Thanks in advance, Filip

2 Answers2

3

This isn't possible (comments are not part of the representation graph, so they're not retained).

Jesse Beder
  • 33,081
  • 21
  • 109
  • 146
1

If I understand your question correctly, you could just add them as part of the data:

# This is an example yaml config file
_comment: This is a comment I would like to retain with my data
foo:
   _comment: Another one
   bar: 1
   baz: '2'
fie:
   bar: 3
   baz: "4"
fum:
   bar: 5
   baz: 6
stephenmm
  • 2,640
  • 3
  • 30
  • 48