Added emitting for a YAML::Node (instead of the ad-hoc std::ostream overload) so it'll actually emit valid YAML always

This commit is contained in:
Jesse Beder
2009-07-10 23:39:14 +00:00
parent 6c8600ab52
commit 3e0179fd6e
13 changed files with 136 additions and 202 deletions

View File

@@ -3,7 +3,7 @@
#include "node.h"
#include "scanner.h"
#include "token.h"
#include <iostream>
#include "emitter.h"
namespace YAML
{
@@ -133,23 +133,12 @@ namespace YAML
}
}
void Sequence::Write(std::ostream& out, int indent, bool startedLine, bool onlyOneCharOnLine)
void Sequence::Write(Emitter& out) const
{
if(startedLine && !onlyOneCharOnLine)
out << "\n";
for(unsigned i=0;i<m_data.size();i++) {
if((startedLine && !onlyOneCharOnLine) || i > 0) {
for(int j=0;j<indent;j++)
out << " ";
}
out << "- ";
m_data[i]->Write(out, indent + 1, true, i > 0 || !startedLine || onlyOneCharOnLine);
}
if(m_data.empty())
out << "\n";
out << BeginSeq;
for(unsigned i=0;i<m_data.size();i++)
out << *m_data[i];
out << EndSeq;
}
int Sequence::Compare(Content *pContent)