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

xml_element.hpp « generator - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 966c0943bf9f638cfcf1fdcebf99ead35edc5cf2 (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
#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);