QtFit
0.1
Internal library development documentation
|
Provides private implementation for FitStreamReader. More...
Public Types | |
typedef qsizetype | size_t |
Size type for size-related operations. | |
Public Member Functions | |
FitStreamReaderPrivate (FitStreamReader *const q) | |
Constructs a FitStreamReaderPrivate object, with public implementation q. More... | |
virtual | ~FitStreamReaderPrivate () |
Destroys the FitStreamReaderPrivate object. | |
Public Attributes | |
QByteArray | data |
FIT File data (alternative to device ). | |
size_t | dataOffset |
Current position within data . | |
QIODevice * | device |
FIT File IO stream (alternative to data and dataOffset ). | |
Protected Member Functions | |
template<class T > | |
size_t | bytesAvailable () const |
Returns the number of bytes currently available for reading. More... | |
template<class T > | |
bool | parseFileHeader () |
Reads and parses the FIT stream's file header. More... | |
template<class T > | |
bool | parseDefinitionMessage () |
Reads and parses a FIT Definition Message. More... | |
template<class T > | |
AbstractDataMessage * | parseDataMessage () |
Reads and parses a FIT Data Message. More... | |
template<class T > | |
quint8 | peekByte (const int pos=0) const |
Peeks the next pos'th byte in the FIT stream. More... | |
template<class T > | |
QByteArray | readBytes (const size_t size) |
Reads the next size bytes from the FIT stream. More... | |
template<class T > | |
QByteArray | readFileHeader () |
Reads all bytes of the FIT stream file header. More... | |
template<class T > | |
AbstractDataMessage * | readNextDataMessage () |
Reads up to, and including, the next FIT Data Message. More... | |
template<> | |
FitStreamReaderPrivate::size_t | bytesAvailable () const |
Specialisation for reading from QByteArray objects. More... | |
template<> | |
FitStreamReaderPrivate::size_t | bytesAvailable () const |
Specialisation for reading from QIODevice streams. More... | |
template<> | |
quint8 | peekByte (const int pos) const |
Specialisation for reading from QByteArray objects. More... | |
template<> | |
quint8 | peekByte (const int pos) const |
Specialisation for reading from QIODevice streams. More... | |
template<> | |
QByteArray | readBytes (const size_t size) |
Specialisation for reading from QIODevice streams. More... | |
template<> | |
QByteArray | readBytes (const size_t size) |
Specialisation for reading from QIODevice streams. More... | |
Static Protected Member Functions | |
static quint16 | fitChecksum (const QByteArray &data) |
Calculates a checksum, as per the algorithm used by FIT file headers. More... | |
static bool | isDefinitionMessage (const quint8 recordHeader) |
Returns true if recordHeader indicates a Definition Message, otherwise false . More... | |
Protected Attributes | |
FitStreamReader *const | q_ptr |
Internal q-pointer. | |
Private Attributes | |
QVersionNumber | protocolVersion |
Protocol version read from the parsed FIT file header. | |
QVersionNumber | profileVersion |
Protocol version read from the parsed FIT file header. | |
quint32 | expectedDataSize |
Total size, in bytes, expected to comprise the FIT file. | |
QHash< int, DataDefinition > | dataDefinitions |
Local message types to current data definitions. | |
QHash< int, int > | recordSizes |
Local message types to current record sizes. | |
Provides private implementation for FitStreamReader.
Definition at line 40 of file fitstreamreader_p.h.
|
explicit |
Constructs a FitStreamReaderPrivate object, with public implementation q.
q | Pointer to public implementation. |
Definition at line 267 of file fitstreamreader.cpp.
|
protected |
Specialisation for reading from QByteArray objects.
Definition at line 294 of file fitstreamreader.cpp.
References data, dataOffset, and device.
|
protected |
Specialisation for reading from QIODevice streams.
Definition at line 305 of file fitstreamreader.cpp.
References device.
|
protected |
Returns the number of bytes currently available for reading.
|
inlinestaticprotected |
Calculates a checksum, as per the algorithm used by FIT file headers.
data | FIT file header to calculate the checksum for. |
Definition at line 678 of file fitstreamreader.cpp.
References data.
Referenced by parseFileHeader().
|
inlinestaticprotected |
Returns true
if recordHeader indicates a Definition Message, otherwise false
.
recordHeader | A FIT Data Record header byte. |
true
if recordHeader indicates a Definition Message, otherwise false
. Definition at line 702 of file fitstreamreader.cpp.
Referenced by parseDataMessage(), parseDefinitionMessage(), and readNextDataMessage().
|
protected |
Reads and parses a FIT Data Message.
Note, this function assumes that the next item in the FIT stream is indeed a Data Message (the caller should have already determined this). Though it is perfectly acceptable that the message may not be completely available yet (in which case false
will be returned).
This fuction will, as part of decoding the message, look-up the Data Message's definition, which must have been stored previously by one or more Definition Messages being processed earlier. If no matching definition is found, false
will be returned.
true
if the Data Message was successfully read and parsed, false
otherwise. Definition at line 493 of file fitstreamreader.cpp.
References dataDefinitions, AbstractDataMessage::fromData(), isDefinitionMessage(), and DataDefinition::recordSize.
|
protected |
Reads and parses a FIT Definition Message.
Note, this function assumes that the next item in the FIT stream is indeed a Definition Message (the caller should have already determined this). Though it is perfectly acceptable that the message may not be completely available yet (in which case false
will be returned).
true
if the Definition Message was successfully read and parsed, false
otherwise. Definition at line 388 of file fitstreamreader.cpp.
References DataDefinition::architecture, FieldDefinition::baseType, BigEndian, dataDefinitions, DeveloperFieldDefinition::devDataIndex, DataDefinition::developerFieldDefinitions, DataDefinition::fieldDefinitions, DeveloperFieldDefinition::fieldNumber, DataDefinition::globalMessageNumber, isDefinitionMessage(), FieldDefinition::number, DataDefinition::recordSize, DeveloperFieldDefinition::size, and FieldDefinition::size.
|
protected |
Reads and parses the FIT stream's file header.
false
it returned.true
if the header was successfully read and parsed, false
otherwise. Definition at line 319 of file fitstreamreader.cpp.
References data, expectedDataSize, fitChecksum(), profileVersion, and protocolVersion.
|
protected |
Specialisation for reading from QByteArray objects.
pos | The position (relative to the current stream position) to peek. |
0
if not enough bytes were available. Definition at line 566 of file fitstreamreader.cpp.
References data, dataOffset, and device.
|
protected |
Specialisation for reading from QIODevice streams.
pos | The position (relative to the current stream position) to peek. |
0
if not enough bytes were available. Definition at line 579 of file fitstreamreader.cpp.
References device.
|
protected |
Peeks the next pos'th byte in the FIT stream.
If less than pos bytes are available, 0
will be returned. It is the caller's responsibility to first check that there are enough bytes availble (eg via bytesAvailable) before calling this, otherwise it would be impossible to distinguish between not-enough-bytes-available and reading a valid 0x00
byte.
Of course, we could provide a better error feedback mechanism, but as this is an internal private function, and all of our callers need to check for bytes first anyway, this is the more efficient pattern here.
pos | The position (relative to the current stream position) to peek. |
0
if not enough bytes were available.
|
protected |
Specialisation for reading from QIODevice streams.
size | The number of bytes to read. |
QDataArray
if less than size bytes were available. Definition at line 603 of file fitstreamreader.cpp.
References data, dataOffset, and device.
|
protected |
Specialisation for reading from QIODevice streams.
size | The number of bytes to read. |
QDataArray
if less than size bytes were available. Definition at line 616 of file fitstreamreader.cpp.
References device.
|
protected |
Reads the next size bytes from the FIT stream.
size | The number of bytes to read. |
QDataArray
if less than size bytes were available.
|
protected |
Reads all bytes of the FIT stream file header.
This function will first peek the header length (if available), and then read the entire header if (and only if) all header bytes are available.
QByteArray
if not enough bytes were available. Definition at line 630 of file fitstreamreader.cpp.
|
protected |
Reads up to, and including, the next FIT Data Message.
This function will continue reading the FIT stream until either no bytes are available, or a FIT Data Message has been located and parsed (or failed to be parsed). If (as expected) Definition Messages are found in the process, then they will be parse, and their definitions cached for interpreting future Data Messages.
nullptr
), and is responsible for deleting object when finished with.nullptr
if none found, or an error occurred. Definition at line 649 of file fitstreamreader.cpp.
References isDefinitionMessage(), and protocolVersion.