如何打印出 yaml::Node?
我尝试了许多不同的方法来做到这一点。我有一堆彼此嵌套的节点:
yaml::Node a;
a["foo"] = 3;
yaml::Node b;
b["baz"] = 7;
a["bar"] = b;
我只想将A打印到字符串上,这样我就可以看到YAML的样子。我已经尝试了以下操作:
a.as<std::string>()
以及
std:: string str;
a >> str;
第一个抛出异常,而第二个则没有编译。
我想念什么?感觉这应该非常容易。
I have tried many different ways to do this. I have a bunch of nodes nested under each other e.g:
yaml::Node a;
a["foo"] = 3;
yaml::Node b;
b["baz"] = 7;
a["bar"] = b;
I just want to print a to a string so I can see what the yaml looks like. I've tried the following:
a.as<std::string>()
as well as
std:: string str;
a >> str;
The first throws an exception while the second doesn't compile.
What am I missing? This feels like it should be very easy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用转储功能。 IE
Use the Dump function. i.e.
您可以使用
发射器
打印节点You can print Node using
Emitter