DATRW++ library: seismic data I/O with multiple formats
Description of writing operation

All output streams are derived from datrw::odatstream. The interface of datrw::odatstream consequently defines the behaviour of all output stream classes. datrw::oanystream implements the same interface and behaviour. It is a general output stream, more or less, which selects one of the implemented stream classes based on the second parameter passed to its constructor datrw::oanystream::oanystream().

So, what happens when you are up to write a file?

Writing the file header

You create an instance of the output stream class by passing an C++ ostream (usually a std::ofstream opened with the appropriate open mode as indicated by openmode of the libdatrwxx output stream class, like datrw::osffstream::openmode) to which data should be written to the constructor of the stream class.

Then you can use the file header set functions

or the corresponding output operators to write file header data. The functions

tell you whether the specific output stream can handle file FREE block and SRCE data. This is not possible for all data formats.

A call to datrw::odatstream::setwid2() will flush the file header. Any subsequent call to datrw::odatstream::setfree() will pass a trace FREE block and not a file FREE block.

Writing samples to a trace

Prior to writing the actual time series, you have to pass the trace header data to the output stream. You can do this through the trace header set functions

or the corresponding output operators. A call to datrw::odatstream::setwid2() per trace is mandatory. The functions

tell you whether the specific output stream can handle trace FREE block and INFO data. This is not possible for all data formats.

Finally you use the overloaded series set function

or the corresponding output operator to write the actual time series. This call will flush the trace such that a subsequent call to a trace header set function will pass data to the next trace.

Note
The output stream classes are intended to take any type of data (floating point as well as integer). Beware that floating point data will be truncated when being written to an integer data file format.

You can check this by the series type query function

Ever heard of input operators?

Output operators support an easy way to apply the modules in this library. Almost all data set functions (be it header data or trace samples) can be accessed through output operators. This is the case for all classes. The operators are provided in namespace datrw.

See also
HOWTO write data of any supported format, datrw
Date
11/2010