source: subversion/applications/lib/libosm/Parser.h @ 14298

Last change on this file since 14298 was 11745, checked in by nienhueser, 11 years ago

Encapsulate Object::tags and add more documentation

File size: 1023 bytes
Line 
1#include "Object.h"
2#include "Components.h"
3
4#include <expat.h>
5
6#include <cstdio>
7#include <cstdlib>
8#include <iostream>
9#include <string>
10
11namespace OSM
12{
13
14/**
15 * Xml parser for OSM
16 */
17class Parser
18{
19public:
20        /**
21         * Parses xml provided by the given stream and returns the OSM components contained
22         * @param stream Input stream containing OSM xml (e.g. read from an OSM server or a local file)
23         * @return The OSM components contained in the stream
24         */
25        static Components* parse(std::istream &stream);
26
27        /**
28         * @return An empty string if no error occurred in the last parse call,
29         * or a description of the error otherwise
30         */
31        static std::string getError();
32
33private:
34        static void startElement(void *d, const XML_Char* name,
35                        const XML_Char** attrs);
36        static void endElement(void *d, const XML_Char* name);
37        static void characters(void*, const XML_Char* txt, int txtlen);
38
39        static Object *curObject;
40        static int curID;
41        static bool inNode, inWay;
42        static Components* components;
43        static std::string error;
44};
45
46}
Note: See TracBrowser for help on using the repository browser.