5

Is there a C++ library for emitting YAML? Wikipedia mentions a c++ wrapper for libyaml, but the link is broken. The official YAML site only offers yaml-cpp, which was also suggested in this SO question, but cpp-yaml is only a parser, not an emitter. Am I out of luck?

Edit: I'm looking for an object oriented interface, hence the C++ requirement. I know I could use libyaml's C interface in C++ code, but that's less than ideal.

Community
  • 1
  • 1
Kyle Simek
  • 9,576
  • 4
  • 26
  • 32
  • I'm the author of yaml-cpp, and I've been meaning to write an emitter for some time, but since my own projects don't require one, I haven't been able to think of a good API. What kinds of things would you like to emit, and what would be an ideal user interface for you? If you leave a comment in the google code wiki, I'd be *very* appreciative! – Jesse Beder May 08 '09 at 05:57
  • Hi, Jesse. Its good to meet the one daring soul attempting a C++ YAML library. Considering the lack of response to my question, it sounds like you're the last best hope for what I'm looking for. I looked at the page late last night, but struggled with a good API; I'll spend some more time this weekend thinking about it. – Kyle Simek May 08 '09 at 20:32
  • Great! What kinds of YAML documents are you trying to generate? I haven't yet seen a non-artificially constructed example. – Jesse Beder May 08 '09 at 23:46
  • I want to use it as a serialization format for, well, everything. I'm starting a new project and I want to be to serialize all of my classes in a human-readable format. I'm not happy with XML's angle bracket tax (thanks, Jeff!), and a raw text output is difficult for human readers to parse. – Kyle Simek May 09 '09 at 05:29
  • OK, I've given it some thought in terms of serialization, and it gave me some ideas. Check out the wiki and let me know what you think (I tacked on the "Stream method" to the end). – Jesse Beder May 10 '09 at 21:17

2 Answers2

7

Per your suggestion, yaml-cpp now has an emitter.

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

How about libyaml ?

LibYAML is a YAML 1.1 parser and emitter written in C.

And, more directly, emitter.c ?

gimel
  • 83,368
  • 10
  • 76
  • 104