Save a YAML Emitter content to a file with YAML-CPP -
i started playing around yaml-cpp, managed build , run of examples yaml-cpp wiki can't find way save emitter file.
is not possible? mean pyyaml library has 'dump' function this. there no such functionality in yaml-cpp? there workaround converting yaml emitter stl stream , dumping yaml file?
please let me know
thanks, adam
the function emitter::c_str()
returns null
-terminated c-style string (which not have release), can write file. example:
yaml::emitter emitter; emitter << "hello world!"; std::ofstream fout("file.yaml"); fout << emitter.c_str();
there emitter::size()
, returns number of bytes in string, in case want more advanced , don't want walk string find length.
if want dump node
stream, there's shortcut:
yaml::node node = ...; std::ofstream fout("file.yaml"); fout << node;
Comments
Post a Comment