Subversion Repositories public

Rev

Rev 232 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
224 andreas 1
/***************************************************************************
314 andreas 2
 *   Copyright (C) 2007 - 2013 by Andreas Theofilu                         *
224 andreas 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>
232 andreas 25
#include <QXmlReader>
224 andreas 26
 
27
#include "garmin.h"
28
#include "disassemble.h"
314 andreas 29
#include "callback.h"
224 andreas 30
 
31
#define eMax 7
32
 
33
#define FLD_FIRST	1
225 andreas 34
#define FLD_LAST	30
224 andreas 35
#define CON_FIRST	100
225 andreas 36
#define CON_LAST	121
37
#define ATT_FIRST	200
38
#define ATT_LAST	200
224 andreas 39
#define ERR_FIRST	500
40
#define ERR_LAST	507
41
 
42
#define ERR_OK			500
43
#define ERR_NOFILE		501
44
#define ERR_TAGS		502
45
#define ERR_ALLOCGMN		503
46
#define ERR_ALLOCLAP		504
47
#define ERR_ALLOCPOINT		505
48
#define ERR_ALLOCRUN		506
49
#define ERR_ALLOCLIST		507
50
 
51
typedef struct
52
{
53
	int id;
54
	QString name;
55
} KEYS;
56
 
57
extern KEYS keys[];
58
 
59
class gmn_import : public QXmlDefaultHandler
60
{
61
	public:
62
	   gmn_import () { Initialize(); };
63
	   gmn_import (const QFile &qfile);
64
	   ~gmn_import () { if (qfstat) file.close(); };
65
 
66
	   void Initialize ();
67
	   void setFile (const QFile &qfile);
68
	   void setFile (const QString &sfile);
69
	   void setDisassemble (disassemble *dis) { ds = dis; };
70
 
314 andreas 71
	   void connectCallback(CallbackInterface *cb) { m_cb = cb; }
72
 
224 andreas 73
	   int import ();
74
	   garmin_data *getGarminData() { if (gmn) return gmn; else return 0; };
75
 
76
	   QString getError (int err);
77
	   QString getError ();
78
 
79
	   bool startDocument ();
80
	   bool startElement (const QString&, const QString&, const QString& , const QXmlAttributes&);
81
	   bool endElement (const QString&, const QString&, const QString&);
82
	   bool characters (const QString&);
314 andreas 83
	   void saveImported(void *g);
224 andreas 84
 
85
	protected:
86
	   unsigned int garmin_time (const QString&);
87
	   QString getKey (int pos);
88
 
89
	private:
314 andreas 90
	   CallbackInterface *m_cb;
91
	   bool doCallback;
92
	   gmn_import *inst;
224 andreas 93
	   disassemble *ds;
94
	   QFile file;
95
	   bool qfstat, qfopen;
96
	   int __error;
97
	   int indent, tpos, lpos, oldLPos;
225 andreas 98
	   int tk, first_tpos;
99
	   bool history, fakeLap;
224 andreas 100
	   QString con, subCon;
101
	   garmin_data *gmn, *gmn_lap, *gmn_track;
102
	   garmin_list *list, *list_lap, *list_track;
225 andreas 103
	   D1015 lap, *plap;
224 andreas 104
	   D1009 run, *prun;
105
	   D304 point;
106
 
107
};
108
 
109
#endif