1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-07 07:13:21 +02:00
GPXSee/src/parser.h

49 lines
1.2 KiB
C
Raw Normal View History

2015-10-05 01:43:48 +02:00
#ifndef PARSER_H
#define PARSER_H
#include <QXmlStreamReader>
#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)
: _tracks(tracks), _waypoints(waypoints) {_track = 0;}
bool loadFile(QIODevice *device);
QString errorString() const {return _reader.errorString();}
int errorLine() const {return _reader.lineNumber();}
2015-10-05 01:43:48 +02:00
private:
2016-06-21 00:12:34 +02:00
enum TrackpointElement {
2016-06-20 23:56:42 +02:00
Elevation, Time, Geoidheight, Speed, HeartRate, Temperature
};
2016-06-21 00:12:34 +02:00
enum WaypointElement {
2016-07-25 19:32:36 +02:00
Name, Description
2016-06-21 00:12:34 +02:00
};
2016-06-20 23:56:42 +02:00
bool parse();
void gpx();
void track();
2016-06-21 00:12:34 +02:00
void trackpoints();
void tpExtension();
void extensions();
2016-06-21 00:12:34 +02:00
void trackpointData();
void waypointData();
2016-06-21 00:12:34 +02:00
void handleWaypointAttributes(const QXmlStreamAttributes &attr);
void handleWaypointData(WaypointElement element, const QString &value);
void handleTrackpointAttributes(const QXmlStreamAttributes &attr);
void handleTrackpointData(TrackpointElement 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