mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
Added long key
This commit is contained in:
@@ -358,22 +358,22 @@ namespace YAML
|
||||
|
||||
void Emitter::BlockMapPrepareNode(EmitterNodeType::value child)
|
||||
{
|
||||
const std::size_t childCount = m_pState->CurGroupChildCount();
|
||||
|
||||
if(childCount % 2 == 0) {
|
||||
if(m_pState->GetMapKeyFormat() == LongKey || child == EmitterNodeType::BlockSeq || child == EmitterNodeType::BlockMap)
|
||||
m_pState->SetLongKey();
|
||||
|
||||
if(m_pState->CurGroupLongKey())
|
||||
BlockMapPrepareLongKey(child);
|
||||
else
|
||||
BlockMapPrepareSimpleKey(child);
|
||||
} else {
|
||||
if(m_pState->CurGroupLongKey())
|
||||
BlockMapPrepareLongKeyValue(child);
|
||||
else
|
||||
BlockMapPrepareSimpleKeyValue(child);
|
||||
}
|
||||
if(m_pState->CurGroupChildCount() % 2 == 0) {
|
||||
if(m_pState->GetMapKeyFormat() == LongKey)
|
||||
m_pState->SetLongKey();
|
||||
if(child == EmitterNodeType::BlockSeq || child == EmitterNodeType::BlockMap)
|
||||
m_pState->SetLongKey();
|
||||
|
||||
if(m_pState->CurGroupLongKey())
|
||||
BlockMapPrepareLongKey(child);
|
||||
else
|
||||
BlockMapPrepareSimpleKey(child);
|
||||
} else {
|
||||
if(m_pState->CurGroupLongKey())
|
||||
BlockMapPrepareLongKeyValue(child);
|
||||
else
|
||||
BlockMapPrepareSimpleKeyValue(child);
|
||||
}
|
||||
}
|
||||
|
||||
void Emitter::BlockMapPrepareLongKey(EmitterNodeType::value child)
|
||||
@@ -410,6 +410,34 @@ namespace YAML
|
||||
}
|
||||
}
|
||||
|
||||
void Emitter::BlockMapPrepareLongKeyValue(EmitterNodeType::value child)
|
||||
{
|
||||
const unsigned curIndent = m_pState->CurIndent();
|
||||
const unsigned nextIndent = curIndent + m_pState->CurGroupIndent();
|
||||
|
||||
if(child == EmitterNodeType::None)
|
||||
return;
|
||||
|
||||
if(!m_pState->HasBegunContent()) {
|
||||
m_stream << "\n";
|
||||
m_stream << IndentTo(curIndent);
|
||||
m_stream << ":";
|
||||
}
|
||||
|
||||
switch(child) {
|
||||
case EmitterNodeType::None:
|
||||
break;
|
||||
case EmitterNodeType::Property:
|
||||
case EmitterNodeType::Scalar:
|
||||
case EmitterNodeType::FlowSeq:
|
||||
case EmitterNodeType::FlowMap:
|
||||
case EmitterNodeType::BlockSeq:
|
||||
case EmitterNodeType::BlockMap:
|
||||
SpaceOrIndentTo(true, nextIndent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Emitter::BlockMapPrepareSimpleKey(EmitterNodeType::value child)
|
||||
{
|
||||
const unsigned curIndent = m_pState->CurIndent();
|
||||
@@ -438,31 +466,7 @@ namespace YAML
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Emitter::BlockMapPrepareLongKeyValue(EmitterNodeType::value child)
|
||||
{
|
||||
const unsigned curIndent = m_pState->CurIndent();
|
||||
const unsigned nextIndent = curIndent + m_pState->CurGroupIndent();
|
||||
|
||||
if(!m_pState->HasBegunNode()) {
|
||||
}
|
||||
|
||||
switch(child) {
|
||||
case EmitterNodeType::None:
|
||||
break;
|
||||
case EmitterNodeType::Property:
|
||||
case EmitterNodeType::Scalar:
|
||||
case EmitterNodeType::FlowSeq:
|
||||
case EmitterNodeType::FlowMap:
|
||||
SpaceOrIndentTo(true, nextIndent);
|
||||
break;
|
||||
case EmitterNodeType::BlockSeq:
|
||||
case EmitterNodeType::BlockMap:
|
||||
m_stream << "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Emitter::BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child)
|
||||
{
|
||||
const unsigned curIndent = m_pState->CurIndent();
|
||||
|
@@ -8,7 +8,9 @@ int main()
|
||||
out << YAML::BeginMap;
|
||||
out << "a" << "b";
|
||||
out << YAML::EndMap;
|
||||
out << "c";
|
||||
out << YAML::BeginMap;
|
||||
out << "a" << "b";
|
||||
out << YAML::EndMap;
|
||||
out << YAML::EndMap;
|
||||
|
||||
std::cout << out.c_str() << "\n";
|
||||
|
Reference in New Issue
Block a user