--- /dev/null
+/* $Id$
+
+This file is part of libmspdatafile
+Copyright © 2006 Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#include "statement.h"
+#include "textwriter.h"
+
+using namespace std;
+
+namespace Msp {
+namespace DataFile {
+
+TextWriter::TextWriter(ostream &o):
+ WriterMode(o)
+{ }
+
+void TextWriter::write(const Statement &st)
+{
+ write_(st, 0);
+}
+
+void TextWriter::write_(const Statement &st, unsigned level)
+{
+ string indent(level, '\t');
+
+ out<<indent<<st.keyword;
+ for(ValueArray::const_iterator i=st.args.begin(); i!=st.args.end(); ++i)
+ {
+ out<<' ';
+ if(i->get_type()==STRING)
+ out<<'\"'<<i->get_raw()<<'\"';
+ else if(i->get_type()==BOOLEAN)
+ out<<(i->get<bool>() ? "true" : "false");
+ else
+ out<<i->get_raw();
+ }
+ if(!st.sub.empty())
+ {
+ out<<'\n'<<indent<<"{\n";
+ for(list<Statement>::const_iterator i=st.sub.begin(); i!=st.sub.end(); ++i)
+ write_(*i, level+1);
+ out<<indent<<'}';
+ }
+ out<<";\n";
+}
+
+} // namespace DataFile
+} // namespace Msp