mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
Added flow seq
This commit is contained in:
@@ -221,6 +221,15 @@ namespace YAML
|
||||
if(!good())
|
||||
return;
|
||||
|
||||
if(m_pState->CurGroupFlowType() == FlowType::Flow) {
|
||||
if(m_stream.comment())
|
||||
m_stream << "\n";
|
||||
m_stream << IndentTo(m_pState->CurIndent());
|
||||
if(m_pState->CurGroupChildCount() == 0)
|
||||
m_stream << "[";
|
||||
m_stream << "]";
|
||||
}
|
||||
|
||||
m_pState->EndedGroup(GroupType::Seq);
|
||||
}
|
||||
|
||||
@@ -315,6 +324,33 @@ namespace YAML
|
||||
|
||||
void Emitter::FlowSeqPrepareNode(EmitterNodeType::value child)
|
||||
{
|
||||
const unsigned curIndent = m_pState->CurIndent();
|
||||
const unsigned lastIndent = m_pState->LastIndent();
|
||||
|
||||
if(!m_pState->HasBegunNode()) {
|
||||
if(m_stream.comment())
|
||||
m_stream << "\n";
|
||||
m_stream << IndentTo(lastIndent);
|
||||
if(m_pState->CurGroupChildCount() == 0)
|
||||
m_stream << "[";
|
||||
else
|
||||
m_stream << ",";
|
||||
}
|
||||
|
||||
switch(child) {
|
||||
case EmitterNodeType::None:
|
||||
break;
|
||||
case EmitterNodeType::Property:
|
||||
case EmitterNodeType::Scalar:
|
||||
case EmitterNodeType::FlowSeq:
|
||||
case EmitterNodeType::FlowMap:
|
||||
SpaceOrIndentTo(m_pState->HasBegunContent() || m_pState->CurGroupChildCount() > 0, curIndent);
|
||||
break;
|
||||
case EmitterNodeType::BlockSeq:
|
||||
case EmitterNodeType::BlockMap:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Emitter::BlockSeqPrepareNode(EmitterNodeType::value child)
|
||||
|
@@ -188,6 +188,14 @@ namespace YAML
|
||||
return m_groups.empty() ? false : m_groups.top().longKey;
|
||||
}
|
||||
|
||||
int EmitterState::LastIndent() const
|
||||
{
|
||||
if(m_groups.size() <= 1)
|
||||
return 0;
|
||||
|
||||
return m_curIndent - m_groups.top(-1).indent;
|
||||
}
|
||||
|
||||
void EmitterState::ClearModifiedSettings()
|
||||
{
|
||||
m_modifiedSettings.clear();
|
||||
|
@@ -51,6 +51,7 @@ namespace YAML
|
||||
std::size_t CurGroupChildCount() const;
|
||||
bool CurGroupLongKey() const;
|
||||
|
||||
int LastIndent() const;
|
||||
int CurIndent() const { return m_curIndent; }
|
||||
bool HasAnchor() const { return m_hasAnchor; }
|
||||
bool HasTag() const { return m_hasTag; }
|
||||
|
@@ -4,11 +4,10 @@
|
||||
int main()
|
||||
{
|
||||
YAML::Emitter out;
|
||||
out << YAML::BeginMap;
|
||||
out << YAML::LongKey << "a" << "b";
|
||||
out << YAML::Flow;
|
||||
out << YAML::BeginSeq;
|
||||
out << "a" << "b";
|
||||
out << YAML::EndMap;
|
||||
out << YAML::EndMap;
|
||||
out << YAML::EndSeq;
|
||||
|
||||
std::cout << out.c_str() << "\n";
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user