Brief description of class still missing. More...
#include <GeopsySignalHeader.h>
Public Member Functions | |
| bool | isValid () |
Public Attributes | |
| union { | |
| struct { | |
| qint32 nSignals | |
| qint32 offset | |
| char tag [10] | |
| qint32 version | |
| } compat1 | |
| struct { | |
| double magicFloat | |
| qint32 magicInt | |
| qint32 nSignals | |
| qint32 offset | |
| char tag [16] | |
| qint32 version | |
| } field | |
| char raw [GEOPSYSIGNAL_HEADERSIZE] | |
| }; | |
Brief description of class still missing.
Full description of class still missing
Returns true if header is valid
References compat1, QGpCoreTools::endl(), field, GEOPSYSIGNAL_HEADERSIZE, GEOPSYSIGNAL_MAGICFLOAT, GEOPSYSIGNAL_MAGICINT, GEOPSYSIGNAL_TAG, GEOPSYSIGNAL_VERSION, QGpCoreTools::tr(), and TRACE.
Referenced by GeopsyCore::SignalFileFormat::fromContent(), and GeopsyCore::SignalFile::loadGeopsySignal().
{
TRACE;
if(strcmp( field.tag, GEOPSYSIGNAL_TAG)!=0) {
// Trying compatibility with version 1
if(strcmp( compat1.tag, "DBSignals" )!=0) {
App::stream() << tr("Cannot read Geopsy Signal file: wrong tag.") << endl;
return false;
} else { // Compatibility with version 1
App::stream() << tr("Compatibility with Geopsy Signal version 1...") << endl;
if(compat1.version==1) {
if(compat1.offset < 10 + 3 * 4 + compat1.nSignals * (4 + 8) ) {
App::stream() << tr("Cannot read Geopsy Signal file: bad offset to first signal.") << endl;
return false;
}
// Translate header compat1 to field
field.nSignals=compat1.nSignals;
field.offset=compat1.offset;
field.version=1;
} else {
App::stream() << tr("Cannot read Geopsy Signal file: bad version number.") << endl;
return false;
}
}
} else {
// Check magic numbers
if(field.magicFloat!=GEOPSYSIGNAL_MAGICFLOAT ||
field.magicInt!=GEOPSYSIGNAL_MAGICINT) {
// This is the place to implement compatibility checks (e.g. Big/Little endian) if requested.
App::stream() << tr("Cannot read Geopsy Signal file: bad magic float. This happens because\n"
"the file has been generated with another machine with different number representations.\n"
"Please send a request to bug@geopsy.org to improve compatibilty.") << endl;
return false;
}
if(field.version==GEOPSYSIGNAL_VERSION) {
if(field.offset < GEOPSYSIGNAL_HEADERSIZE + field.nSignals * 4) {
App::stream() << tr("Cannot read Geopsy Signal file: bad offset to first signal.") << endl;
return false;
}
} else {
App::stream() << tr("Cannot read Geopsy Signal file with version > %1. File version=%2")
.arg(GEOPSYSIGNAL_VERSION).arg(field.version) << endl;
return false;
}
}
if(field.nSignals<0) {
App::stream() << tr("Cannot read Geopsy Signal file: no signals specified.") << endl;
return false;
}
return true;
}
| union { ... } |
| struct { ... } GeopsyCore::GeopsySignalHeader::compat1 |
Referenced by isValid().
| struct { ... } GeopsyCore::GeopsySignalHeader::field |
| char GeopsyCore::GeopsySignalHeader::tag[10] |