71 "usage: any2any [--verbose] [--overwrite] [--integer] [--single]" "\n" 72 " [--itype t] [--otype t] [--vconversion]" "\n" 73 " outfile infile [t:T] [f:F] [infile [t:T] [f:F] ... ]" "\n" 74 " or: any2any --help|-h" "\n" 75 " or: any2any --xhelp" "\n" 81 "Options may be abbreviated to a short string as long as they" "\n" 82 "remain unique. \"-v\" is identical to \"--verbose\"." "\n" 84 "--verbose be verbose" "\n" 85 "--vconversion be verbose on type conversion" "\n" 86 "--overwrite overwrite output if file already exists" "\n" 87 "--integer use integer values for copying" "\n" 88 "--single use single precision floats for copying" "\n" 89 " default data type for copying is double presicion floats\n" 90 "--itype t standard format of input file(s) (see below)" "\n" 91 "--otype t data format of output file (see below)" "\n" 93 "outfile output data file name" "\n" 94 "infile input data file name" "\n" 96 "File specific options:" "\n" 97 "t:T select specfic traces from input file" "\n" 98 " T can be a list of traces like \"1,4,5\" or" "\n" 99 " a range like \"6-19\" or mixed like \"5,8,12-17,20\"" "\n" 100 "f:F specify file format (overrides --itype setting)" "\n" 102 "The output format might not be able to store all header information" "\n" 103 "from the input data." "\n" 107 using namespace tfxx::cmdline;
108 static Declare options[]=
113 {
"xhelp",arg_no,
"-"},
115 {
"verbose",arg_no,
"-"},
117 {
"overwrite",arg_no,
"-"},
119 {
"itype",arg_yes,
"sff"},
121 {
"otype",arg_yes,
"sff"},
123 {
"DEBUG",arg_no,
"-"},
125 {
"integer",arg_no,
"-"},
127 {
"single",arg_no,
"-"},
129 {
"vconversion",arg_no,
"-"},
133 static const char tracekey[]=
"t";
134 static const char formatkey[]=
"f";
137 static const char* cmdlinekeys[]={tracekey, formatkey, 0};
145 cerr << usage_text << endl;
146 cerr << tfxx::seitosh::repository_reference << endl;
151 Commandline cmdline(iargc, argv, options);
154 if (cmdline.optset(0) || cmdline.optset(1))
156 cerr << usage_text << endl;
157 cerr << help_text << endl;
158 datrw::supported_data_types(cerr);
159 if (cmdline.optset(1))
162 datrw::online_help(cerr);
164 cerr << endl << tfxx::seitosh::repository_reference << endl;
174 opt.
debug=cmdline.optset(6);
176 opt.
single=cmdline.optset(8);
183 ::datrw::report_type_conversion();
187 TFXX_assert(cmdline.extra(),
"missing output file");
188 std::string outfile=cmdline.next();
189 TFXX_assert(cmdline.extra(),
"missing input file");
190 tfxx::cmdline::Tparsed arguments=parse_cmdline(cmdline, cmdlinekeys);
191 if ((arguments.size()>1) && opt.
verbose)
193 cout <<
"NOTICE: file specific information (SRCE line and file FREE)\n" 194 <<
" of the second and subsequent files might get lost!\n";
203 cout <<
"open output file " << outfile
206 if (!opt.
overwrite) { datrw::abort_if_exists(outfile); }
207 std::ofstream ofs(outfile.c_str(),
212 cout <<
"file data is stored in ";
214 switch (os.seriestype()) {
219 cout <<
"single precision floating point";
222 cout <<
"double precision floating point";
225 cout <<
"any desired";
228 TFXX_abort(
"output stream uses unknown variable type!");
230 cout <<
" variable type" << endl;
236 tfxx::cmdline::Tparsed::const_iterator infile=arguments.begin();
237 while (infile != arguments.end())
241 if (infile->haskey(formatkey))
242 { inputformat=infile->value(formatkey); }
245 cout <<
"open input file " << infile->name
246 <<
" of format " << inputformat << endl;
248 std::ifstream ifs(infile->name.c_str(),
249 datrw::ianystream::openmode(inputformat));
250 datrw::ianystream is(ifs, inputformat, opt.
debug);
261 if (os.handlesfilefree())
271 cout <<
" file FREE block is discarded." << endl;
279 if (os.handlessrce())
289 cout <<
" SRCE line is discarded." << endl;
299 typedef tfxx::RangeList<int> Trangelist;
300 bool doselect=infile->haskey(tracekey);
301 Trangelist traceranges=
302 tfxx::string::rangelist<Trangelist::Tvalue>(infile->value(tracekey));
307 if ((!doselect) || traceranges.contains(itrace))
310 { std::cout <<
" copy trace #" << itrace << std::endl; }
313 datrw::Tdseries dseries;
319 TFXX_assert(is.providesi(),
320 "ERROR: input data is not provided as integer values");
325 TFXX_assert(is.providesf(),
326 "ERROR: input data is not provided as " 327 "single precision floats");
332 TFXX_assert(is.providesd(),
333 "ERROR: input data is not provided as " 334 "double precision floats");
343 TFXX_debug(opt.
debug,
"any2any: trace header data availability",
344 " is.hasinfo(): " << is.hasinfo() <<
345 " is.hasfree(): " << is.hasfree());
350 if (os.handlesinfo())
355 TFXX_debug(opt.
debug,
"any2any: INFO data",
362 cout <<
" INFO line is discarded." << endl;
370 if (os.handlestracefree())
380 cout <<
" trace FREE block is discarded." << endl;
386 switch (os.seriestype()) {
390 cout <<
" WARNING: converting floating point data to integer!" 398 "converting double precision to single precision data!" 409 TFXX_abort(
"output stream uses unknown variable type!");
429 { std::cout <<
" skip trace #" << itrace << std::endl; }