X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftextwriter.cpp;h=2768462297e6fed397e31b8a7ae58e96b3110113;hb=cbd0ddd6ee033e46646bfb85d19232c816ea1eda;hp=68111c0d3038c9b6b4b0f1f0a70df6b436d0c167;hpb=27630d44298cb67e075c166f4421288cc8ca117e;p=libs%2Fdatafile.git diff --git a/source/textwriter.cpp b/source/textwriter.cpp index 68111c0..2768462 100644 --- a/source/textwriter.cpp +++ b/source/textwriter.cpp @@ -5,6 +5,8 @@ Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#include +#include #include "statement.h" #include "textwriter.h" @@ -13,7 +15,7 @@ using namespace std; namespace Msp { namespace DataFile { -TextWriter::TextWriter(ostream &o): +TextWriter::TextWriter(IO::Base &o): WriterMode(o) { } @@ -26,25 +28,25 @@ void TextWriter::write_(const Statement &st, unsigned level) { string indent(level, '\t'); - out<get_type()==STRING) - out<<'\"'<get_raw()<<'\"'; + IO::print(out, "\"%s\"", c_escape(i->get_raw(), false)); else if(i->get_type()==BOOLEAN) - out<<(i->get() ? "true" : "false"); + out.write(i->get() ? "true" : "false"); else - out<get_raw(); + out.write(i->get_raw()); } if(!st.sub.empty()) { - out<<'\n'<::const_iterator i=st.sub.begin(); i!=st.sub.end(); ++i) + IO::print(out, "\n%s{\n", indent); + for(list::const_iterator i = st.sub.begin(); i!=st.sub.end(); ++i) write_(*i, level+1); - out<