-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml.hpp
74 lines (57 loc) · 1.79 KB
/
xml.hpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include <unordered_map>
#include <string>
#include <list>
#include <iostream>
#include "manipulators.hpp"
class XMLExpression
{
private:
public:
//XMLExpression() {};
virtual ~XMLExpression() {};
friend std::ostream& operator<<(std::ostream& os,XMLExpression* e);
virtual void print(std::ostream& os) const =0;
};
class SingleTag : public XMLExpression
{
protected:
std::unordered_map<std::string, std::string> attributes_;
std::string name_;
public:
SingleTag(std::string name, std::unordered_map<std::string, std::string> attributes);
~SingleTag();
virtual void print(std::ostream& os) const;
};
class DoubleTag : public SingleTag
{
protected:
std::list<::XMLExpression*> subexpressions_;
public:
DoubleTag(std::string name, std::list<::XMLExpression*> subexpressions, std::unordered_map<std::string, std::string> attributes);
~DoubleTag();
//friend std::ostream& operator<<(std::ostream& os, const DoubleTag& dt);
virtual void print(std::ostream& os) const;
};
class RootTag : public DoubleTag
{
private:
/* data */
public:
RootTag(std::string name, std::list<::XMLExpression*> subexpressions, std::unordered_map<std::string, std::string> attributes);
~RootTag();
virtual void print(std::ostream& os) const;
// friend std::ostream& operator<<(std::ostream& os, const RootTag& rt);
};
class Text : public XMLExpression
{
protected:
std::string content_;
public:
Text(std::string content);
~Text();
//friend std::ostream& operator<<(std::ostream& os, const Text& te);
virtual void print(std::ostream& os) const;
};
void tag_begin(std::ostream& os, const std::string& name, const std::unordered_map<std::string, std::string>& attributes);
void tag_end(std::ostream& os, const std::string& name);