mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 20:51:16 +00:00
Added long key
This commit is contained in:
@@ -358,10 +358,10 @@ namespace YAML
|
|||||||
|
|
||||||
void Emitter::BlockMapPrepareNode(EmitterNodeType::value child)
|
void Emitter::BlockMapPrepareNode(EmitterNodeType::value child)
|
||||||
{
|
{
|
||||||
const std::size_t childCount = m_pState->CurGroupChildCount();
|
if(m_pState->CurGroupChildCount() % 2 == 0) {
|
||||||
|
if(m_pState->GetMapKeyFormat() == LongKey)
|
||||||
if(childCount % 2 == 0) {
|
m_pState->SetLongKey();
|
||||||
if(m_pState->GetMapKeyFormat() == LongKey || child == EmitterNodeType::BlockSeq || child == EmitterNodeType::BlockMap)
|
if(child == EmitterNodeType::BlockSeq || child == EmitterNodeType::BlockMap)
|
||||||
m_pState->SetLongKey();
|
m_pState->SetLongKey();
|
||||||
|
|
||||||
if(m_pState->CurGroupLongKey())
|
if(m_pState->CurGroupLongKey())
|
||||||
@@ -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)
|
void Emitter::BlockMapPrepareSimpleKey(EmitterNodeType::value child)
|
||||||
{
|
{
|
||||||
const unsigned curIndent = m_pState->CurIndent();
|
const unsigned curIndent = m_pState->CurIndent();
|
||||||
@@ -439,30 +467,6 @@ namespace YAML
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
void Emitter::BlockMapPrepareSimpleKeyValue(EmitterNodeType::value child)
|
||||||
{
|
{
|
||||||
const unsigned curIndent = m_pState->CurIndent();
|
const unsigned curIndent = m_pState->CurIndent();
|
||||||
|
@@ -8,7 +8,9 @@ int main()
|
|||||||
out << YAML::BeginMap;
|
out << YAML::BeginMap;
|
||||||
out << "a" << "b";
|
out << "a" << "b";
|
||||||
out << YAML::EndMap;
|
out << YAML::EndMap;
|
||||||
out << "c";
|
out << YAML::BeginMap;
|
||||||
|
out << "a" << "b";
|
||||||
|
out << YAML::EndMap;
|
||||||
out << YAML::EndMap;
|
out << YAML::EndMap;
|
||||||
|
|
||||||
std::cout << out.c_str() << "\n";
|
std::cout << out.c_str() << "\n";
|
||||||
|
Reference in New Issue
Block a user