dom_document.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 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 "dom_node.h"
33 #include <vector>
34
35 namespace clan
36 {
39
40 class IODevice;
41 class DomDocumentType;
42 class DomImplementation;
43 class DomCDATASection;
44 class DomProcessingInstruction;
45 class DomElement;
46 class DomDocumentFragment;
47 class DomComment;
48 class DomText;
49 class DomAttr;
50 class DomEntityReference;
51 class DomNodeList;
52 class DomDocument_Impl;
53
64 class DomDocument : public DomNode
65 {
68
69 public:
71 DomDocument();
72
77 DomDocument(IODevice &input, bool eat_whitespace = true);
78
79 DomDocument(
80 const DomString &namespace_uri,
81 const DomString &qualified_name,
82 const DomDocumentType &doctype);
83
87 DomDocument(const std::shared_ptr<DomNode_Impl> &impl);
88
89 ~DomDocument();
90
94
95 public:
97
100 DomDocumentType get_doctype();
101
103 DomImplementation get_implementation();
104
106
108 DomElement get_document_element();
109
113
114 public:
116
119 DomElement create_element(const DomString &tag_name);
120
122 DomElement create_element_ns(
123 const DomString &namespace_uri,
124 const DomString &qualified_name);
125
127 DomDocumentFragment create_document_fragment();
128
132 DomText create_text_node(const DomString &data);
133
137 DomComment create_comment(const DomString &data);
138
142 DomCDATASection create_cdata_section(const DomString &data);
143
148 DomProcessingInstruction create_processing_instruction(
149 const DomString &target,
150 const DomString &data);
151
153
155 DomAttr create_attribute(const DomString &name);
156
158
159 DomAttr create_attribute_ns(
160 const DomString &namespace_uri,
161 const DomString &qualified_name);
162
166 DomEntityReference create_entity_reference(const DomString &name);
167
169
172 DomNodeList get_elements_by_tag_name(const DomString &tag_name);
173
175
177 DomNodeList get_elements_by_tag_name_ns(
178 const DomString &namespace_uri,
179 const DomString &qualified_name);
180
182 DomElement get_element_by_id(const DomString &element_id);
183
185
194 DomNode import_node(
195 const DomNode &node,
196 bool deep);
197
204 std::vector<DomNode> load(
205 IODevice &input,
206 bool eat_whitespace = true,
207 DomNode insert_point = DomNode());
208
213 void save(IODevice &output, bool insert_whitespace = true);
214
216 void clear_all();
217
221
222 private:
224 };
225
226 }
227
clan::DomDocument::create_cdata_section
DomCDATASection create_cdata_section(const DomString &data)
Creates a CDATASection node whose value is the specified string.
clan::DomAttr
DOM Attribute class.
Definition: dom_attr.h:66
clan
Definition: clanapp.h:35
clan::DomComment
DOM Comment class.
Definition: dom_comment.h:44
clan::DomDocument::get_document_element
DomElement get_document_element()
Returns the root document element node.
clan::DomDocument::import_node
DomNode import_node(const DomNode &node, bool deep)
Imports a node from another document to this document.
clan::DomNodeList
DOM Node List class.
Definition: dom_node_list.h:50
clan::DomDocumentType
DOM Document Type class.
Definition: dom_document_type.h:50
clan::DomDocument::get_elements_by_tag_name
DomNodeList get_elements_by_tag_name(const DomString &tag_name)
Returns a NodeList of all the Elements with a given tag name.
clan::DomDocument::get_implementation
DomImplementation get_implementation()
Returns the DomImplementation object that handles this document.
clan::IODevice
I/O Device interface.
Definition: iodevice.h:50
clan::DomDocument::create_document_fragment
DomDocumentFragment create_document_fragment()
Creates an empty DocumentFragment object.
clan::DomDocument::create_entity_reference
DomEntityReference create_entity_reference(const DomString &name)
Creates an EntityReference object.
clan::DomDocument::create_text_node
DomText create_text_node(const DomString &data)
Creates a Text node given the specified string.
clan::DomDocument::create_comment
DomComment create_comment(const DomString &data)
Creates a Comment node given the specified string.
clan::DomCDATASection
DOM CDATA Section.
Definition: dom_cdata_section.h:54
clan::DomDocument::create_processing_instruction
DomProcessingInstruction create_processing_instruction(const DomString &target, const DomString &data)
Creates a ProcessingInstruction node given the specified name and data strings.
clan::DomNode::DomNode
DomNode()
clan::DomString
std::string DomString
Definition: dom_string.h:37
clan::DomNode::impl
std::shared_ptr< DomNode_Impl > impl
Definition: dom_node.h:422
clan::DomDocument
DOM Document class.
Definition: dom_document.h:64
clan::DomEntityReference
DOM Entity Reference class.
Definition: dom_entity_reference.h:51
clan::DomDocument::clear_all
void clear_all()
Removes all nodes from the DOM document.
clan::DomNode
DOM Node class.
Definition: dom_node.h:70
clan::DomDocument::create_attribute
DomAttr create_attribute(const DomString &name)
Creates an Attr of the given name.
clan::DomElement
DOM Element class.
Definition: dom_element.h:59
clan::DomDocument::create_element_ns
DomElement create_element_ns(const DomString &namespace_uri, const DomString &qualified_name)
Creates an element of the given qualified name and namespace URI.
clan::DomDocument::create_element
DomElement create_element(const DomString &tag_name)
Creates an element of the type specified.
clan::DomText
DOM Text class.
Definition: dom_text.h:54
clan::DomDocument::get_elements_by_tag_name_ns
DomNodeList get_elements_by_tag_name_ns(const DomString &namespace_uri, const DomString &qualified_name)
Returns a NodeList of all the Elements with a given local name and namespace URI. ...
clan::DomDocument::DomDocument
DomDocument()
Constructs a DOM Document.
clan::DomDocument::get_doctype
DomDocumentType get_doctype()
Returns the Document Type Declaration (see DomDocumentType)associated with this document.
clan::DomDocument::save
void save(IODevice &output, bool insert_whitespace=true)
Saves the DOM document as XML to an input source.
clan::DomDocumentFragment
DOM Document Fragment class.
Definition: dom_document_fragment.h:70
clan::DomProcessingInstruction
DOM Processing Instruction class.
Definition: dom_processing_instruction.h:43
clan::DomImplementation
DOM Implementation class.
Definition: dom_implementation.h:48
clan::DomDocument::get_element_by_id
DomElement get_element_by_id(const DomString &element_id)
Returns the Element whose ID is given by element_id.
clan::DomDocument::create_attribute_ns
DomAttr create_attribute_ns(const DomString &namespace_uri, const DomString &qualified_name)
Creates an attribute of the given qualified name and namespace URI.
clan::DomDocument::~DomDocument
~DomDocument()
clan::DomDocument::load
std::vector< DomNode > load(IODevice &input, bool eat_whitespace=true, DomNode insert_point=DomNode())
Loads the DOM document as XML from an input source.