43 #define ANYINDEX_VERSION \ 44 "ANYINDEX V1.6 create index of data files" 50 #include <tfxx/commandline.h> 51 #include <tfxx/error.h> 52 #include <tfxx/stringfunc.h> 53 #include <tfxx/seitosh.h> 54 #include <datrwxx/readany.h> 55 #include <datrwxx/debug.h> 56 #include <sffostream.h> 71 int main(
int iargc,
char* argv[])
78 "usage: anyindex [-v] [-a] [-o] [-t type] [-D] [-r]" "\n" 79 " [-Fbonjer] [-Fsff] [-Fpdas] [-Fhpmo]" "\n" 80 " file [file ...] outfile" "\n" 81 " or: anyindex --help|-h" "\n" 82 " or: anyindex --fhelp type" "\n" 88 "-fhelp type print online help for file format \"type\"\n" 91 "-a append to outfile" "\n" 92 "-o overwrite outfile" "\n" 93 "-r explicitely read all samples (default: skip)" "\n" 94 "-t format select data format or use one of the shortcuts below" "\n" 95 "-Fsff input format is SFF" "\n" 96 "-Fhpmo input format is multiplexed ASCII format" "\n" 97 " defined by WG for BFO HP-MO data acquisition system" "\n" 98 "-Fpdas input format is PDAS100 (i.e. DaDisp)" "\n" 99 "-Fbonjer input format is defined by K. Bonjer for" "\n" 100 " K2 ASCII data" "\n" 101 "-D produce debugging output" "\n" 102 "file ... file(s) to read data from" "\n" 103 "outfile out file (index)" "\n" 107 using namespace tfxx::cmdline;
108 static Declare options[]=
121 {
"Fhpmo",arg_no,
"-"},
123 {
"Fpdas",arg_no,
"-"},
125 {
"Fbonjer",arg_no,
"-"},
129 {
"DEBUG",arg_no,
"-"},
133 {
"fhelp",arg_yes,
"sff"},
140 cerr << usage_text << endl;
141 cerr << tfxx::seitosh::repository_reference << endl;
146 Commandline cmdline(iargc, argv, options);
149 if (cmdline.optset(0) || cmdline.optset(11))
151 cerr << usage_text << endl;
152 cerr << help_text << endl << endl;
153 if (cmdline.optset(11))
155 datrw::online_help(cmdline.string_arg(11), cerr,
true);
159 datrw::supported_data_types(cerr);
161 cerr << endl << tfxx::seitosh::repository_reference << endl;
169 opt.
append=cmdline.optset(2);
171 opt.
format=datrw::anyID(datrw::Fsff);
172 if (cmdline.optset(5)) { opt.
format=datrw::anyID(datrw::Fhpmo); }
173 if (cmdline.optset(6)) { opt.
format=datrw::anyID(datrw::Fpdas); }
174 if (cmdline.optset(7)) { opt.
format=datrw::anyID(datrw::Fbonjer); }
175 if (cmdline.optset(8)) { opt.
format=cmdline.string_arg(8); }
176 opt.
debug=cmdline.optset(9);
179 tfxx::string::trimws(opt.
format);
181 { cout <<
"selected data type: " << opt.
format << endl; }
183 TFXX_assert(opt.
format.find(
" ")==std::string::npos,
184 "ERROR: using white space in format modifiers will fail " 185 "when reading index file");
190 TFXX_assert(cmdline.extra(),
"ERROR: missing input file!");
191 outfile=cmdline.next();
193 while (cmdline.extra())
195 infiles.push_back(outfile);
196 outfile=cmdline.next();
198 TFXX_assert((infiles.size()>0),
"ERROR: missing output file!");
201 std::ios_base::openmode ofopenmode;
204 ofopenmode=std::ios_base::out|std::ios_base::app|std::ios_base::app;
210 std::ifstream file(outfile.c_str(),std::ios_base::in);
211 TFXX_assert((!file.good()),
"ERROR: output file exists!");
213 ofopenmode=std::ios_base::out;
215 std::ofstream os(outfile.c_str(), ofopenmode);
217 Tvecofstrings::const_iterator infile=infiles.begin();
218 while( infile!=infiles.end())
221 { cout <<
"** open next file: " << *infile << endl; }
222 std::ifstream ifs(infile->c_str(),
223 datrw::ianystream::openmode(opt.
format));
227 if (is.last() && opt.
debug) { cout <<
"LAST!" << endl; }
232 { cout <<
"**** read next trace: #" << ntrace << endl; }
235 datrw::Tdseries series;
244 os << *infile <<
" " << ntrace <<
" " <<
246 DATRW_debug(opt.
debug,
"anyindex main()",
247 "prepare WIDX line");
248 if (opt.
debug) { sff::verbose(std::cerr, wid2); }
249 std::string widx=sff::WIDXline(wid2, opt.
debug);
250 DATRW_debug(opt.
debug,
"anyindex main()",
std::vector< std::string > Tvecofstrings
int main(int iargc, char *argv[])
std::vector< std::string > Tvecofstrings