QtFit
0.1
Internal library development documentation
|
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... | |
Protected Member Functions | |
FitStreamReader (FitStreamReaderPrivate *const d) | |
Constructs a FIT stream reader with private implementation d. More... | |
Protected Attributes | |
FitStreamReaderPrivate *const | d_ptr |
Internal d-pointer. | |
The FitStreamReader class provides a streaming parser for reading Garmin FIT files.
Definition at line 37 of file fitstreamreader.h.
FitStreamReader::FitStreamReader | ( | ) |
Constructs a FIT stream reader with no initial data.
Use addData() or setDevice() to provide data when ready.
Definition at line 54 of file fitstreamreader.cpp.
|
explicit |
Constructs a FIT stream reader that reads from data.
data
may be empty or incomplete, in which case more data can be added later via addData().
data | FIT data to begin reading. |
Definition at line 68 of file fitstreamreader.cpp.
|
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. |
Definition at line 88 of file fitstreamreader.cpp.
References device().
|
explicitprotected |
Constructs a FIT stream reader with private implementation d.
d | Pointer to private implementation. |
Definition at line 102 of file fitstreamreader.cpp.
void FitStreamReader::addData | ( | const QByteArray & | data | ) |
Adds more data to read.
data | Additonal data to read. |
Definition at line 124 of file fitstreamreader.cpp.
bool FitStreamReader::atEnd | ( | ) | const |
Returns true
if the reader has reached the end of the underlying data or device, or an error has occurred.
true
if the reader has reached the end of the underlying data or device. Definition at line 143 of file fitstreamreader.cpp.
void FitStreamReader::clear | ( | ) |
Clears the FIT stream reader.
This returns the reader to a state equivalent to having just been default-constructed.
Definition at line 155 of file fitstreamreader.cpp.
Referenced by setDevice().
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.Definition at line 177 of file fitstreamreader.cpp.
Referenced by FitStreamReader(), and setDevice().
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.
Definition at line 211 of file fitstreamreader.cpp.
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.
Definition at line 225 of file fitstreamreader.cpp.
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.
Definition at line 246 of file fitstreamreader.cpp.
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. |
Definition at line 195 of file fitstreamreader.cpp.
References clear(), and device().