mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 12:41:17 +00:00
Add flow/block style setting on Nodes
This commit is contained in:
@@ -51,7 +51,9 @@ bool convert<bool>::decode(const Node& node, bool& rhs) {
|
||||
// http://yaml.org/type/bool.html)
|
||||
static const struct {
|
||||
std::string truename, falsename;
|
||||
} names[] = {{"y", "n"}, {"yes", "no"}, {"true", "false"}, {"on", "off"}, };
|
||||
} names[] = {
|
||||
{"y", "n"}, {"yes", "no"}, {"true", "false"}, {"on", "off"},
|
||||
};
|
||||
|
||||
if (!IsFlexibleCase(node.Scalar()))
|
||||
return false;
|
||||
|
@@ -16,7 +16,10 @@ namespace detail {
|
||||
std::string node_data::empty_scalar;
|
||||
|
||||
node_data::node_data()
|
||||
: m_isDefined(false), m_type(NodeType::Null), m_seqSize(0) {}
|
||||
: m_isDefined(false),
|
||||
m_type(NodeType::Null),
|
||||
m_seqSize(0),
|
||||
m_style(EmitterStyle::Default) {}
|
||||
|
||||
void node_data::mark_defined() {
|
||||
if (m_type == NodeType::Undefined)
|
||||
@@ -57,6 +60,8 @@ void node_data::set_type(NodeType::value type) {
|
||||
|
||||
void node_data::set_tag(const std::string& tag) { m_tag = tag; }
|
||||
|
||||
void node_data::set_style(EmitterStyle::value style) { m_style = style; }
|
||||
|
||||
void node_data::set_null() {
|
||||
m_isDefined = true;
|
||||
m_type = NodeType::Null;
|
||||
|
@@ -54,6 +54,7 @@ void NodeBuilder::OnSequenceStart(const Mark& /* mark */,
|
||||
detail::node& node = Push(anchor);
|
||||
node.set_tag(tag);
|
||||
node.set_type(NodeType::Sequence);
|
||||
node.set_style(style);
|
||||
}
|
||||
|
||||
void NodeBuilder::OnSequenceEnd() { Pop(); }
|
||||
@@ -63,6 +64,7 @@ void NodeBuilder::OnMapStart(const Mark& /* mark */, const std::string& tag,
|
||||
detail::node& node = Push(anchor);
|
||||
node.set_type(NodeType::Map);
|
||||
node.set_tag(tag);
|
||||
node.set_style(style);
|
||||
m_mapDepth++;
|
||||
}
|
||||
|
||||
|
@@ -76,15 +76,14 @@ void NodeEvents::Emit(const detail::node& node, EventHandler& handler,
|
||||
handler.OnScalar(Mark(), node.tag(), anchor, node.scalar());
|
||||
break;
|
||||
case NodeType::Sequence:
|
||||
handler.OnSequenceStart(Mark(), node.tag(), anchor,
|
||||
EmitterStyle::Default);
|
||||
handler.OnSequenceStart(Mark(), node.tag(), anchor, node.style());
|
||||
for (detail::const_node_iterator it = node.begin(); it != node.end();
|
||||
++it)
|
||||
Emit(**it, handler, am);
|
||||
handler.OnSequenceEnd();
|
||||
break;
|
||||
case NodeType::Map:
|
||||
handler.OnMapStart(Mark(), node.tag(), anchor, EmitterStyle::Default);
|
||||
handler.OnMapStart(Mark(), node.tag(), anchor, node.style());
|
||||
for (detail::const_node_iterator it = node.begin(); it != node.end();
|
||||
++it) {
|
||||
Emit(*it->first, handler, am);
|
||||
|
Reference in New Issue
Block a user