QtFit
0.1
Native Qt library for Garmin FIT format
|
The FitStreamReader class provides a streaming parser for reading Garmin FIT files. More...
Public Member Functions | |
FitStreamReader () | |
Constructs a FIT stream reader with no initial data. More... | |
FitStreamReader (const QByteArray &data) | |
Constructs a FIT stream reader that reads from data. More... | |
FitStreamReader (QIODevice *device) | |
Constructs a FIT stream reader that reads from device . More... | |
~FitStreamReader () | |
Destroys the FIT stream reader. | |
void | addData (const QByteArray &data) |
Adds more data to read. More... | |
bool | atEnd () const |
Returns true if the reader has reached the end of the underlying data or device, or an error has occurred. More... | |
void | clear () |
Clears the FIT stream reader. More... | |
QIODevice * | device () const |
Returns the current device associated with the reader, or nullptr if no device is assigned. More... | |
void | setDevice (QIODevice *device) |
Sets the current device to device , and resets the stream to its initial state. More... | |
QVersionNumber | protocolVersion () const |
Returns the protocol version read from the FIT file header, otherwise a null QVersionNumber. More... | |
QVersionNumber | profileVersion () const |
Returns the profile version read from the FIT file header, otherwise a null QVersionNumber. More... | |
AbstractDataMessage * | readNext () |
Returns the next FIT data message from the underlying stream, or a null data message if none could be read. More... | |
The FitStreamReader class provides a streaming parser for reading Garmin FIT files.
FitStreamReader::FitStreamReader | ( | ) |
Constructs a FIT stream reader with no initial data.
Use addData() or setDevice() to provide data when ready.
|
explicit |
|
explicit |
Constructs a FIT stream reader that reads from device
.
device
must be open for reading, but does not need to have any bytes available yet.
device
remains valid for the lifetime of the constructed reader, or until clear() or setDevice() is used to clear or replace the device.device | Device to to begin reading. |
void FitStreamReader::addData | ( | const QByteArray & | data | ) |
Adds more data to read.
data | Additonal data to read. |
bool FitStreamReader::atEnd | ( | ) | const |
void FitStreamReader::clear | ( | ) |
Clears the FIT stream reader.
This returns the reader to a state equivalent to having just been default-constructed.
QIODevice * FitStreamReader::device | ( | ) | const |
Returns the current device associated with the reader, or nullptr
if no device is assigned.
nullptr
if no device is assigned.QVersionNumber FitStreamReader::profileVersion | ( | ) | const |
Returns the profile version read from the FIT file header, otherwise a null QVersionNumber.
FIT profile versions have only two components - major and minor. Both have a maximum value of 15, as the underlying format uses 4-bits for each component.
QVersionNumber FitStreamReader::protocolVersion | ( | ) | const |
Returns the protocol version read from the FIT file header, otherwise a null QVersionNumber.
FIT protocol versions have only two components - major and minor. The minor component is limited to the range 0 to 100, whereas the major component may be (theoreticlly) 0 to 655.
AbstractDataMessage * FitStreamReader::readNext | ( | ) |
Returns the next FIT data message from the underlying stream, or a null data message if none could be read.
If FIT header has not been read yet, it will be read first. If any FIT definition messages are found, they will be parsed, and kept in a dictionary, to used for interpretation of subsequent data messages. Reading will continue until the next FIT data message is found, or no more bytes are available for reading.
void FitStreamReader::setDevice | ( | QIODevice * | device | ) |
Sets the current device to device
, and resets the stream to its initial state.
device
must be open for reading, but does not need to have any bytes available yet.
device
remains valid for the lifetime of the constructed reader, or until clear() or setDevice() is used to clear or replace the device.device | IO device to read from. |