Commit 35536fdd authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

improved robustness

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1662
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 4c03bb48
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.cc,v 1.15 2005-03-15 17:48:40 tforb Exp $
* $Id: sffxx.cc,v 1.16 2005-03-15 18:15:28 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -20,13 +20,18 @@
* - correct reading of FREE block
* - 23/12/2004 V1.3 added full block append to FREE
* - 26/01/2004 V1.4 SRCE reading and INFO reading was not satisfactory
* - 15/03/2005 V1.5
* - made SRCE date and time reading more robust against
* whitespace
* - added some debug output
* - check SFF file type version to be at least 1.10
*
* ============================================================================
*/
#define TF_SFFXX_CC_VERSION \
"TF_SFFXX_CC V1.4"
"TF_SFFXX_CC V1.5"
#define TF_SFFXX_CC_CVSID \
"$Id: sffxx.cc,v 1.15 2005-03-15 17:48:40 tforb Exp $"
"$Id: sffxx.cc,v 1.16 2005-03-15 18:15:28 tforb Exp $"
#include<sstream>
#include <sffxx.h>
......@@ -148,6 +153,14 @@ namespace sff {
is >> code;
this->hasfree=(code.find('F')!=std::string::npos);
this->hassrce=(code.find('S')!=std::string::npos);
if (debug)
{
if (this->hasfree)
{ std::cerr << "DEBUG (STAT::read): has FREE block" << std::endl; }
if (this->hassrce)
{ std::cerr << "DEBUG (STAT::read): has SRCE line" << std::endl; }
std::cerr << "DEBUG (STAT::read): finished" << std::endl;
}
} // STAT::read
/*----------------------------------------------------------------------*/
......@@ -175,7 +188,7 @@ namespace sff {
return(retval);
} // SRCE::line()
void SRCE::read(std::istream& fis)
void SRCE::read(std::istream& fis, const bool& debug)
{
std::string theline;
std::getline(fis, theline);
......@@ -188,6 +201,8 @@ namespace sff {
char intype[21];
is.get(intype, 21);
type=intype;
if (debug)
{ std::cerr << "DEBUG (SRCE::read): type: " << type << std::endl; }
char cschar;
is >> cschar;
......@@ -195,10 +210,26 @@ namespace sff {
is >> cx;
is >> cy;
is >> cz;
if (debug)
{
std::cerr << "DEBUG (SRCE::read): cs,cx,cy,cz: "
<< cs << "," << cx << "," << cy << "," << cz << std::endl;
}
std::string datestring,timestring;
is >> datestring;
is >> timestring;
char indatestring[8];
char intimestring[11];
is.get(indatestring, 8);
is.get(intimestring, 11);
datestring=&indatestring[1];
timestring=&intimestring[1];
if (debug)
{
std::cerr << "DEBUG (SRCE::read): datestring: "
<< datestring << std::endl;
std::cerr << "DEBUG (SRCE::read): timestring: "
<< timestring << std::endl;
}
std::string fulldate("");
fulldate+=datestring.substr(0,2);
fulldate+="/";
......@@ -211,7 +242,17 @@ namespace sff {
fulldate+=timestring.substr(2,2);
fulldate+=":";
fulldate+=timestring.substr(4,6);
if (debug)
{
std::cerr << "DEBUG (SRCE::read): convert string: "
<< fulldate() << std::endl;
}
date=libtime::TAbsoluteTime(fulldate);
if (debug)
{
std::cerr << "DEBUG (SRCE::read): time: "
<< date.timestring() << std::endl;
}
} // SRCE::read
/*----------------------------------------------------------------------*/
......@@ -415,8 +456,20 @@ namespace sff {
void FileHeader::read(std::istream& is, const bool& debug)
{
Mstat.read(is, debug);
if (Mstat.hasfree) { Mfree.read(is); }
if (Mstat.hassrce) { Msrce.read(is); }
if (Mstat.hasfree)
{
Mfree.read(is);
if (debug)
{ std::cerr << "DEBUG (FileHeader::read): file FREE read" << std::endl; }
}
if (Mstat.hassrce)
{
Msrce.read(is, debug);
if (debug)
{ std::cerr << "DEBUG (FileHeader::read): SRCE line read" << std::endl; }
}
if (debug)
{ std::cerr << "DEBUG (FileHeader::read): finished" << std::endl; }
}
/*----------------------------------------------------------------------*/
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: sffxx.h,v 1.22 2005-01-26 17:51:32 tforb Exp $
* $Id: sffxx.h,v 1.23 2005-03-15 18:15:28 tforb Exp $
* \author Thomas Forbriger
* \date 21/12/2003
*
......@@ -30,7 +30,7 @@
#define TF_SFFXX_H_VERSION \
"TF_SFFXX_H V1.3"
#define TF_SFFXX_H_CVSID \
"$Id: sffxx.h,v 1.22 2005-01-26 17:51:32 tforb Exp $"
"$Id: sffxx.h,v 1.23 2005-03-15 18:15:28 tforb Exp $"
#include<string>
#include<cmath>
......@@ -112,7 +112,7 @@ namespace sff {
SRCE();
SRCE(std::istream& is) { read(is); }
std::string line() const;
void read(std::istream& is);
void read(std::istream& is, const bool& debug=false);
public:
std::string type;
libtime::TAbsoluteTime date; //!< time of source
......
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