#include <msp/io/file.h>
#include <msp/datafile/parser.h>
#include <msp/datafile/statement.h>
-#include <msp/datafile/writer.h>
#include "compiler.h"
#include "tool.h"
void DataTool::do_transfer()
{
IO::Base *out = open_output(out_fn);
- DataFile::Writer writer(*out);
- set_writer_parameters(writer);
+ DataFile::Writer *writer = create_writer(*out);
for(vector<string>::const_iterator i=in_fns.begin(); i!=in_fns.end(); ++i)
{
{
DataFile::Statement st = parser.parse();
if(st.valid)
- writer.write(st);
+ writer->write(st);
}
delete in;
}
+ delete writer;
delete out;
}
void DataTool::do_compile()
{
IO::Base *out = open_output(out_fn);
- DataFile::Writer writer(*out);
- set_writer_parameters(writer);
+ DataFile::Writer *writer = create_writer(*out);
- Compiler compiler(writer);
+ Compiler compiler(*writer);
for(vector<string>::const_iterator i=in_fns.begin(); i!=in_fns.end(); ++i)
{
IO::Base *in = open_input(*i);
delete in;
}
+ delete writer;
delete out;
}
return new IO::BufferedFile(fn, IO::M_READ);
}
-void DataTool::set_writer_parameters(DataFile::Writer &writer)
+DataFile::Writer *DataTool::create_writer(IO::Base &out)
{
+ DataFile::Writer *writer = new DataFile::Writer(out);
if(compress)
- writer.set_compressed();
+ writer->set_compressed();
if(binary)
- writer.set_binary(true);
+ writer->set_binary(true);
if(float_size)
- writer.set_float_precision(float_size);
+ writer->set_float_precision(float_size);
+ return writer;
}
#include <string>
#include <msp/core/application.h>
+#include <msp/datafile/writer.h>
class DataTool: public Msp::RegisteredApplication<DataTool>
{
void do_compile();
Msp::IO::Base *open_output(const std::string &);
Msp::IO::Base *open_input(const std::string &);
- void set_writer_parameters(Msp::DataFile::Writer &);
+public:
+ Msp::DataFile::Writer *create_writer(Msp::IO::Base &);
};
#endif