summaryrefslogtreecommitdiffstats
path: root/kgeography/src/mapparser.h
blob: 9db844ae4bbe5f28ceea24adfdc266121d84b173 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/***************************************************************************
 *   Copyright (C) 2004 by Albert Astals Cid                               *
 *   tsdgeos@terra.es                                                      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef MAPPARSER_H
#define MAPPARSER_H

#include <tqxml.h>

class division;
class KGmap;

class mapReader : public QXmlSimpleReader
{
	public:
		mapReader();
		
		bool parseMap(const TQString &path);
		TQString getError();
		KGmap *getMap();
	
	private:
		TQString p_error;
		KGmap *p_map;
};

class mapParser : public QXmlDefaultHandler
{
	public:
		mapParser(KGmap *m, const TQString &path);
		bool startDocument();
		bool startElement(const TQString&, const TQString&, const TQString&, const TQXmlAttributes&);
		bool endElement(const TQString &, const TQString &name, const TQString &);
		bool characters(const TQString &ch);
		bool endDocument();
		TQString errorString();
	
	private:
		TQString getPreviousTag() const;
		void removeLastTag();
		
		division *p_division;
		int p_red, p_green, p_blue;
		KGmap *p_map;
		bool p_allowChars, p_mapNameSet, p_mapFileSet;
		bool p_divisionNameSet, p_colorSet, p_divisionIgnoreSet, p_flagFileSet, p_capitalSet;
		const TQString &p_path;
		TQString p_error, p_contents, p_previousTags;
};

#endif