Commit 5d8cee82 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

Merge branch 'master' into cross

parents ae333cef 4e0b0257
......@@ -3,6 +3,12 @@ this is <CHANGELOG>
Recent development in Seitosh (bug fixes, new features, etc)
------------------------------------------------------------
18.11.2016 (bf3f4664a): libdatrwxx
Debug output is produced at the base class level. This way the workflow for
reading and writing of any of the specific classes may be displayed, without
the need to implement specific debug functions.
16.11.2016 (840f7e310): stuplo, stuplox
Provide new option -st which adjusts sample time relative to source time.
......
......@@ -15,7 +15,7 @@
namespace datrw {
const char* const libversion="libdatrwxx (version 2016-07-05)";
const char* const libversion="libdatrwxx (version 2016-11-18)";
} // namespace datrw
......
......@@ -30,6 +30,7 @@
* REVISIONS and CHANGES
* - 11/04/2006 V1.0 Thomas Forbriger
* - 23/08/2012 V1.1 output stream supports modifiers
* - 18/11/2016 V1.2 use debug flag in base class
*
* ============================================================================
*/
......@@ -38,7 +39,7 @@
#ifndef DATRW_ASCII_H_VERSION
#define DATRW_ASCII_H_VERSION \
"DATRW_ASCII_H V1.1"
"DATRW_ASCII_H V1.2"
#include<datrwxx/datread.h>
#include<datrwxx/datwrite.h>
......@@ -78,7 +79,6 @@ namespace datrw {
private:
void settraceheader();
void readheader();
bool Mdebug;
bool Mnonfatal;
std::string Mmodifier; //!< format modifier
std::string Mcurrentline;
......@@ -118,7 +118,6 @@ namespace datrw {
virtual void writetrace(const Tiseries::Tcoc& series);
private:
void writetraceheader(const unsigned int& n, const char* type);
bool Mdebug; //!< produce debug output if true
unsigned int Mprecision; //!< floating point format precision
}; // class oasciistream
......
......@@ -35,11 +35,12 @@
* - 08/07/2016 V1.2 thof:
* - make correct use of new DATRW_report_assert
* - make correct use of new DATRW_nonfatal_assert
* - 18/11/2016 V1.3 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_IASCIISTREAM_CC_VERSION \
"DATRW_IASCIISTREAM_CC V1.2"
"DATRW_IASCIISTREAM_CC V1.3"
#include<iomanip>
#include<vector>
......@@ -60,7 +61,7 @@ namespace datrw {
iasciistream::iasciistream(std::istream& is,
const std::string& modifier,
const bool& debug):
Tbase(is, true, true, true), Mdebug(debug), Mmodifier(modifier)
Tbase(is, true, true, true, debug), Mmodifier(modifier)
{
// format modifiers must be used here to set defaults
datrw::Subformat subformat(Mmodifier);
......
......@@ -30,11 +30,12 @@
* REVISIONS and CHANGES
* - 18/10/2011 V1.0 Thomas Forbriger
* - 23/08/2012 V1.1 support format modifiers
* - 18/11/2016 V1.2 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_OASCIISTREAM_CC_VERSION \
"DATRW_OASCIISTREAM_CC V1.1"
"DATRW_OASCIISTREAM_CC V1.2"
#include<datrwxx/ascii.h>
#include<datrwxx/debug.h>
......@@ -56,8 +57,7 @@ namespace datrw {
oasciistream::oasciistream(std::ostream& os,
const std::string& modifier,
const bool& debug):
Tbase(os, Fall, true, true, true, true),
Mdebug(debug)
Tbase(os, Fall, true, true, true, true, debug)
{
DATRW_debug(Mdebug, "oasciistream::oasciistream",
"new instance established");
......
......@@ -29,6 +29,7 @@
*
* REVISIONS and CHANGES
* - 24/02/2010 V1.0 Thomas Forbriger
* - 18/11/2016 V1.1 use debug flag in base class
*
* ============================================================================
*/
......@@ -37,7 +38,7 @@
#ifndef DATRW_BINARY_H_VERSION
#define DATRW_BINARY_H_VERSION \
"DATRW_BINARY_H V1.0 "
"DATRW_BINARY_H V1.1"
#include<datrwxx/datread.h>
#include<datrwxx/datwrite.h>
......@@ -116,7 +117,6 @@ namespace datrw {
void readflags();
void setnsamples(const unsigned int& nsamples);
binary::ibinstream Mibs;
bool Mdebug;
short Mversion;
char Mnextflags; //!< flags for next trace
}; // class ibinarystream
......@@ -145,7 +145,6 @@ namespace datrw {
private:
void writetraceheader(const binary::Eflags&,
const unsigned int& nsamples);
bool Mdebug;
binary::obinstream Mobs;
}; // class obinarystream
......
......@@ -29,11 +29,12 @@
*
* REVISIONS and CHANGES
* - 18/10/2011 V1.0 Thomas Forbriger
* - 18/11/2016 V1.1 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_IBINARYSTREAM_CC_VERSION \
"DATRW_IBINARYSTREAM_CC V1.0 "
"DATRW_IBINARYSTREAM_CC V1.1"
#include<datrwxx/binary.h>
#include<datrwxx/error.h>
......@@ -49,9 +50,8 @@ namespace datrw {
ibinarystream::ibinarystream(std::istream& is,
const bool& debug):
Tbase(is, true, true, true),
Mibs(is, ::datrw::binary::magic, debug),
Mdebug(debug)
Tbase(is, true, true, true, debug),
Mibs(is, ::datrw::binary::magic, debug)
{
char flags;
Mibs >> Mversion;
......
......@@ -29,11 +29,12 @@
*
* REVISIONS and CHANGES
* - 18/10/2011 V1.0 Thomas Forbriger
* - 18/11/2016 V1.1 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_OBINARYSTREAM_CC_VERSION \
"DATRW_OBINARYSTREAM_CC V1.0 "
"DATRW_OBINARYSTREAM_CC V1.1"
#include<datrwxx/binary.h>
#include<datrwxx/debug.h>
......@@ -46,8 +47,7 @@ namespace datrw {
/*----------------------------------------------------------------------*/
obinarystream::obinarystream(std::ostream& os, const bool& debug):
Tbase(os, Fall, true, true, true, true),
Mdebug(debug),
Tbase(os, Fall, true, true, true, true, debug),
Mobs(os, ::datrw::binary::magic, Mdebug)
//Mobs(os, ::datrw::binary::magic, debug)
{
......
......@@ -29,13 +29,16 @@
* REVISIONS and CHANGES
* - 30/03/2004 V1.0 Thomas Forbriger
* - 17/09/2004 V1.1 make most fields private
* - 18/11/2016 V1.2 provide debug flag in base class
* and produce debug output
*
* ============================================================================
*/
#define DATRW_DATRW_CC_VERSION \
"DATRW_DATRW_CC V1.1 "
"DATRW_DATRW_CC V1.2"
#include <datrwxx/datread.h>
#include <datrwxx/debug.h>
namespace datrw {
......@@ -49,11 +52,15 @@ namespace datrw {
idatstream::idatstream(std::istream& is,
const bool& providesd,
const bool& providesf,
const bool& providesi)
: Mis(is), Mwid2set(false), Msrceset(false), Minfoset(false),
const bool& providesi,
const bool& debug)
: Mis(is), Mdebug(debug), Mwid2set(false), Msrceset(false), Minfoset(false),
Mtracefreeset(false), Mfilefreeset(false), Mlast(false),
Mprovidesd(providesd), Mprovidesf(providesf), Mprovidesi(providesi)
{
DATRW_debug(this->Mdebug,
"idatstream::idatstream",
"create new input stream");
DATRW_assert(is.good(), "input stream is not good!");
} // idatstream::idatstream
......@@ -68,7 +75,18 @@ namespace datrw {
sff::FREE idatstream::free() const
{
if (Mwid2set) { return(Mtracefree); } else { return(Mfilefree); }
if (Mwid2set)
{
DATRW_debug(this->Mdebug, "idatstream::free",
DATRW_value(Mtracefree.lines.size()));
return(Mtracefree);
}
else
{
DATRW_debug(this->Mdebug, "idatstream::free",
DATRW_value(Mfilefree.lines.size()));
return(Mfilefree);
}
}
/*----------------------------------------------------------------------*/
......@@ -135,6 +153,77 @@ namespace datrw {
os << "Class " << name << " provides no help text." << std::endl;
}
/* ====================================================================== */
// input operators implemented here to provide debug output
idatstream& operator>>(idatstream& is, sff::WID2& wid2)
{
wid2=is.wid2();
DATRW_debug(is.debug(), "operator>>(idatstream& is, sff::WID2& wid2)",
DATRW_value(wid2.line().substr(0,50)));
return(is);
} // idatstream& operator>>(idatstream& is, sff::WID2& wid2)
/* ---------------------------------------------------------------------- */
idatstream& operator>>(idatstream& is, sff::SRCE& srce)
{
srce=is.srce();
DATRW_debug(is.debug(), "operator>>(idatstream& is, sff::SRCE& srce)",
DATRW_value(srce.line().substr(0,50)));
return(is);
} // idatstream& operator>>(idatstream& is, sff::SRCE& srce)
/* ---------------------------------------------------------------------- */
idatstream& operator>>(idatstream& is, sff::INFO& info)
{
info=is.info();
DATRW_debug(is.debug(), "operator>>(idatstream& is, sff::INFO& info)",
DATRW_value(info.line().substr(0,50)));
return(is);
} // idatstream& operator>>(idatstream& is, sff::INFO& info)
/* ---------------------------------------------------------------------- */
idatstream& operator>>(idatstream& is, sff::FREE& free)
{
free=is.free();
DATRW_debug(is.debug(), "operator>>(idatstream& is, sff::FREE& free)",
DATRW_value(free.lines.size()));
return(is);
} // idatstream& operator>>(idatstream& is, sff::FREE& free)
/* ---------------------------------------------------------------------- */
idatstream& operator>>(idatstream& is, Tdseries& series)
{
series=is.dseries();
DATRW_debug(is.debug(), "operator>>(idatstream& is, Tdseries& series)",
DATRW_value(series.f()) << ", " << DATRW_value(series.l()));
return(is);
} // idatstream& operator>>(idatstream& is, Tdseries& series)
/* ---------------------------------------------------------------------- */
idatstream& operator>>(idatstream& is, Tfseries& series)
{
series=is.fseries();
DATRW_debug(is.debug(), "operator>>(idatstream& is, Tfseries& series)",
DATRW_value(series.f()) << ", " << DATRW_value(series.l()));
return(is);
} // idatstream& operator>>(idatstream& is, Tfseries& series)
/* ---------------------------------------------------------------------- */
idatstream& operator>>(idatstream& is, Tiseries& series)
{
series=is.iseries();
DATRW_debug(is.debug(), "operator>>(idatstream& is, Tiseries& series)",
DATRW_value(series.f()) << ", " << DATRW_value(series.l()));
return(is);
} // idatstream& operator>>(idatstream& is, Tiseries& series)
} // namespace datrw
/* ----- END OF datrw.cc ----- */
......@@ -34,6 +34,8 @@
* anything about Mis state
* - 23/11/2010 V1.4 introduced isbinary flag
* - 29/07/2011 V1.5 support property query
* - 18/11/2016 V1.6 provide debug flag in base class
* do not define input operators inline
*
* ============================================================================
*/
......@@ -42,7 +44,7 @@
#ifndef DATRW_DATREAD_H_VERSION
#define DATRW_DATREAD_H_VERSION \
"DATRW_DATREAD_H V1.5"
"DATRW_DATREAD_H V1.6"
#include<iostream>
#include<sffxx.h>
......@@ -110,11 +112,17 @@ namespace datrw {
//! print some info about data conversion.
static void help(std::ostream& os=std::cout,
const char* name="idatsream");
//! indicate debug mode
bool debug() { return Mdebug; }
//! set debug mode
void debug(const bool& debug) { Mdebug=debug; }
protected:
// member functions
idatstream(std::istream& is,
const bool& providesd=false,
const bool& providesf=false,
const bool& providesi=false);
const bool& providesi=false,
const bool& debug=false);
std::istream& Mis;
void setfilefree(const sff::FREE& free);
void settracefree(const sff::FREE& free);
......@@ -123,6 +131,8 @@ namespace datrw {
void setinfo(const sff::INFO& info);
void setlast();
void newtrace();
// member data
bool Mdebug;
private:
sff::WID2 Mwid2;
sff::SRCE Msrce;
......@@ -136,26 +146,19 @@ namespace datrw {
/*----------------------------------------------------------------------*/
inline idatstream& operator>>(idatstream& is, sff::WID2& wid2)
{ wid2=is.wid2(); return(is); }
idatstream& operator>>(idatstream& is, sff::WID2& wid2);
inline idatstream& operator>>(idatstream& is, sff::SRCE& srce)
{ srce=is.srce(); return(is); }
idatstream& operator>>(idatstream& is, sff::SRCE& srce);
inline idatstream& operator>>(idatstream& is, sff::INFO& info)
{ info=is.info(); return(is); }
idatstream& operator>>(idatstream& is, sff::INFO& info);
inline idatstream& operator>>(idatstream& is, sff::FREE& free)
{ free=is.free(); return(is); }
idatstream& operator>>(idatstream& is, sff::FREE& free);
inline idatstream& operator>>(idatstream& is, Tdseries& series)
{ series=is.dseries(); return(is); }
idatstream& operator>>(idatstream& is, Tdseries& series);
inline idatstream& operator>>(idatstream& is, Tfseries& series)
{ series=is.fseries(); return(is); }
idatstream& operator>>(idatstream& is, Tfseries& series);
inline idatstream& operator>>(idatstream& is, Tiseries& series)
{ series=is.iseries(); return(is); }
idatstream& operator>>(idatstream& is, Tiseries& series);
} // namespace datrw
......
......@@ -32,14 +32,17 @@
* - 01/04/2011 V1.1 do not clear Mhassrce upon writing the file header
* - 07/06/2011 V1.2 promise constness of series samples
* - 08/07/2016 V1.3 make correct use of new DATRW_report_assert
* - 18/11/2016 V1.4 provide debug flag in base class
* and produce debug output
*
* ============================================================================
*/
#define DATRW_DATWRITE_CC_VERSION \
"DATRW_DATWRITE_CC V1.3"
"DATRW_DATWRITE_CC V1.4"
#include<fstream>
#include <datrwxx/datwrite.h>
#include <datrwxx/debug.h>
namespace datrw {
......@@ -85,15 +88,19 @@ namespace datrw {
const bool& handlesfilefree,
const bool& handlestracefree,
const bool& handlessrce,
const bool& handlesinfo)
: Mos(os), Mwid2set(false), Msrceset(false), Minfoset(false),
Mfreeset(false), Mheaderflushed(false),
const bool& handlesinfo,
const bool& debug)
: Mos(os), Mdebug(debug), Mwid2set(false), Msrceset(false),
Minfoset(false), Mfreeset(false), Mheaderflushed(false),
Mhandlestracefree(handlestracefree),
Mhandlesfilefree(handlesfilefree),
Mhandlesinfo(handlesinfo),
Mhandlessrce(handlessrce),
Mdatatype(datatype)
{
DATRW_debug(this->Mdebug,
"odatstream::odatstream",
"create new output stream");
DATRW_assert(os.good(), "output stream is not good!");
}
......@@ -101,6 +108,8 @@ namespace datrw {
void odatstream::setfree(const sff::FREE& free)
{
DATRW_debug(this->Mdebug, "odatstream::setfree",
DATRW_value(free.lines.size()));
if (Mheaderflushed)
{
DATRW_report_assert(this->handlestracefree(),
......@@ -119,6 +128,8 @@ namespace datrw {
void odatstream::setwid2(const sff::WID2& wid2)
{
DATRW_debug(this->Mdebug, "odatstream::setwid2",
DATRW_value(wid2.line().substr(0,50)));
Mwid2set=true;
Mwid2=wid2;
this->flushfileheader();
......@@ -128,6 +139,8 @@ namespace datrw {
void odatstream::setinfo(const sff::INFO& info)
{
DATRW_debug(this->Mdebug, "odatstream::setinfo",
DATRW_value(info.line().substr(0,50)));
DATRW_report_assert(this->handlesinfo(),
"file format cannot handle INFO data\n"
"INFO data will be dropped silently");
......@@ -139,6 +152,8 @@ namespace datrw {
void odatstream::setsrce(const sff::SRCE& srce)
{
DATRW_debug(this->Mdebug, "odatstream::setsrce",
DATRW_value(srce.line().substr(0,50)));
DATRW_report_assert(this->handlessrce(),
"file format cannot handle SRCE data\n"
"SRCE data will be dropped silently");
......@@ -178,6 +193,8 @@ namespace datrw {
void odatstream::writeseries(const Tdseries::Tcoc& series)
{
DATRW_debug(this->Mdebug, "odatstream::writeseries (double)",
DATRW_value(series.f()) << ", " << DATRW_value(series.l()));
DATRW_assert(this-Mwid2set,"missing WID2 header");
this->writetrace(series);
this->cleartraceheader();
......@@ -187,6 +204,8 @@ namespace datrw {
void odatstream::writeseries(const Tfseries::Tcoc& series)
{
DATRW_debug(this->Mdebug, "odatstream::writeseries (float)",
DATRW_value(series.f()) << ", " << DATRW_value(series.l()));
DATRW_assert(this-Mwid2set,"missing WID2 header");
this->writetrace(series);
this->cleartraceheader();
......@@ -196,6 +215,8 @@ namespace datrw {
void odatstream::writeseries(const Tiseries::Tcoc& series)
{
DATRW_debug(this->Mdebug, "odatstream::writeseries (int)",
DATRW_value(series.f()) << ", " << DATRW_value(series.l()));
DATRW_assert(this-Mwid2set,"missing WID2 header");
this->writetrace(series);
this->cleartraceheader();
......
......@@ -31,6 +31,7 @@
* - 11/04/2006 V1.0 Thomas Forbriger
* - 07/06/2011 V1.1 promise constness of series samples
* - 29/07/2011 V1.2 support property query
* - 18/11/2016 V1.3 provide debug flag in base class
*
* ============================================================================
*/
......@@ -39,7 +40,7 @@
#ifndef DATRW_DATWRITE_H_VERSION
#define DATRW_DATWRITE_H_VERSION \
"DATRW_DATWRITE_H V1.2"
"DATRW_DATWRITE_H V1.3"
#include<string>
#include<iostream>
......@@ -139,6 +140,11 @@ namespace datrw {
//! print some info about data conversion.
static void help(std::ostream& os=std::cout,
const char* name="idatsream");
//! indicate debug mode
bool debug() { return Mdebug; }
//! set debug mode
void debug(const bool& debug) { Mdebug=debug; }
protected:
//! constructor is protected: do not create an instance of this class
odatstream(std::ostream& os,
......@@ -146,7 +152,8 @@ namespace datrw {
const bool& handlesfilefree=false,
const bool& handlestracefree=false,
const bool& handlessrce=false,
const bool& handlesinfo=false);
const bool& handlesinfo=false,
const bool& debug=false);
//! write double data
virtual void writetrace(const Tdseries::Tcoc& series) { DATRW_illegal; }
//! write single precision float data
......@@ -185,6 +192,9 @@ namespace datrw {
//! output stream to be used by this class
std::ostream& Mos;
//! global debug flag
bool Mdebug;
private:
bool Mwid2set, Msrceset, Minfoset, Mfreeset;
bool Mheaderflushed;
......
......@@ -34,6 +34,7 @@
* - 22/07/2014 V1.4 thof: support new format modifier: estimateNframes
* - 05/07/2016 V1.5 thof: provide consistency check control flags
* - 12/07/2016 V1.6 thof: provide usec consistency check
* - 18/11/2016 V1.7 use debug flag in base class
*
* ============================================================================
*/
......@@ -42,7 +43,7 @@
#ifndef DATRW_MSEED_H_VERSION
#define DATRW_MSEED_H_VERSION \
"DATRW_MSEED_H V1.6"
"DATRW_MSEED_H V1.7"
#include<datrwxx/datread.h>
......@@ -177,8 +178,6 @@ namespace datrw {
Tiseries read(const bool& skipdata=false);
//! data read ahead
datrw::mseed::Record Mrecord;
//! debugging mode
bool Mdebug;
std::string Mmodifier; //!< format modifier
bool Mdumpascii; //!< dump ASCII data if true
double Mttolerance; //!< timing tolerance in microseconds
......
......@@ -38,11 +38,12 @@
* - 05/07/2016 V1.7 thof: evaluate format modifiers to adjust
* consistency checks
* - 12/07/2016 V1.8 thof: provide usec consistency check
* - 18/11/2016 V1.9 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_IMSEEDSTREAM_CC_VERSION \
"DATRW_IMSEEDSTREAM_CC V1.8"
"DATRW_IMSEEDSTREAM_CC V1.9"
#include <datrwxx/util.h>
#include <datrwxx/mseed.h>
......@@ -89,7 +90,7 @@ namespace datrw {
imseedstream::imseedstream(std::istream& is,
const std::string& modifier,
const bool& debug):
Tbase(is, true, true, true), Mdebug(debug), Mmodifier(modifier),
Tbase(is, true, true, true, debug), Mmodifier(modifier),
Mdumpascii(false), Mchecks(true, true)
{
datrw::Subformat subformat(Mmodifier);
......
......@@ -47,11 +47,12 @@
* - 19/11/2011 V1.17 provide binary input
* - 05/12/2011 V1.18 itsoftstream takes format modifiers
* - 21/01/2012 V1.19 prepared isustream to take modifiers
* - 18/11/2016 V1.20 set debug mode in base class
*
* ============================================================================
*/
#define DATRW_READANY_CC_VERSION \
"DATRW_READANY_CC V1.19"
"DATRW_READANY_CC V1.20"
#include <datrwxx/readany.h>
#include <datrwxx/sff.h>
......@@ -177,7 +178,7 @@ namespace datrw {
else if (Mformat==Fsff)
{
DATRW_expect_no_modifier(Mformat,modifiers);
Mis=new isffstream(is, debug);
Mis=new isffstream(is);
}
else if (Mformat==Fhpmo)
{
......@@ -186,12 +187,12 @@ namespace datrw {