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

56 lines
1.4 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-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;}
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:
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
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();
void tpExtension();
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-06-21 00:12:34 +02:00
void handleWaypointAttributes(const QXmlStreamAttributes &attr);
void handleWaypointData(DataType type, const QString &value);
2016-06-21 00:12:34 +02:00
void handleTrackpointAttributes(const QXmlStreamAttributes &attr);
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