2015-10-05 01:43:48 +02:00
|
|
|
#ifndef PARSER_H
|
|
|
|
#define PARSER_H
|
|
|
|
|
|
|
|
#include <QXmlStreamReader>
|
2016-02-11 20:58:52 +01:00
|
|
|
#include <QVector>
|
|
|
|
#include <QList>
|
|
|
|
#include "trackpoint.h"
|
|
|
|
#include "waypoint.h"
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Parser
|
|
|
|
{
|
|
|
|
public:
|
2016-08-09 01:16:19 +02:00
|
|
|
Parser(QList<QVector<Trackpoint> > &tracks,
|
|
|
|
QList<QVector<Waypoint> > &routes, QList<Waypoint> &waypoints)
|
|
|
|
: _tracks(tracks), _routes(routes), _waypoints(waypoints)
|
|
|
|
{_track = 0; _route = 0;}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
bool loadFile(QIODevice *device);
|
2015-11-26 19:13:59 +01:00
|
|
|
QString errorString() const {return _reader.errorString();}
|
|
|
|
int errorLine() const {return _reader.lineNumber();}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
private:
|
2016-07-28 00:23:22 +02:00
|
|
|
enum DataType {
|
|
|
|
Name, Description, Elevation, Time, Geoidheight, Speed, HeartRate,
|
|
|
|
Temperature
|
2016-06-21 00:12:34 +02:00
|
|
|
};
|
2016-06-20 23:56:42 +02:00
|
|
|
|
2016-02-08 17:53:09 +01:00
|
|
|
bool parse();
|
|
|
|
void gpx();
|
|
|
|
void track();
|
2016-06-21 00:12:34 +02:00
|
|
|
void trackpoints();
|
2016-08-09 01:16:19 +02:00
|
|
|
void routepoints();
|
2016-03-21 23:13:46 +01:00
|
|
|
void tpExtension();
|
2016-02-08 17:53:09 +01:00
|
|
|
void extensions();
|
2016-06-21 00:12:34 +02:00
|
|
|
void trackpointData();
|
2016-08-09 01:16:19 +02:00
|
|
|
void routepointData();
|
2016-06-21 00:12:34 +02:00
|
|
|
void waypointData();
|
2016-02-08 17:53:09 +01:00
|
|
|
|
2016-06-21 00:12:34 +02:00
|
|
|
void handleWaypointAttributes(const QXmlStreamAttributes &attr);
|
2016-07-28 00:23:22 +02:00
|
|
|
void handleWaypointData(DataType type, const QString &value);
|
2016-06-21 00:12:34 +02:00
|
|
|
void handleTrackpointAttributes(const QXmlStreamAttributes &attr);
|
2016-07-28 00:23:22 +02:00
|
|
|
void handleTrackpointData(DataType type, const QString &value);
|
2016-08-09 01:16:19 +02:00
|
|
|
void handleRoutepointAttributes(const QXmlStreamAttributes &attr);
|
|
|
|
void handleRoutepointData(DataType type, const QString &value);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
QXmlStreamReader _reader;
|
2016-02-19 21:42:54 +01:00
|
|
|
QList<QVector<Trackpoint> > &_tracks;
|
2016-08-09 01:16:19 +02:00
|
|
|
QList<QVector<Waypoint> > &_routes;
|
2016-02-19 21:42:54 +01:00
|
|
|
QList<Waypoint> &_waypoints;
|
|
|
|
QVector<Trackpoint> *_track;
|
2016-08-09 01:16:19 +02:00
|
|
|
QVector<Waypoint> *_route;
|
2015-10-05 01:43:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PARSER_H
|