mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Split the block map prepare into key/value
This commit is contained in:
@@ -92,6 +92,8 @@ namespace YAML
|
|||||||
void BlockSeqPrepareNode(EmitterNodeType::value child);
|
void BlockSeqPrepareNode(EmitterNodeType::value child);
|
||||||
void FlowMapPrepareNode(EmitterNodeType::value child);
|
void FlowMapPrepareNode(EmitterNodeType::value child);
|
||||||
void BlockMapPrepareNode(EmitterNodeType::value child);
|
void BlockMapPrepareNode(EmitterNodeType::value child);
|
||||||
|
void BlockMapPrepareKey(EmitterNodeType::value child);
|
||||||
|
void BlockMapPrepareValue(EmitterNodeType::value child);
|
||||||
|
|
||||||
void SpaceOrIndentTo(bool requireSpace, unsigned indent);
|
void SpaceOrIndentTo(bool requireSpace, unsigned indent);
|
||||||
|
|
||||||
|
@@ -357,59 +357,67 @@ namespace YAML
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Emitter::BlockMapPrepareNode(EmitterNodeType::value child)
|
void Emitter::BlockMapPrepareNode(EmitterNodeType::value child)
|
||||||
|
{
|
||||||
|
const std::size_t childCount = m_pState->CurGroupChildCount();
|
||||||
|
|
||||||
|
if(childCount % 2 == 0)
|
||||||
|
BlockMapPrepareKey(child);
|
||||||
|
else
|
||||||
|
BlockMapPrepareValue(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Emitter::BlockMapPrepareKey(EmitterNodeType::value child)
|
||||||
{
|
{
|
||||||
const unsigned curIndent = m_pState->CurIndent();
|
const unsigned curIndent = m_pState->CurIndent();
|
||||||
const unsigned nextIndent = curIndent + m_pState->CurGroupIndent();
|
const unsigned nextIndent = curIndent + m_pState->CurGroupIndent();
|
||||||
const std::size_t childCount = m_pState->CurGroupChildCount();
|
const std::size_t childCount = m_pState->CurGroupChildCount();
|
||||||
|
|
||||||
if(!m_pState->HasBegunNode()) {
|
if(!m_pState->HasBegunNode()) {
|
||||||
if(childCount % 2 == 0) {
|
if(childCount > 0) {
|
||||||
// key
|
m_stream << "\n";
|
||||||
if(childCount > 0) {
|
}
|
||||||
m_stream << "\n";
|
if(false /* long key */) {
|
||||||
}
|
|
||||||
if(false /* long key */) {
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// value
|
|
||||||
if(false /* was long key */) {
|
|
||||||
} else {
|
|
||||||
m_stream << ":";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(childCount % 2 == 0) {
|
switch(child) {
|
||||||
// key
|
case EmitterNodeType::None:
|
||||||
switch(child) {
|
break;
|
||||||
case EmitterNodeType::None:
|
case EmitterNodeType::Property:
|
||||||
break;
|
case EmitterNodeType::Scalar:
|
||||||
case EmitterNodeType::Property:
|
case EmitterNodeType::FlowSeq:
|
||||||
case EmitterNodeType::Scalar:
|
case EmitterNodeType::FlowMap:
|
||||||
case EmitterNodeType::FlowSeq:
|
SpaceOrIndentTo(m_pState->HasBegunContent(), curIndent);
|
||||||
case EmitterNodeType::FlowMap:
|
break;
|
||||||
SpaceOrIndentTo(m_pState->HasBegunContent(), curIndent);
|
case EmitterNodeType::BlockSeq:
|
||||||
break;
|
case EmitterNodeType::BlockMap:
|
||||||
case EmitterNodeType::BlockSeq:
|
break;
|
||||||
case EmitterNodeType::BlockMap:
|
}
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
void Emitter::BlockMapPrepareValue(EmitterNodeType::value child)
|
||||||
|
{
|
||||||
|
const unsigned curIndent = m_pState->CurIndent();
|
||||||
|
const unsigned nextIndent = curIndent + m_pState->CurGroupIndent();
|
||||||
|
|
||||||
|
if(false /* was long key */) {
|
||||||
} else {
|
} else {
|
||||||
// value
|
m_stream << ":";
|
||||||
switch(child) {
|
}
|
||||||
case EmitterNodeType::None:
|
|
||||||
break;
|
switch(child) {
|
||||||
case EmitterNodeType::Property:
|
case EmitterNodeType::None:
|
||||||
case EmitterNodeType::Scalar:
|
break;
|
||||||
case EmitterNodeType::FlowSeq:
|
case EmitterNodeType::Property:
|
||||||
case EmitterNodeType::FlowMap:
|
case EmitterNodeType::Scalar:
|
||||||
SpaceOrIndentTo(true, nextIndent);
|
case EmitterNodeType::FlowSeq:
|
||||||
break;
|
case EmitterNodeType::FlowMap:
|
||||||
case EmitterNodeType::BlockSeq:
|
SpaceOrIndentTo(true, nextIndent);
|
||||||
case EmitterNodeType::BlockMap:
|
break;
|
||||||
m_stream << "\n";
|
case EmitterNodeType::BlockSeq:
|
||||||
break;
|
case EmitterNodeType::BlockMap:
|
||||||
}
|
m_stream << "\n";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user