Rewrote the output so that it emits correct YAML.

Fixed a bug in the last newline of a block folded scalar.
This commit is contained in:
Jesse Beder
2008-07-05 05:28:23 +00:00
parent d98007b0be
commit dacc631968
12 changed files with 98 additions and 145 deletions

27
map.cpp
View File

@@ -125,22 +125,27 @@ namespace YAML
}
}
void Map::Write(std::ostream& out, int indent)
void Map::Write(std::ostream& out, int indent, bool startedLine, bool onlyOneCharOnLine)
{
for(int i=0;i<indent;i++)
out << " ";
out << "{map}\n";
if(startedLine && !onlyOneCharOnLine)
out << std::endl;
for(node_map::const_iterator it=m_data.begin();it!=m_data.end();++it) {
for(int i=0;i<indent + 1;i++)
out << " ";
out << "{key}\n";
it->first->Write(out, indent + 2);
if((startedLine && !onlyOneCharOnLine) || it != m_data.begin()) {
for(int i=0;i<indent;i++)
out << " ";
}
for(int i=0;i<indent + 1;i++)
out << "? ";
it->first->Write(out, indent + 1, true, it!= m_data.begin() || !startedLine || onlyOneCharOnLine);
for(int i=0;i<indent;i++)
out << " ";
out << "{value}\n";
it->second->Write(out, indent + 2);
out << ": ";
it->second->Write(out, indent + 1, true, true);
}
if(m_data.empty())
out << std::endl;
}
}