-/* $Id$
-
-This file is part of libmspdatafile
-Copyright © 2008 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#include <msp/core/getopt.h>
#include <msp/io/buffered.h>
#include <msp/io/console.h>
in_fn("-"),
out_fn("-"),
binary(false),
- compile(false)
+ compile(false),
+ float_size(0),
+ compress(false)
{
GetOpt getopt;
getopt.add_option('b', "binary", binary, GetOpt::NO_ARG);
getopt.add_option('c', "compile", compile, GetOpt::NO_ARG);
+ getopt.add_option('f', "float-size", float_size, GetOpt::REQUIRED_ARG);
getopt.add_option('o', "output", out_fn, GetOpt::REQUIRED_ARG);
+ getopt.add_option('z', "compress", compress, GetOpt::NO_ARG);
getopt(argc, argv);
- const vector<string> &args=getopt.get_args();
+ const vector<string> &args = getopt.get_args();
if(!args.empty())
- in_fn=args[0];
+ in_fn = args[0];
}
int DataTool::main()
{
IO::Base *in;
if(in_fn=="-")
- in=&IO::cin;
+ in = &IO::cin;
else
- in=new IO::File(in_fn);
+ in = new IO::File(in_fn);
IO::Base *out;
if(out_fn=="-")
- out=&IO::cout;
+ out = &IO::cout;
else
- out=new IO::File(out_fn, IO::M_WRITE);
+ 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(compress)
+ writer.set_compressed();
if(binary)
writer.set_binary(true);
+ if(float_size)
+ writer.set_float_precision(float_size);
if(compile)
{
{
while(parser)
{
- DataFile::Statement st=parser.parse();
+ DataFile::Statement st = parser.parse();
if(st.valid)
{
writer.write(st);
return 0;
}
-
-Application::RegApp<DataTool> DataTool::reg;