source: subversion/applications/utils/export/segmentise/Parser.h @ 28183

Last change on this file since 28183 was 24400, checked in by nick, 9 years ago

Added segmentise utility: break down OSM ways into segments at joins

File size: 1.1 KB
Line 
1#ifndef PARSER_H
2#define PARSER_H
3
4// based on the libosm parser
5// http://svn.openstreetmap.org/applications/lib/libosm/
6
7#include <expat.h>
8
9#include <cstdio>
10#include <cstdlib>
11#include <iostream>
12#include <string>
13#include <map>
14
15using std::cout;
16using std::cerr;
17using std::endl;
18
19#include "segmentise.h"
20
21/**
22 * Xml parser for OSM
23 */
24class Parser
25{
26public:
27        static bool parse(XML_Parser p,std::istream &stream);
28
29        /**
30         * @return An empty string if no error occurred in the last parse call,
31         * or a description of the error otherwise
32         */
33        static std::string getError();
34
35        static void startElement(void *d, const XML_Char* name,
36                        const XML_Char** attrs);
37        static void endElement(void *d, const XML_Char* name);
38        static void characters(void*, const XML_Char* txt, int txtlen);
39
40private:
41
42        static void writeCurrentTags(std::map<std::string,std::string>& tags);
43        static void freeNodes();
44
45        static int curID, wayCount;
46        static bool inNode, inWay;
47        static std::map <int,Node*> nodes;
48        static std::map<std::string,std::string> tags;
49        static std::string error;
50        static Way curWay;
51
52        static bool initialRun;
53
54};
55
56#endif
Note: See TracBrowser for help on using the repository browser.