X-Git-Url: http://git.tdb.fi/?p=libs%2Fdatafile.git;a=blobdiff_plain;f=tool%2Ftool.cpp;h=5f9febeedda26d87a749551de4035d7ee6e07a30;hp=36ee5c4abd6e760162934417a8d8ae4b1f355333;hb=19179a622c1de88de5ed7047643eec79f285bf2a;hpb=52e6bd3e02522f68166c70f83d2ef3d7cf0c15ff diff --git a/tool/tool.cpp b/tool/tool.cpp index 36ee5c4..5f9febe 100644 --- a/tool/tool.cpp +++ b/tool/tool.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspdatafile -Copyright © 2008 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include #include @@ -22,32 +15,34 @@ DataTool::DataTool(int argc, char **argv): in_fn("-"), out_fn("-"), binary(false), - compile(false) + compile(false), + float_size(0) { 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(argc, argv); - const vector &args=getopt.get_args(); + const vector &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); @@ -56,6 +51,8 @@ int DataTool::main() DataFile::Writer writer(out_buf); if(binary) writer.set_binary(true); + if(float_size) + writer.set_float_precision(float_size); if(compile) { @@ -66,7 +63,7 @@ int DataTool::main() { while(parser) { - DataFile::Statement st=parser.parse(); + DataFile::Statement st = parser.parse(); if(st.valid) { writer.write(st); @@ -83,5 +80,3 @@ int DataTool::main() return 0; } - -Application::RegApp DataTool::reg;