Added block seq indentation

This commit is contained in:
Jesse Beder 2012-05-21 21:04:10 -05:00
parent d86cfc1c63
commit b5d8241dfa
4 changed files with 18 additions and 2 deletions

View File

@ -312,6 +312,13 @@ namespace YAML
void Emitter::BlockSeqPrepareNode()
{
const unsigned curIndent = m_pState->CurIndent();
if(m_stream.col() > curIndent) {
m_stream << "\n";
}
m_stream << IndentTo(curIndent);
m_stream << "-";
m_stream << IndentTo(curIndent + m_pState->CurGroupIndent());
}
void Emitter::FlowMapPrepareNode()

View File

@ -61,8 +61,8 @@ namespace YAML
{
BeginNode();
unsigned lastIndent = (m_groups.empty() ? 0 : m_groups.top().indent);
m_curIndent += lastIndent;
const int lastGroupIndent = (m_groups.empty() ? 0 : m_groups.top().indent);
m_curIndent += lastGroupIndent;
std::auto_ptr<Group> pGroup(new Group(type));
@ -114,6 +114,11 @@ namespace YAML
return (m_groups.top().flow == Flow ? FlowType::Flow : FlowType::Block);
}
int EmitterState::CurGroupIndent() const
{
return m_groups.empty() ? 0 : m_groups.top().indent;
}
void EmitterState::ClearModifiedSettings()
{
m_modifiedSettings.clear();

View File

@ -39,6 +39,7 @@ namespace YAML
GroupType::value CurGroupType() const;
FlowType::value CurGroupFlowType() const;
int CurGroupIndent() const;
int CurIndent() const { return m_curIndent; }
bool HasAnchor() const { return m_hasAnchor; }
bool HasTag() const { return m_hasTag; }

View File

@ -4,7 +4,10 @@
int main()
{
YAML::Emitter out;
out << YAML::BeginSeq;
out << "foo";
out << "bar";
out << YAML::EndSeq;
std::cout << out.c_str() << "\n";
return 0;