3 #include <wordring/html/simple_node.hpp>
5 #include <wordring/encoding/encoding.hpp>
7 #include <wordring/compatibility.hpp>
8 #include <wordring/tree/tree.hpp>
22 template <
typename NodeIterator>
25 using node_pointer = NodeIterator;
26 using node_type =
typename node_pointer::value_type;
28 using element_type =
typename node_type::element_type;
29 using text_type =
typename node_type::text_type;
30 using processing_instruction_type =
typename node_type::processing_instruction_type;
31 using comment_type =
typename node_type::comment_type;
32 using document_type =
typename node_type::document_type;
33 using document_type_type =
typename node_type::document_type_type;
34 using document_fragment_type =
typename node_type::document_fragment_type;
36 using attribute_type =
typename element_type::attribute_type;
37 using attribute_pointer =
typename element_type::const_iterator;
39 using string_type =
typename element_type::string_type;
47 static node_pointer
pointer() {
return node_pointer(); }
54 static node_pointer
parent(node_pointer it) {
return it.parent(); }
58 static node_pointer
begin(node_pointer it) {
return it.begin(); }
62 static node_pointer
end(node_pointer it) {
return it.end(); }
66 static node_pointer
prev(node_pointer it) {
return --it; }
70 static node_pointer
next(node_pointer it) {
return ++it; }
72 static auto& data(node_pointer it) {
return it->data(); }
74 static auto target(node_pointer it) {
return it->target(); }
76 static auto name(node_pointer it) {
return it->name(); }
82 static bool is_element(node_pointer it) {
return it->is_element(); }
94 return it->namespace_uri_name();
97 static string_type get_namespace(node_pointer it)
99 return it->namespace_uri();
106 return it->local_name_name();
109 static string_type get_local_name(node_pointer it)
111 return it->local_name();
114 static string_type get_qualified_name(node_pointer it)
116 return it->qualified_name();
119 static bool is_html_element_of(node_pointer it, tag_name tag)
128 static bool equals(node_pointer lhs, node_pointer rhs)
135 static auto abegin(node_pointer it) {
return it->begin(); }
137 static auto aend(node_pointer it) {
return it->end(); }
166 return attr.namespace_uri_name();
169 static string_type get_namespace(attribute_type
const& attr)
171 return attr.namespace_uri();
176 return attr.local_name_name();
179 static string_type get_local_name(attribute_type
const& attr)
181 return attr.local_name();
184 static string_type get_qualified_name(attribute_type
const& attr)
186 return attr.qualified_name();
189 static string_type
const& value(attribute_type
const& attr) {
return attr.value(); }
195 static bool is_text(node_pointer it) {
return it->is_text(); }
197 static text_type create_text(char32_t cp)
200 wordring::to_string(cp, std::back_inserter(s));
204 static void append_text(node_pointer it, char32_t cp)
206 wordring::to_string(cp, std::back_inserter(it->data()));
213 static bool is_processing_instruction(node_pointer it) {
return it->is_processing_instruction(); }
219 static bool is_comment(node_pointer it) {
return it->is_comment(); }
221 static comment_type create_comment(string_type
const& data)
223 return comment_type(data);
230 static bool is_document(node_pointer it) {
return it->is_document(); }
236 return it->document_type_name();
246 it->document_type_name(type);
253 return it->document_mode_name();
263 it->document_mode_name(mode);
286 static bool is_document_type(node_pointer it) {
return it->is_document_type(); }
288 static document_type_type create_document_type(
289 string_type
const& name, string_type
const& public_id, string_type
const& system_id)
291 return document_type_type(name, public_id, system_id);
298 static bool is_root(node_pointer it)
300 return is_element(it) && is_html_element_of(it, tag_name::Html);
307 static bool is_single(node_type
const& node)
311 case node_type::type_name::Text:
312 case node_type::type_name::Comment:
313 case node_type::type_name::DocumentType: