3 This file is part of libmspdatafile
4 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/strings/utils.h>
10 #include "textwriter.h"
17 TextWriter::TextWriter(ostream &o):
21 void TextWriter::write(const Statement &st)
26 void TextWriter::write_(const Statement &st, unsigned level)
28 string indent(level, '\t');
30 out<<indent<<st.keyword;
31 for(ValueArray::const_iterator i=st.args.begin(); i!=st.args.end(); ++i)
34 if(i->get_type()==STRING)
35 out<<'\"'<<c_escape(i->get_raw(), false)<<'\"';
36 else if(i->get_type()==BOOLEAN)
37 out<<(i->get<bool>() ? "true" : "false");
43 out<<'\n'<<indent<<"{\n";
44 for(list<Statement>::const_iterator i=st.sub.begin(); i!=st.sub.end(); ++i)
51 } // namespace DataFile