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-02-19 21:42:54 +01:00
|
|
|
Parser(QList<QVector<Trackpoint> > &tracks, QList<Waypoint> &waypoints)
|
2016-02-11 20:58:52 +01:00
|
|
|
: _tracks(tracks), _waypoints(waypoints) {_track = 0;}
|
|
|
|
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-02-08 17:53:09 +01:00
|
|
|
bool parse();
|
|
|
|
void gpx();
|
|
|
|
void track();
|
|
|
|
void trackPoints();
|
|
|
|
void extensions();
|
|
|
|
void trackPointData();
|
2016-02-11 20:58:52 +01:00
|
|
|
void wayPointData();
|
2016-02-08 17:53:09 +01:00
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void handleWayPointAttributes(const QXmlStreamAttributes &attr);
|
|
|
|
void handleWayPointData(QStringRef element, const QString &value);
|
2016-02-08 17:53:09 +01:00
|
|
|
void handleTrekPointAttributes(const QXmlStreamAttributes &attr);
|
|
|
|
void handleTrekPointData(QStringRef element, const QString &value);
|
|
|
|
void handleExtensionData(QStringRef element, 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;
|
|
|
|
QList<Waypoint> &_waypoints;
|
|
|
|
QVector<Trackpoint> *_track;
|
2015-10-05 01:43:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PARSER_H
|