如何为特定的yaml-cpp节点设置发射样式 [英] How to set an emit style for a particular yaml-cpp node

查看:164
本文介绍了如何为特定的yaml-cpp节点设置发射样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在发出YAML文档,如下所示:

I'm emitting a YAML document as follows:

YAML::Node doc; // ...populate doc...
YAML::Emitter out;
out << doc;

在节点的层次结构中,我有一个特定的序列,我想以Flow样式发出,而其他所有内容都应使用默认样式设置.

Somewhere in the hierarchy of nodes I have a particular sequence that I would like to emit in the Flow style while everything else should use the default style settings.

除了手动发出每个节点并注意我感兴趣的节点外,我似乎找不到其他方法.对于相对简单的东西来说,这似乎是一个很高的代价.

I can't seem to find any way of doing this other than emitting by hand every node and watching out for the nodes I'm interested in. This seems like a high price to pay for something relatively straightforward.

理想情况下,我希望能够将Node标记为如果您被激发,请使用以下样式进行标记".但我认为对此没有任何支持.

Ideally I'd like to be able to tag the Node to say "If you get emitted, do so with the following style". But I don't think there's any support for this.

有人能想到一种方法来手动发送整个文档吗?

Can anyone think of a way around having to emit the whole document by hand?

非常感谢.

推荐答案

此功能已按照您可以使用以下代码设置节点样式

You can set the node style with the following code

node.SetStyle(YAML::EmitterStyle::Flow);

node.SetStyle(YAML::EmitterStyle::Block);

这篇关于如何为特定的yaml-cpp节点设置发射样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆