28 typedef QString string_type;
29 typedef HtmlDocument document_type;
30 typedef HtmlNode node_type;
32 typedef std::shared_ptr<HtmlPrivate> pointer;
33 typedef std::shared_ptr<HtmlPrivate const> const_pointer;
34 typedef std::weak_ptr<HtmlPrivate> weak_pointer;
35 typedef std::weak_ptr<HtmlPrivate const> const_weak_pointer;
37 typedef std::list<HtmlAttribute> attribute_list_type;
38 typedef attribute_list_type::iterator attribute_iterator;
39 typedef attribute_list_type::const_iterator const_attribute_iterator;
42 enum : int { Unknown = 0, };
53 ProcessingInstruction = 7,
57 DocumentFragment = 11,
63 A = 10000, Abbr, Acronym, Address, Applet, Area, Article, Aside, Audio,
64 B, Base, Basefont, Bdi, Bdo, Bgsound, Big, Blink, Blockquote, Body, Br,
66 Canvas, Caption, Center, Cite, Code, Col, Colgroup, Command,
67 Datalist, Dd, Del, Details, Dfn, Dir, Div, Dl, Dt,
69 Fieldset, Figcaption, Figure, Font, Footer, Form, Frame, Frameset,
70 H1, H2, H3, H4, H5, H6, Head, Header, Hgroup, Hr, Htm,
71 I, Iframe, Img, Input, Ins, Isindex,
73 Label, Legend, Li, Link, Listing,
74 Map, Mark, Marquee, Menu, Meta, Meter,
75 Nav, Nobr, Noframes, Noscript,
76 Object, Ol, Optgroup, Option, Output,
77 P, Param, Plaintext, Pre, Progress,
80 S, Samp, Script, Section, Select, Small, Source, Spacer, Span, Strike,
81 Strong, Style, Sub, Summary, Sup,
82 Table, Tbody, Td, Textarea, Tfoot, Th, Thead, Time, Title, Tr, Track, Tt,
91 Metadata = 0x1, Flow = 0x2, Sectioning = 0x4, Heading = 0x8,
92 Phrasing = 0x10, Embeded = 0x20, Interactive = 0x40,
93 FormAssociated = 0x80, Transparent = 0x100, Other = 0x200,
95 Inline = 0x400, Block = 0x800,
101 enum Information : int
106 enum Place : int { Open, Close, Single, };
109 struct HtmlAttribute : public Html
111 HtmlAttribute(string_type const &nuri_, string_type const &lname_,
112 string_type const &qname_, string_type const &value_);
113 HtmlAttribute(string_type const &lname_, string_type const &value_);
115 bool operator ==(string_type const &lname_) const;
117 string_type namespace_uri;
118 string_type local_name;
123 class HtmlAttributes : public Html
126 HtmlAttributes(pointer node);
128 attribute_iterator begin();
129 attribute_iterator end();
135 class HtmlRange : public Html
138 class iterator : public std::iterator<std::bidirectional_iterator_tag, node_type>
142 iterator(Html::pointer const ¤t);
144 iterator& operator ++();
145 iterator operator ++(int);
147 bool operator ==(iterator const &rhs) const;
148 bool operator !=(iterator const &rhs) const;
150 HtmlNode& operator *() const;
151 HtmlNode* operator ->() const;
154 Html::pointer m_current;
159 HtmlRange(pointer begin_, pointer tail_);
160 HtmlRange(HtmlNode begin_, HtmlNode tail_);
164 //pointer common_ancestor();
165 //HtmlRange& remove();
167 pointer wrap(Html::string_type const &name_);
171 string_type debug_dump();
175 void check(std::vector<pointer> &under_, std::vector<pointer> &over_);
176 void reparent(pointer begin_, pointer tail_);
183 class HtmlNode : public Html
185 friend class HtmlDocument;
186 typedef HtmlNode self_type;
189 class child_iterator : public std::iterator<
190 std::bidirectional_iterator_tag, node_type>
192 friend class HtmlNode;
195 child_iterator(Html::pointer const ¤t);
197 child_iterator& operator ++();
198 child_iterator operator ++(int);
200 bool operator ==(child_iterator const &rhs) const;
201 bool operator !=(child_iterator const &rhs) const;
203 HtmlNode& operator *() const;
204 HtmlNode* operator ->() const;
207 Html::pointer m_current;
212 HtmlNode(weak_pointer const &pointer_);
213 HtmlNode(HtmlNode const &rhs);
218 bool equals(HtmlNode const &rhs) const;
219 bool containes(HtmlNode const &node) const; // 未実装
221 HtmlAttributes attributes();
223 child_iterator begin();
224 child_iterator end();
230 HtmlNode first(string_type const &name_);
232 HtmlNode last(string_type const &name_);
236 string_type content() const; // 未実装
238 HtmlNode clone(bool deep = true) const; // 未実装
240 HtmlNode insert(string_type const &name_, child_iterator place);
241 HtmlNode insert_text(string_type const &text, child_iterator place);
242 HtmlNode insert_comment(string_type const &comment, child_iterator place);
243 HtmlNode insert_cdata(string_type const &cdata, child_iterator place);
244 HtmlNode insert(HtmlRange range);
246 HtmlNode remove(HtmlNode node);
247 HtmlNode replace(HtmlNode const &newChild, const HtmlNode &oldChild);
249 bool operator ==(HtmlNode const &rhs) const;
250 bool operator !=(HtmlNode const &rhs) const;
251 operator bool() const;
253 void operator =(HtmlNode const &rhs);
255 // ------------------------------------------------------------------------
257 virtual document_type* document();
258 virtual document_type const* document() const;
260 virtual int type() const;
261 virtual int place() const;
263 virtual int tclass() const;
264 virtual string_type tname() const;
265 virtual int tcategory() const;
266 virtual int tinfo() const;
268 virtual string_type name() const;
269 virtual string_type value() const;
270 virtual void set_value(string_type const &value_);
273 virtual attribute_iterator abegin();
274 virtual attribute_iterator aend();
275 virtual const_attribute_iterator abegin() const;
276 virtual const_attribute_iterator aend() const;
278 virtual bool has_attribute(string_type const &name_) const;
279 virtual string_type attribute(string_type const &name_) const;
280 virtual HtmlNode& set_attribute(string_type const &name_, string_type const &value_);
281 virtual HtmlNode& set_attribute(string_type const &name_, int value_);
284 virtual string_type to_string() const;
285 virtual string_type debug_dump() const;
287 virtual pointer lself();
288 virtual const_pointer lself() const;
289 virtual pointer lbegin();
290 virtual pointer ltail();
293 pointer m_next; /*!< 次のデータ実体 */
297 class HtmlDocument : public HtmlNode
299 //friend class HtmlHandler;
300 //friend class HtmlDocumentOpenPrivate;
310 HtmlDocument(QByteArray html);
315 bool set_content(QByteArray const &html, int mode = Xhtml);
316 QByteArray to_byte_array() const;
317 string_type to_string() const;
319 bool parse(QByteArray bytes);
322 pointer set_lbegin(pointer const &begin_);
324 int find_tclass(string_type const &tname_) const;
326 void setup_tclasses();
329 static QMutex s_mutex;
330 std::map<string_type const, int const> m_tclasses;