mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Switch to flow sequence when emitting an empty sequence
This commit is contained in:
@@ -349,12 +349,18 @@ namespace YAML
|
|||||||
|
|
||||||
EMITTER_STATE curState = m_pState->GetCurState();
|
EMITTER_STATE curState = m_pState->GetCurState();
|
||||||
FLOW_TYPE flowType = m_pState->GetCurGroupFlowType();
|
FLOW_TYPE flowType = m_pState->GetCurGroupFlowType();
|
||||||
if(flowType == FT_BLOCK)
|
if(flowType == FT_BLOCK) {
|
||||||
assert(curState == ES_DONE_WITH_BLOCK_SEQ_ENTRY);
|
// Note: block sequences are *not* allowed to be empty, but we convert it
|
||||||
else if(flowType == FT_FLOW) {
|
// to a flow sequence if it is
|
||||||
m_stream << "]";
|
assert(curState == ES_DONE_WITH_BLOCK_SEQ_ENTRY || curState == ES_WAITING_FOR_BLOCK_SEQ_ENTRY);
|
||||||
|
if(curState == ES_WAITING_FOR_BLOCK_SEQ_ENTRY) {
|
||||||
|
unsigned curIndent = m_pState->GetCurIndent();
|
||||||
|
m_stream << IndentTo(curIndent) << "[]";
|
||||||
|
}
|
||||||
|
} else if(flowType == FT_FLOW) {
|
||||||
// Note: flow sequences are allowed to be empty
|
// Note: flow sequences are allowed to be empty
|
||||||
assert(curState == ES_DONE_WITH_FLOW_SEQ_ENTRY || curState == ES_WAITING_FOR_FLOW_SEQ_ENTRY);
|
assert(curState == ES_DONE_WITH_FLOW_SEQ_ENTRY || curState == ES_WAITING_FOR_FLOW_SEQ_ENTRY);
|
||||||
|
m_stream << "]";
|
||||||
} else
|
} else
|
||||||
assert(false);
|
assert(false);
|
||||||
|
|
||||||
@@ -685,3 +691,4 @@ namespace YAML
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user