DATRW++ library: seismic data I/O with multiple formats
HOWTO implement an output stream

The base class datrw::odatstream takes care of many organizational issues for you. You are only responsible to provide code which is capable to actually write the data to a file stream. I will use datrw::osffstream as an example.

You have to provide at least a derived stream class like datrw::osffstream, which has to be equipped with:

That's all.

Finally check files writeany.h, writeany.cc, formats.h, and formats.cc and add appropriate lines to make the new stream visible through the generic interface of datrw::oanystream and the functions presented in writeany.h.

Additional information on the implementation of function writefileheader()

The C++ ostream to which data should be written is available through the protected member data field datrw::odatstream::Mos by inheritance. The inherited function datrw::odatstream::hassrce() indicates whether SRCE data is available and can be retrieved through the inherited function datrw::odatstream::srce(). The inherited function datrw::odatstream::hasfree() indicates whether FREE data is available and can be retrieved through the inherited function datrw::odatstream::free().

Additional information on the implementation of function writetrace()

This set of functions is responsible to actually write a trace to the C++ output stream which is available through the protected member data field datrw::odatstream::Mos by inheritance. Appropriate sample type conversion has do be done, if necessary. The base class datrw::odatstream ensures that WID2 data is available before one of these functions is called. You can check whether additionally INFO or FREE data is available for the trace, by calling the inherited functions datrw::odatstream::hasinfo() or datrw::odatstream::hasfree(), respectively. The INFO and FREE data is available through the inherited functions datrw::odatstream::info() and datrw::odatstream::free().

Note
Attention: Do not rely on the number of samples passed with the ::sff::WID2 to the output stream. The number os samples should be set to the actual numer of samples passed to function writetrace()!
See also
HOWTO write data of any supported format, Description of writing operation, HOWTO implement an input stream, HOWTO use format modifiers
Date
8.12.2010