Is it possible to emit and read(parse) binary data(image, file etc)? Like this is shown here: http://yaml.org/type/binary.html How can I do this in yaml-cpp?
A:
As of revision 425, yes! (for emitting)
YAML::Emitter emitter;
emitter << YAML::Binary("Hello, World!", 13);
std::cout << emitter.c_str();
outputs
--- !!binary "SGVsbG8sIFdvcmxkIQ=="
The syntax is
YAML::Binary(const char *bytes, std::size_t size);
I wasn't sure how to pass the byte array: char
isn't necessarily one byte, so I'm not sure how portable the algorithm is. What format is your byte array typically in?
(The problem is that uint8_t
isn't standard C++ yet, so I'm a little worried about using it.)
As for parsing, yaml-cpp
will certainly parse the data as a string, but there's no decoding algorithm yet.
Jesse Beder
2010-10-28 23:14:43