Line data Source code
1 : /* 2 : Copyright 2021 Paul Colby 3 : 4 : This file is part of QtFit. 5 : 6 : QtFit is free software: you can redistribute it and/or modify 7 : it under the terms of the GNU Lesser General Public License as published by 8 : the Free Software Foundation, either version 3 of the License, or 9 : (at your option) any later version. 10 : 11 : QtFit is distributed in the hope that it will be useful, 12 : but WITHOUT ANY WARRANTY; without even the implied warranty of 13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 : GNU Lesser General Public License for more details. 15 : 16 : You should have received a copy of the GNU Lesser General Public License 17 : along with QtFit. If not, see <http://www.gnu.org/licenses/>. 18 : */ 19 : 20 : #ifndef FITSTREAMREADER_H 21 : #define FITSTREAMREADER_H 22 : 23 : #include "fitdatamessage.h" 24 : 25 : #include <QIODevice> 26 : #include <QVersionNumber> 27 : 28 : QTFIT_BEGIN_NAMESPACE 29 : 30 : class FitStreamReaderPrivate; 31 : 32 : class QTFIT_EXPORT FitStreamReader { 33 : 34 : public: 35 : FitStreamReader(); 36 : explicit FitStreamReader(const QByteArray &data); 37 : explicit FitStreamReader(QIODevice *device); 38 : ~FitStreamReader(); 39 : 40 : void addData(const QByteArray &data); 41 : bool atEnd() const; 42 : void clear(); 43 : QIODevice *device() const; 44 : // [enum] Error error() const; or lastError? 45 : // QString errorString() const; 46 : void setDevice(QIODevice *device); 47 : 48 : // quint8 headerSize() const; 49 : QVersionNumber protocolVersion() const; 50 : QVersionNumber profileVersion() const; 51 : // quint32 expectedDataSize() const; 52 : // quint32 expectedChecksum() const; 53 : 54 : FitDataMessage readNext(); // Will consume the file header, defn records, and data message headers. 55 : 56 : protected: 57 : /// @cond internal 58 : FitStreamReaderPrivate * const d_ptr; ///< Internal d-pointer. 59 : explicit FitStreamReader(FitStreamReaderPrivate * const d); 60 : /// @endcond 61 : 62 : private: 63 398 : Q_DECLARE_PRIVATE(FitStreamReader) 64 : Q_DISABLE_COPY(FitStreamReader) 65 : 66 : }; 67 : 68 : QTFIT_END_NAMESPACE 69 : 70 : #endif // FITSTREAMREADER_H