224 |
andreas |
1 |
/***************************************************************************
|
|
|
2 |
* Copyright (C) 2007, 2008 by Andreas Theofilu *
|
|
|
3 |
* andreas@theosys.at *
|
|
|
4 |
* *
|
|
|
5 |
* This program is free software; you can redistribute it and/or modify *
|
|
|
6 |
* it under the terms of the GNU General Public License as published by *
|
|
|
7 |
* the Free Software Foundation version 3 of the License. *
|
|
|
8 |
* *
|
|
|
9 |
* This program is distributed in the hope that it will be useful, *
|
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
12 |
* GNU General Public License for more details. *
|
|
|
13 |
* *
|
|
|
14 |
* You should have received a copy of the GNU General Public License *
|
|
|
15 |
* along with this program; if not, write to the *
|
|
|
16 |
* Free Software Foundation, Inc., *
|
|
|
17 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
18 |
***************************************************************************/
|
|
|
19 |
|
|
|
20 |
#ifndef _IMPORT_H
|
|
|
21 |
#define _IMPORT_H
|
|
|
22 |
|
|
|
23 |
#include <qfile.h>
|
|
|
24 |
#include <qstring.h>
|
|
|
25 |
#include <qxml.h>
|
|
|
26 |
|
|
|
27 |
#include "garmin.h"
|
|
|
28 |
#include "disassemble.h"
|
|
|
29 |
|
|
|
30 |
#define eMax 7
|
|
|
31 |
|
|
|
32 |
#define FLD_FIRST 1
|
|
|
33 |
#define FLD_LAST 24
|
|
|
34 |
#define CON_FIRST 100
|
|
|
35 |
#define CON_LAST 113
|
|
|
36 |
#define ERR_FIRST 500
|
|
|
37 |
#define ERR_LAST 507
|
|
|
38 |
|
|
|
39 |
#define ERR_OK 500
|
|
|
40 |
#define ERR_NOFILE 501
|
|
|
41 |
#define ERR_TAGS 502
|
|
|
42 |
#define ERR_ALLOCGMN 503
|
|
|
43 |
#define ERR_ALLOCLAP 504
|
|
|
44 |
#define ERR_ALLOCPOINT 505
|
|
|
45 |
#define ERR_ALLOCRUN 506
|
|
|
46 |
#define ERR_ALLOCLIST 507
|
|
|
47 |
|
|
|
48 |
typedef struct
|
|
|
49 |
{
|
|
|
50 |
int id;
|
|
|
51 |
QString name;
|
|
|
52 |
} KEYS;
|
|
|
53 |
|
|
|
54 |
extern KEYS keys[];
|
|
|
55 |
|
|
|
56 |
class gmn_import : public QXmlDefaultHandler
|
|
|
57 |
{
|
|
|
58 |
public:
|
|
|
59 |
gmn_import () { Initialize(); };
|
|
|
60 |
gmn_import (const QFile &qfile);
|
|
|
61 |
~gmn_import () { if (qfstat) file.close(); };
|
|
|
62 |
|
|
|
63 |
void Initialize ();
|
|
|
64 |
void setFile (const QFile &qfile);
|
|
|
65 |
void setFile (const QString &sfile);
|
|
|
66 |
void setDisassemble (disassemble *dis) { ds = dis; };
|
|
|
67 |
|
|
|
68 |
int import ();
|
|
|
69 |
garmin_data *getGarminData() { if (gmn) return gmn; else return 0; };
|
|
|
70 |
|
|
|
71 |
QString getError (int err);
|
|
|
72 |
QString getError ();
|
|
|
73 |
|
|
|
74 |
bool startDocument ();
|
|
|
75 |
bool startElement (const QString&, const QString&, const QString& , const QXmlAttributes&);
|
|
|
76 |
bool endElement (const QString&, const QString&, const QString&);
|
|
|
77 |
bool characters (const QString&);
|
|
|
78 |
|
|
|
79 |
protected:
|
|
|
80 |
unsigned int garmin_time (const QString&);
|
|
|
81 |
QString getKey (int pos);
|
|
|
82 |
|
|
|
83 |
private:
|
|
|
84 |
disassemble *ds;
|
|
|
85 |
QFile file;
|
|
|
86 |
bool qfstat, qfopen;
|
|
|
87 |
int __error;
|
|
|
88 |
int indent, tpos, lpos, oldLPos;
|
|
|
89 |
int tk;
|
|
|
90 |
QString con, subCon;
|
|
|
91 |
garmin_data *gmn, *gmn_lap, *gmn_track;
|
|
|
92 |
garmin_list *list, *list_lap, *list_track;
|
|
|
93 |
D1015 lap;
|
|
|
94 |
D1009 run, *prun;
|
|
|
95 |
D304 point;
|
|
|
96 |
|
|
|
97 |
};
|
|
|
98 |
|
|
|
99 |
#endif
|