dom_document.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
29 
30 #pragma once
31 
32 #include "../api_core.h"
33 #include "dom_node.h"
34 #include <vector>
35 
36 namespace clan
37 {
40 
41 class IODevice;
42 class DomDocumentType;
43 class DomImplementation;
44 class DomCDATASection;
45 class DomProcessingInstruction;
46 class DomElement;
47 class DomDocumentFragment;
48 class DomComment;
49 class DomText;
50 class DomAttr;
51 class DomEntityReference;
52 class DomNodeList;
53 class DomDocument_Impl;
54 
65 class CL_API_CORE DomDocument : public DomNode
66 {
69 
70 public:
72  DomDocument();
73 
78  DomDocument(IODevice &input, bool eat_whitespace = true);
79 
81  const DomString &namespace_uri,
82  const DomString &qualified_name,
83  const DomDocumentType &doctype);
84 
88  DomDocument(const std::shared_ptr<DomNode_Impl> &impl);
89 
90  ~DomDocument();
91 
95 
96 public:
98 
101  DomDocumentType get_doctype();
102 
104  DomImplementation get_implementation();
105 
107 
109  DomElement get_document_element();
110 
114 
115 public:
117 
120  DomElement create_element(const DomString &tag_name);
121 
123  DomElement create_element_ns(
124  const DomString &namespace_uri,
125  const DomString &qualified_name);
126 
128  DomDocumentFragment create_document_fragment();
129 
133  DomText create_text_node(const DomString &data);
134 
138  DomComment create_comment(const DomString &data);
139 
143  DomCDATASection create_cdata_section(const DomString &data);
144 
149  DomProcessingInstruction create_processing_instruction(
150  const DomString &target,
151  const DomString &data);
152 
154 
156  DomAttr create_attribute(const DomString &name);
157 
159 
160  DomAttr create_attribute_ns(
161  const DomString &namespace_uri,
162  const DomString &qualified_name);
163 
167  DomEntityReference create_entity_reference(const DomString &name);
168 
170 
173  DomNodeList get_elements_by_tag_name(const DomString &tag_name);
174 
176 
178  DomNodeList get_elements_by_tag_name_ns(
179  const DomString &namespace_uri,
180  const DomString &qualified_name);
181 
183  DomElement get_element_by_id(const DomString &element_id);
184 
186 
195  DomNode import_node(
196  const DomNode &node,
197  bool deep);
198 
205  std::vector<DomNode> load(
206  IODevice &input,
207  bool eat_whitespace = true,
208  DomNode insert_point = DomNode());
209 
214  void save(IODevice &output, bool insert_whitespace = true);
215 
217  void clear_all();
218 
222 
223 private:
225 };
226 
227 }
228 
DOM Attribute class.
Definition: dom_attr.h:67
DOM Comment class.
Definition: dom_comment.h:45
DOM Node List class.
Definition: dom_node_list.h:51
DOM Document Type class.
Definition: dom_document_type.h:51
I/O Device interface.
Definition: iodevice.h:51
DOM CDATA Section.
Definition: dom_cdata_section.h:55
std::string DomString
Definition: dom_string.h:37
DOM Document class.
Definition: dom_document.h:65
DOM Entity Reference class.
Definition: dom_entity_reference.h:52
DOM Node class.
Definition: dom_node.h:71
DOM Element class.
Definition: dom_element.h:60
DOM Text class.
Definition: dom_text.h:55
DOM Document Fragment class.
Definition: dom_document_fragment.h:71
DOM Processing Instruction class.
Definition: dom_processing_instruction.h:44
DOM Implementation class.
Definition: dom_implementation.h:49