Commit bf3f4664 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libdatrwxx [FEATURE]: provide debug output on base class level

Input operators for idatstream no longer are defined inline. This was
necessary, since idatstream functions have one level of indiraction less than
functions in odatstream. Input operators for idatstream produce debug output,
while in odatstream debug output is produced in member functions.
parent 90ff3a93
......@@ -30,6 +30,7 @@
* - 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
*
* ============================================================================
*/
......@@ -37,6 +38,7 @@
"DATRW_DATRW_CC V1.2"
#include <datrwxx/datread.h>
#include <datrwxx/debug.h>
namespace datrw {
......@@ -56,6 +58,9 @@ namespace datrw {
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
......@@ -70,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);
}
}
/*----------------------------------------------------------------------*/
......@@ -137,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 ----- */
......@@ -35,6 +35,7 @@
* - 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
*
* ============================================================================
*/
......@@ -145,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
......
......@@ -33,6 +33,7 @@
* - 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
*
* ============================================================================
*/
......@@ -41,6 +42,7 @@
#include<fstream>
#include <datrwxx/datwrite.h>
#include <datrwxx/debug.h>
namespace datrw {
......@@ -96,6 +98,9 @@ namespace datrw {
Mhandlessrce(handlessrce),
Mdatatype(datatype)
{
DATRW_debug(this->Mdebug,
"odatstream::odatstream",
"create new output stream");
DATRW_assert(os.good(), "output stream is not good!");
}
......@@ -103,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(),
......@@ -121,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();
......@@ -130,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");
......@@ -141,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");
......@@ -180,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();
......@@ -189,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();
......@@ -198,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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment