Skip to content

Commit

Permalink
Conrad Meyer replaces our expat-based XML reader with QtXmlStreamReader.
Browse files Browse the repository at this point in the history
This is known to crash right now, and that will anger Jenkins, but this will only hurt for a 
little while.  (I hope.)   The changes are too good to leave unmerged - let's tackle them
together.
  • Loading branch information
robertlipe committed Aug 5, 2013
1 parent c292bd1 commit 4673a25
Show file tree
Hide file tree
Showing 29 changed files with 659 additions and 887 deletions.
2 changes: 2 additions & 0 deletions gpsbabel/coastexp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/

#include <QtCore/QXmlStreamAttributes>

#include "defs.h"
#include "xmlgeneric.h"
#if HAVE_LIBEXPAT
Expand Down
4 changes: 4 additions & 0 deletions gpsbabel/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
# define XML_UNICODE
#endif

#define CSTR(qstr) (qstr.toUtf8().constData())
#define CSTRE_(qstr, enc) (enc->fromUnicode(qstr).constData())
#define CSTRE(qstr) (CSTRE_(qstr, codec))

/*
* Amazingly, this constant is not specified in the standard...
*/
Expand Down
34 changes: 18 additions & 16 deletions gpsbabel/dmtlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*/

#include <QtCore/QXmlStreamAttributes>

#include "defs.h"
#include "jeeps/gpsmath.h"
#include "xmlgeneric.h"
Expand Down Expand Up @@ -146,20 +148,20 @@ finalize_pt(waypoint* wpt)

#if !ZLIB_INHIBITED
static void
tlog3a_xgcb_version(const char* args, const char** unused)
tlog3a_xgcb_version(const char* args, const QXmlStreamAttributes* unused)
{
if (strcmp(args, "1") != 0) {
fatal(MYNAME ": Unsupported file version '%s'!\n", args);
}
}

static void
tlog3a_xgcb_length(const char* args, const char** unused)
tlog3a_xgcb_length(const char* args, const QXmlStreamAttributes* unused)
{
}

static void
tlog3a_xgcb_data(const char* args, const char** unused)
tlog3a_xgcb_data(const char* args, const QXmlStreamAttributes* unused)
{
int len;
char* bin;
Expand Down Expand Up @@ -203,7 +205,7 @@ tlog3a_xgcb_data(const char* args, const char** unused)


static void
tlog3b_xgcb_tfna(const char* args, const char** unused)
tlog3b_xgcb_tfna(const char* args, const QXmlStreamAttributes* unused)
{
if (xmltrk == NULL) {
xmltrk = route_head_alloc();
Expand All @@ -214,7 +216,7 @@ tlog3b_xgcb_tfna(const char* args, const char** unused)


static void
tlog3b_xgcb_tfdes(const char* args, const char** unused)
tlog3b_xgcb_tfdes(const char* args, const QXmlStreamAttributes* unused)
{
if (xmltrk == NULL) {
xmltrk = route_head_alloc();
Expand All @@ -225,23 +227,23 @@ tlog3b_xgcb_tfdes(const char* args, const char** unused)


static void
tlog3b_xgcb_wptst(const char* args, const char** unused)
tlog3b_xgcb_wptst(const char* args, const QXmlStreamAttributes* unused)
{
xmlwpt = waypt_new();
xmldatum = DATUM_WGS84;
}


static void
tlog3b_xgcb_tptst(const char* args, const char** unused)
tlog3b_xgcb_tptst(const char* args, const QXmlStreamAttributes* unused)
{
xmlwpt = waypt_new();
xmldatum = DATUM_WGS84;
}


static void
tlog3b_xgcb_tpten(const char* args, const char** unused)
tlog3b_xgcb_tpten(const char* args, const QXmlStreamAttributes* unused)
{
finalize_pt(xmlwpt);

Expand All @@ -255,7 +257,7 @@ tlog3b_xgcb_tpten(const char* args, const char** unused)


static void
tlog3b_xgcb_wptid(const char* args, const char** unused)
tlog3b_xgcb_wptid(const char* args, const QXmlStreamAttributes* unused)
{
if (*args) {
xmlwpt->shortname = xstrdup(args);
Expand All @@ -264,14 +266,14 @@ tlog3b_xgcb_wptid(const char* args, const char** unused)


static void
tlog3b_xgcb_wptdt(const char* args, const char** unused)
tlog3b_xgcb_wptdt(const char* args, const QXmlStreamAttributes* unused)
{
xmldatum = GPS_Lookup_Datum_Index(args);
}


static void
tlog3b_xgcb_wptgr(const char* args, const char** unused)
tlog3b_xgcb_wptgr(const char* args, const QXmlStreamAttributes* unused)
{
if (xmlgrid != NULL) {
if (strcmp(xmlgrid, args) == 0) {
Expand All @@ -284,35 +286,35 @@ tlog3b_xgcb_wptgr(const char* args, const char** unused)


static void
tlog3b_xgcb_wptno(const char* args, const char** unused)
tlog3b_xgcb_wptno(const char* args, const QXmlStreamAttributes* unused)
{
xmlNorthing = atof(args);
}


static void
tlog3b_xgcb_wptea(const char* args, const char** unused)
tlog3b_xgcb_wptea(const char* args, const QXmlStreamAttributes* unused)
{
xmlEasting = atof(args);
}


static void
tlog3b_xgcb_wptal(const char* args, const char** unused)
tlog3b_xgcb_wptal(const char* args, const QXmlStreamAttributes* unused)
{
xmlAltitude = atof(args);
}


static void
tlog3b_xgcb_tptdt(const char* args, const char** unused)
tlog3b_xgcb_tptdt(const char* args, const QXmlStreamAttributes* unused)
{
xmldatum = GPS_Lookup_Datum_Index(args);
}


static void
tlog3b_xgcb_wpten(const char* args, const char** unused)
tlog3b_xgcb_wpten(const char* args, const QXmlStreamAttributes* unused)
{
finalize_pt(xmlwpt);
waypt_add(xmlwpt);
Expand Down
16 changes: 9 additions & 7 deletions gpsbabel/garmin_device_xml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
// http://developer.garmin.com/web-device/garmin-mass-storage-mode-devices/
// http://developer.garmin.com/schemas/device/v2/

#include <QtCore/QXmlStreamAttributes>

#include "defs.h"
#include "xmlgeneric.h"
#include "garmin_device_xml.h"
Expand All @@ -36,12 +38,12 @@ static char* mountpoint, *base, *path, *ext;
static xg_callback device_s, id_s, path_s, ext_s, base_s, dir_s;
jmp_buf gdx_jmp_buf;

void type_s(const char* args, const char** unused)
void type_s(const char* args, const QXmlStreamAttributes* unused)
{
type = strcmp(args, "GPSData");
}

void device_s(const char* args, const char** unused)
void device_s(const char* args, const QXmlStreamAttributes* unused)
{
if (my_gdx_info) {
fatal(MYNAME ": More than one device type found in file.\n");
Expand All @@ -50,27 +52,27 @@ void device_s(const char* args, const char** unused)
my_gdx_info->device_desc = xstrdup(args);
}

void id_s(const char* args, const char** unused)
void id_s(const char* args, const QXmlStreamAttributes* unused)
{
my_gdx_info->device_id = xstrdup(args);
}

void path_s(const char* args, const char** unused)
void path_s(const char* args, const QXmlStreamAttributes* unused)
{
path = xstrdup(args);
}

void ext_s(const char* args, const char** unused)
void ext_s(const char* args, const QXmlStreamAttributes* unused)
{
ext = xstrdup(args);
}

void base_s(const char* args, const char** unused)
void base_s(const char* args, const QXmlStreamAttributes* unused)
{
base = xstrdup(args);
}

void dir_s(const char* args, const char** unused)
void dir_s(const char* args, const QXmlStreamAttributes* unused)
{
if (type) {
return;
Expand Down
18 changes: 10 additions & 8 deletions gpsbabel/glogbook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/

#include <QtCore/QXmlStreamAttributes>

#include "defs.h"
#include "xmlgeneric.h"

Expand Down Expand Up @@ -124,44 +126,44 @@ glogbook_write(void)
gbfprintf(ofd, "</History>\n");
}

void gl_trk_s(const char* args, const char** unused)
void gl_trk_s(const char* args, const QXmlStreamAttributes* unused)
{
trk_head = route_head_alloc();
track_add_head(trk_head);
}
#if 0
void gl_trk_ident(const char* args, const char** unused)
void gl_trk_ident(const char* args, const QXmlStreamAttributes* unused)
{
trk_head->rte_name = xstrdup(args);
}
#endif

void gl_trk_pnt_s(const char* args, const char** unused)
void gl_trk_pnt_s(const char* args, const QXmlStreamAttributes* unused)
{
wpt_tmp = waypt_new();
}

void gl_trk_pnt_e(const char* args, const char** unused)
void gl_trk_pnt_e(const char* args, const QXmlStreamAttributes* unused)
{
track_add_wpt(trk_head, wpt_tmp);
}

void gl_trk_utc(const char* args, const char** unused)
void gl_trk_utc(const char* args, const QXmlStreamAttributes* unused)
{
wpt_tmp->SetCreationTime(xml_parse_time(args));
}

void gl_trk_lat(const char* args, const char** unused)
void gl_trk_lat(const char* args, const QXmlStreamAttributes* unused)
{
wpt_tmp->latitude = atof(args);
}

void gl_trk_long(const char* args, const char** unused)
void gl_trk_long(const char* args, const QXmlStreamAttributes* unused)
{
wpt_tmp->longitude = atof(args);
}

void gl_trk_alt(const char* args, const char** unused)
void gl_trk_alt(const char* args, const QXmlStreamAttributes* unused)
{
wpt_tmp->altitude = atof(args);
}
Expand Down
Loading

0 comments on commit 4673a25

Please sign in to comment.