1
2
3
4
5
6 #ifndef SNGXML_DOM_CHARACTER_DATA_INCLUDED
7 #define SNGXML_DOM_CHARACTER_DATA_INCLUDED
8 #include <sngxml/dom/Node.hpp>
9
10 namespace sngxml { namespace dom {
11
12 std::u32string XmlCharDataEscape(const std::u32string& charData);
13
14 class CharacterData : public Node
15 {
16 public:
17 CharacterData(NodeType nodeType_, const std::u32string& name_);
18 CharacterData(NodeType nodeType_, const std::u32string& name_, const std::u32string& data_);
19 CharacterData(const CharacterData&) = delete;
20 CharacterData& operator=(const CharacterData&) = delete;
21 CharacterData(CharacterData&&) = delete;
22 CharacterData& operator=(CharacterData&&) = delete;
23 void Write(CodeFormatter& formatter) override;
24 bool ValueContainsNewLine() const override;
25 const std::u32string& Data() const { return data; }
26 std::u32string& Data() { return data; }
27 private:
28 std::u32string data;
29 };
30
31 class Text : public CharacterData
32 {
33 public:
34 Text();
35 Text(const std::u32string& data_);
36 Text(const Text&) = delete;
37 Text& operator=(const Text&) = delete;
38 Text(Text&&) = delete;
39 Text& operator=(Text&&) = delete;
40 Text(NodeType nodeType_, const std::u32string& name_);
41 Text(NodeType nodeType_, const std::u32string& name_, const std::u32string& data_);
42 std::unique_ptr<Node> CloneNode(bool deep) override;
43 void Accept(Visitor& visitor) override;
44 };
45
46 class EntityReference : public CharacterData
47 {
48 public:
49 EntityReference();
50 EntityReference(const std::u32string& entityRef_);
51 EntityReference(const EntityReference&) = delete;
52 EntityReference& operator=(const EntityReference&) = delete;
53 EntityReference(EntityReference&&) = delete;
54 EntityReference& operator=(EntityReference&&) = delete;
55 void Write(CodeFormatter& formatter) override;
56 std::unique_ptr<Node> CloneNode(bool deep) override;
57 void Accept(Visitor& visitor) override;
58 };
59
60 class CDataSection : public Text
61 {
62 public:
63 CDataSection();
64 CDataSection(const std::u32string& data_);
65 CDataSection(const CDataSection&) = delete;
66 CDataSection& operator=(const CDataSection&) = delete;
67 CDataSection(CDataSection&&) = delete;
68 CDataSection& operator=(CDataSection&&) = delete;
69 void Write(CodeFormatter& formatter) override;
70 std::unique_ptr<Node> CloneNode(bool deep) override;
71 void Accept(Visitor& visitor) override;
72 };
73
74 class Comment : public CharacterData
75 {
76 public:
77 Comment();
78 Comment(const std::u32string& data_);
79 Comment(const Comment&) = delete;
80 Comment& operator=(const Comment&) = delete;
81 Comment(Comment&&) = delete;
82 Comment& operator=(Comment&&) = delete;
83 void Write(CodeFormatter& formatter) override;
84 std::unique_ptr<Node> CloneNode(bool deep) override;
85 void Accept(Visitor& visitor) override;
86 };
87
88 class ProcessingInstruction : public Node
89 {
90 public:
91 ProcessingInstruction(const std::u32string& target_, const std::u32string& data_);
92 ProcessingInstruction(const ProcessingInstruction&) = delete;
93 ProcessingInstruction& operator=(const ProcessingInstruction&) = delete;
94 ProcessingInstruction(ProcessingInstruction&&) = delete;
95 ProcessingInstruction& operator=(ProcessingInstruction&&) = delete;
96 void Write(CodeFormatter& formatter) override;
97 std::unique_ptr<Node> CloneNode(bool deep) override;
98 void Accept(Visitor& visitor) override;
99 const std::u32string& Target() const { return target; }
100 const std::u32string& Data() const { return data; }
101 private:
102 std::u32string target;
103 std::u32string data;
104 };
105
106 } }
107
108 #endif // SNGXML_DOM_CHARACTER_DATA_INCLUDED