Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'generator/xml_element.hpp')
-rw-r--r--generator/xml_element.hpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/generator/xml_element.hpp b/generator/xml_element.hpp
new file mode 100644
index 0000000000..966c0943bf
--- /dev/null
+++ b/generator/xml_element.hpp
@@ -0,0 +1,49 @@
+#pragma once
+#include "../coding/file_reader.hpp"
+#include "../std/string.hpp"
+#include "../std/vector.hpp"
+#include "../std/map.hpp"
+
+struct XMLElement
+{
+ string name;
+ map<string, string> attrs;
+ vector<XMLElement> childs;
+ XMLElement * parent;
+
+ void Clear()
+ {
+ name.clear();
+ attrs.clear();
+ childs.clear();
+ parent = 0;
+ }
+};
+
+class BaseOSMParser
+{
+ XMLElement m_element;
+ XMLElement * m_current;
+
+ size_t m_depth;
+
+ vector<string> m_tags;
+ bool is_our_tag(string const & name);
+
+public:
+ BaseOSMParser() : m_current(0), m_depth(0) {}
+
+ template <size_t N> void SetTags(char const * (&arr)[N]) { m_tags.assign(&arr[0], &arr[N]); }
+
+ bool Push(string const & name);
+ void AddAttr(string const & name, string const & value);
+ void Pop(string const &);
+ void CharData(string const &) {}
+
+protected:
+ virtual void EmitElement(XMLElement * p) = 0;
+};
+
+void ParseXMLFromStdIn(BaseOSMParser & parser);
+
+void ParseXMLFromFile(FileReader const & reader, BaseOSMParser & parser);