#include <msp/core/application.h>
#include <msp/core/getopt.h>
#include <msp/io/buffered.h>
+#include <msp/io/console.h>
#include <msp/io/file.h>
#include "source/parser.h"
#include "source/statement.h"
{
IO::Base *in;
if(in_fn=="-")
- throw Exception("stdin/out not supported at the moment");
+ in=&IO::cin;
else
in=new IO::File(in_fn);
IO::Base *out;
if(out_fn=="-")
- throw Exception("stdin/out not supported at the moment");
+ out=&IO::cout;
else
out=new IO::File(out_fn, IO::M_WRITE);
- IO::Buffered in_buf(*in);
- DataFile::Parser parser(in_buf, in_fn);
- IO::Buffered out_buf(*out);
- DataFile::Writer writer(out_buf);
- if(binary)
- writer.set_binary(true);
-
- while(parser)
{
- DataFile::Statement st=parser.parse();
- if(st.valid)
- writer.write(st);
+ IO::Buffered in_buf(*in);
+ DataFile::Parser parser(in_buf, in_fn);
+ IO::Buffered out_buf(*out);
+ DataFile::Writer writer(out_buf);
+ if(binary)
+ writer.set_binary(true);
+
+ while(parser)
+ {
+ DataFile::Statement st=parser.parse();
+ if(st.valid)
+ {
+ writer.write(st);
+ out_buf.flush();
+ }
+ }
}
- //if(out!=&cout)
+ if(in!=&IO::cin)
+ delete in;
+ if(out!=&IO::cout)
delete out;
return 0;