35 #define BINARYTEST_VERSION \ 36 "BINARYTEST V1.0 test binary format I/O functions" 41 #include <tfxx/commandline.h> 42 #include <aff/seriesoperators.h> 45 #include <datrwxx/ibinstream.h> 46 #include <datrwxx/obinstream.h> 63 void values(
const char& out,
const char& in)
65 cout <<
"written to file: " << int(out) << endl;
66 cout <<
"read from file: " << int(in) << endl;
68 { cout <<
"* flag set: free" << endl; }
70 { cout <<
"* flag set: srce" << endl; }
72 { cout <<
"* flag set: info" << endl; }
74 { cout <<
"* flag set: double" << endl; }
76 { cout <<
"* flag set: float" << endl; }
78 { cout <<
"* flag set: int" << endl; }
86 cout <<
"written to file:" << endl;
87 ::sff::verbose(cout, out);
88 cout <<
"read from file:" << endl;
89 ::sff::verbose(cout, in);
97 cout <<
"written to file:" << endl;
99 cout <<
"read from file:" << endl;
101 cout <<
"residual:" << endl;
107 int main(
int iargc,
char* argv[])
114 "usage: binarytest [-v] [-iotest file] [-skip]" "\n" 115 " or: binarytest --help|-h" "\n" 123 "-iotest file execute fixed I/O test with file \"file\"\n" 124 "-skip skip samples of series, just count\n" 128 using namespace tfxx::cmdline;
129 static Declare options[]=
138 {
"iotest",arg_yes,
"-"},
145 cerr << usage_text << endl;
150 Commandline cmdline(iargc, argv, options);
153 if (cmdline.optset(0))
155 cerr << usage_text << endl;
156 cerr << help_text << endl;
163 opt.
iotest=cmdline.optset(3);
164 opt.
iofile=cmdline.string_arg(3);
198 for (
int i=iseries.f(); i<=iseries.l(); ++i)
200 for (
int i=dseries.f(); i<=dseries.l(); ++i)
201 { dseries(i)=double(i)*i; }
202 for (
int i=fseries.f(); i<=fseries.l(); ++i)
203 { fseries(i)=sin((i-fseries.f())*2.
204 *3.141592653589793115998/(fseries.size()-1)); }
212 wid2.date=libtime::TAbsoluteTime(2010,5,6,18,23,12,13,14);
216 wid2.instype=
"my seismometer type";
226 srce.type=
"my source type for this test";
227 srce.date=libtime::TAbsoluteTime(2006,1,1,9,15,12,345,678);
230 free.append(
"my free comment line");
238 const char*
const magic=
"B123";
241 std::ofstream ofs(opt.
iofile.c_str(),
242 std::ios_base::out|std::ios_base::binary);
258 std::ifstream ifs(opt.
iofile.c_str(),
259 std::ios_base::in|std::ios_base::binary);
272 cout <<
"skipped " << is.skipfseries() <<
" samples" << endl;
287 cout <<
"skipped " << is.skipdseries() <<
" samples" << endl;
302 values(
char(fflags), inflags);
304 values(
char(tflags), inflags);
308 cout <<
"skipped " << is.skipiseries() <<
" samples" << endl;
aff::Series< float > Tfseries
void values(const char &out, const char &in)
write raw binary data (prototypes)
const char *const magic
magic number to identify file type and bytesex
aff::Series< double > Tdseries
binary output for basic types and classes
int main(int iargc, char *argv[])
aff::Series< int > Tiseries
stream like class for binary input of basic types and classes
void dump(std::ostream &os, const SampleBlock &block)
dump one block of samples
#define BINARYTEST_VERSION
void reportseries(const C &out, const C &in)
void reportsff(const C &out, const C &in)