qdom.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/xml/dom/qdom.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7static void qt_split_namespace(QString& prefix, QString& name, const QString& qName, bool hasURI)-
8{-
9 int i = qName.indexOf(QLatin1Char(':'));-
10 if (i == -1) {-
11 if (hasURI)-
12 prefix = QLatin1String("");-
13 else-
14 prefix.clear();-
15 name = qName;-
16 } else {-
17 prefix = qName.left(i);-
18 name = qName.mid(i + 1);-
19 }-
20}-
21-
22-
23-
24-
25-
26-
27-
28class QDomImplementationPrivate-
29{-
30public:-
31 inline QDomImplementationPrivate() {}-
32-
33 QDomImplementationPrivate* clone();-
34 QAtomicInt ref;-
35 static QDomImplementation::InvalidDataPolicy invalidDataPolicy;-
36};-
37-
38class QDomNodePrivate-
39{-
40public:-
41 QDomNodePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0);-
42 QDomNodePrivate(QDomNodePrivate* n, bool deep);-
43 virtual ~QDomNodePrivate();-
44-
45 QString nodeName() const { return name; }-
46 QString nodeValue() const { return value; }-
47 virtual void setNodeValue(const QString& v) { value = v; }-
48-
49 QDomDocumentPrivate* ownerDocument();-
50 void setOwnerDocument(QDomDocumentPrivate* doc);-
51-
52 virtual QDomNodePrivate* insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild);-
53 virtual QDomNodePrivate* insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild);-
54 virtual QDomNodePrivate* replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild);-
55 virtual QDomNodePrivate* removeChild(QDomNodePrivate* oldChild);-
56 virtual QDomNodePrivate* appendChild(QDomNodePrivate* newChild);-
57-
58 QDomNodePrivate* namedItem(const QString& name);-
59-
60 virtual QDomNodePrivate* cloneNode(bool deep = true);-
61 virtual void normalize();-
62 virtual void clear();-
63-
64 inline QDomNodePrivate* parent() const { return hasParent ? ownerNode : 0; }-
65 inline void setParent(QDomNodePrivate *p) { ownerNode = p; hasParent = true; }-
66-
67 void setNoParent() {-
68 ownerNode = hasParent ? (QDomNodePrivate*)ownerDocument() : 0;-
69 hasParent = false;-
70 }-
71-
72-
73 bool isAttr() const { return nodeType() == QDomNode::AttributeNode; }-
74 bool isCDATASection() const { return nodeType() == QDomNode::CDATASectionNode; }-
75 bool isDocumentFragment() const { return nodeType() == QDomNode::DocumentFragmentNode; }-
76 bool isDocument() const { return nodeType() == QDomNode::DocumentNode; }-
77 bool isDocumentType() const { return nodeType() == QDomNode::DocumentTypeNode; }-
78 bool isElement() const { return nodeType() == QDomNode::ElementNode; }-
79 bool isEntityReference() const { return nodeType() == QDomNode::EntityReferenceNode; }-
80 bool isText() const { const QDomNode::NodeType nt = nodeType();-
81 return (nt == QDomNode::TextNode)-
82 || (nt == QDomNode::CDATASectionNode); }-
83 bool isEntity() const { return nodeType() == QDomNode::EntityNode; }-
84 bool isNotation() const { return nodeType() == QDomNode::NotationNode; }-
85 bool isProcessingInstruction() const { return nodeType() == QDomNode::ProcessingInstructionNode; }-
86 bool isCharacterData() const { const QDomNode::NodeType nt = nodeType();-
87 return (nt == QDomNode::CharacterDataNode)-
88 || (nt == QDomNode::TextNode)-
89 || (nt == QDomNode::CommentNode); }-
90 bool isComment() const { return nodeType() == QDomNode::CommentNode; }-
91-
92 virtual QDomNode::NodeType nodeType() const { return QDomNode::BaseNode; }-
93-
94 virtual void save(QTextStream&, int, int) const;-
95-
96 void setLocation(int lineNumber, int columnNumber);-
97-
98-
99 QAtomicInt ref;-
100 QDomNodePrivate* prev;-
101 QDomNodePrivate* next;-
102 QDomNodePrivate* ownerNode;-
103 QDomNodePrivate* first;-
104 QDomNodePrivate* last;-
105-
106 QString name;-
107 QString value;-
108 QString prefix;-
109 QString namespaceURI;-
110 bool createdWithDom1Interface : 1;-
111 bool hasParent : 1;-
112-
113 int lineNumber;-
114 int columnNumber;-
115};-
116-
117class QDomNodeListPrivate-
118{-
119public:-
120 QDomNodeListPrivate(QDomNodePrivate*);-
121 QDomNodeListPrivate(QDomNodePrivate*, const QString& );-
122 QDomNodeListPrivate(QDomNodePrivate*, const QString&, const QString& );-
123 ~QDomNodeListPrivate();-
124-
125 bool operator== (const QDomNodeListPrivate&) const;-
126 bool operator!= (const QDomNodeListPrivate&) const;-
127-
128 void createList();-
129 QDomNodePrivate* item(int index);-
130 int length() const;-
131-
132 QAtomicInt ref;-
133-
134-
135-
136 QDomNodePrivate* node_impl;-
137 QString tagname;-
138 QString nsURI;-
139 QList<QDomNodePrivate*> list;-
140 long timestamp;-
141};-
142-
143class QDomNamedNodeMapPrivate-
144{-
145public:-
146 QDomNamedNodeMapPrivate(QDomNodePrivate*);-
147 ~QDomNamedNodeMapPrivate();-
148-
149 QDomNodePrivate* namedItem(const QString& name) const;-
150 QDomNodePrivate* namedItemNS(const QString& nsURI, const QString& localName) const;-
151 QDomNodePrivate* setNamedItem(QDomNodePrivate* arg);-
152 QDomNodePrivate* setNamedItemNS(QDomNodePrivate* arg);-
153 QDomNodePrivate* removeNamedItem(const QString& name);-
154 QDomNodePrivate* item(int index) const;-
155 int length() const;-
156 bool contains(const QString& name) const;-
157 bool containsNS(const QString& nsURI, const QString & localName) const;-
158-
159-
160-
161-
162 void clearMap();-
163 bool isReadOnly() { return readonly; }-
164 void setReadOnly(bool r) { readonly = r; }-
165 bool isAppendToParent() { return appendToParent; }-
166 void setAppendToParent(bool b) { appendToParent = b; }-
167-
168-
169-
170-
171-
172 QDomNamedNodeMapPrivate* clone(QDomNodePrivate* parent);-
173-
174-
175 QAtomicInt ref;-
176 QHash<QString, QDomNodePrivate *> map;-
177 QDomNodePrivate* parent;-
178 bool readonly;-
179 bool appendToParent;-
180};-
181-
182class QDomDocumentTypePrivate : public QDomNodePrivate-
183{-
184public:-
185 QDomDocumentTypePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0);-
186 QDomDocumentTypePrivate(QDomDocumentTypePrivate* n, bool deep);-
187 ~QDomDocumentTypePrivate();-
188 void init();-
189-
190-
191 QDomNodePrivate* cloneNode(bool deep = true) override;-
192 QDomNodePrivate* insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild) override;-
193 QDomNodePrivate* insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild) override;-
194 QDomNodePrivate* replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild) override;-
195 QDomNodePrivate* removeChild(QDomNodePrivate* oldChild) override;-
196 QDomNodePrivate* appendChild(QDomNodePrivate* newChild) override;-
197-
198 QDomNode::NodeType nodeType() const override { return QDomNode::DocumentTypeNode; }-
199-
200 void save(QTextStream& s, int, int) const override;-
201-
202-
203 QDomNamedNodeMapPrivate* entities;-
204 QDomNamedNodeMapPrivate* notations;-
205 QString publicId;-
206 QString systemId;-
207 QString internalSubset;-
208};-
209-
210class QDomDocumentFragmentPrivate : public QDomNodePrivate-
211{-
212public:-
213 QDomDocumentFragmentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent = 0);-
214 QDomDocumentFragmentPrivate(QDomNodePrivate* n, bool deep);-
215-
216-
217 virtual QDomNodePrivate* cloneNode(bool deep = true) override;-
218 QDomNode::NodeType nodeType() const override { return QDomNode::DocumentFragmentNode; }-
219};-
220-
221class QDomCharacterDataPrivate : public QDomNodePrivate-
222{-
223public:-
224 QDomCharacterDataPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& data);-
225 QDomCharacterDataPrivate(QDomCharacterDataPrivate* n, bool deep);-
226-
227 int dataLength() const;-
228 QString substringData(unsigned long offset, unsigned long count) const;-
229 void appendData(const QString& arg);-
230 void insertData(unsigned long offset, const QString& arg);-
231 void deleteData(unsigned long offset, unsigned long count);-
232 void replaceData(unsigned long offset, unsigned long count, const QString& arg);-
233-
234-
235 QDomNode::NodeType nodeType() const override { return QDomNode::CharacterDataNode; }-
236 QDomNodePrivate* cloneNode(bool deep = true) override;-
237};-
238-
239class QDomTextPrivate : public QDomCharacterDataPrivate-
240{-
241public:-
242 QDomTextPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val);-
243 QDomTextPrivate(QDomTextPrivate* n, bool deep);-
244-
245 QDomTextPrivate* splitText(int offset);-
246-
247-
248 QDomNodePrivate* cloneNode(bool deep = true) override;-
249 QDomNode::NodeType nodeType() const override { return QDomNode::TextNode; }-
250 virtual void save(QTextStream& s, int, int) const override;-
251};-
252-
253class QDomAttrPrivate : public QDomNodePrivate-
254{-
255public:-
256 QDomAttrPrivate(QDomDocumentPrivate*, QDomNodePrivate*, const QString& name);-
257 QDomAttrPrivate(QDomDocumentPrivate*, QDomNodePrivate*, const QString& nsURI, const QString& qName);-
258 QDomAttrPrivate(QDomAttrPrivate* n, bool deep);-
259-
260 bool specified() const;-
261-
262-
263 void setNodeValue(const QString& v) override;-
264 QDomNodePrivate* cloneNode(bool deep = true) override;-
265 QDomNode::NodeType nodeType() const override { return QDomNode::AttributeNode; }-
266 virtual void save(QTextStream& s, int, int) const override;-
267-
268-
269 bool m_specified;-
270};-
271-
272class QDomElementPrivate : public QDomNodePrivate-
273{-
274public:-
275 QDomElementPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name);-
276 QDomElementPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& nsURI, const QString& qName);-
277 QDomElementPrivate(QDomElementPrivate* n, bool deep);-
278 ~QDomElementPrivate();-
279-
280 QString attribute(const QString& name, const QString& defValue) const;-
281 QString attributeNS(const QString& nsURI, const QString& localName, const QString& defValue) const;-
282 void setAttribute(const QString& name, const QString& value);-
283 void setAttributeNS(const QString& nsURI, const QString& qName, const QString& newValue);-
284 void removeAttribute(const QString& name);-
285 QDomAttrPrivate* attributeNode(const QString& name);-
286 QDomAttrPrivate* attributeNodeNS(const QString& nsURI, const QString& localName);-
287 QDomAttrPrivate* setAttributeNode(QDomAttrPrivate* newAttr);-
288 QDomAttrPrivate* setAttributeNodeNS(QDomAttrPrivate* newAttr);-
289 QDomAttrPrivate* removeAttributeNode(QDomAttrPrivate* oldAttr);-
290 bool hasAttribute(const QString& name);-
291 bool hasAttributeNS(const QString& nsURI, const QString& localName);-
292-
293 QString text();-
294-
295-
296 QDomNamedNodeMapPrivate* attributes() { return m_attr; }-
297 bool hasAttributes() { return (m_attr->length() > 0); }-
298 QDomNode::NodeType nodeType() const override { return QDomNode::ElementNode; }-
299 QDomNodePrivate* cloneNode(bool deep = true) override;-
300 virtual void save(QTextStream& s, int, int) const override;-
301-
302-
303 QDomNamedNodeMapPrivate* m_attr;-
304};-
305-
306-
307class QDomCommentPrivate : public QDomCharacterDataPrivate-
308{-
309public:-
310 QDomCommentPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val);-
311 QDomCommentPrivate(QDomCommentPrivate* n, bool deep);-
312-
313-
314 QDomNodePrivate* cloneNode(bool deep = true) override;-
315 QDomNode::NodeType nodeType() const override { return QDomNode::CommentNode; }-
316 virtual void save(QTextStream& s, int, int) const override;-
317};-
318-
319class QDomCDATASectionPrivate : public QDomTextPrivate-
320{-
321public:-
322 QDomCDATASectionPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& val);-
323 QDomCDATASectionPrivate(QDomCDATASectionPrivate* n, bool deep);-
324-
325-
326 QDomNodePrivate* cloneNode(bool deep = true) override;-
327 QDomNode::NodeType nodeType() const override { return QDomNode::CDATASectionNode; }-
328 virtual void save(QTextStream& s, int, int) const override;-
329};-
330-
331class QDomNotationPrivate : public QDomNodePrivate-
332{-
333public:-
334 QDomNotationPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name,-
335 const QString& pub, const QString& sys);-
336 QDomNotationPrivate(QDomNotationPrivate* n, bool deep);-
337-
338-
339 QDomNodePrivate* cloneNode(bool deep = true) override;-
340 QDomNode::NodeType nodeType() const override { return QDomNode::NotationNode; }-
341 virtual void save(QTextStream& s, int, int) const override;-
342-
343-
344 QString m_sys;-
345 QString m_pub;-
346};-
347-
348class QDomEntityPrivate : public QDomNodePrivate-
349{-
350public:-
351 QDomEntityPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name,-
352 const QString& pub, const QString& sys, const QString& notation);-
353 QDomEntityPrivate(QDomEntityPrivate* n, bool deep);-
354-
355-
356 QDomNodePrivate* cloneNode(bool deep = true) override;-
357 QDomNode::NodeType nodeType() const override { return QDomNode::EntityNode; }-
358 virtual void save(QTextStream& s, int, int) const override;-
359-
360-
361 QString m_sys;-
362 QString m_pub;-
363 QString m_notationName;-
364};-
365-
366class QDomEntityReferencePrivate : public QDomNodePrivate-
367{-
368public:-
369 QDomEntityReferencePrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& name);-
370 QDomEntityReferencePrivate(QDomNodePrivate* n, bool deep);-
371-
372-
373 QDomNodePrivate* cloneNode(bool deep = true) override;-
374 QDomNode::NodeType nodeType() const override { return QDomNode::EntityReferenceNode; }-
375 virtual void save(QTextStream& s, int, int) const override;-
376};-
377-
378class QDomProcessingInstructionPrivate : public QDomNodePrivate-
379{-
380public:-
381 QDomProcessingInstructionPrivate(QDomDocumentPrivate*, QDomNodePrivate* parent, const QString& target,-
382 const QString& data);-
383 QDomProcessingInstructionPrivate(QDomProcessingInstructionPrivate* n, bool deep);-
384-
385-
386 QDomNodePrivate* cloneNode(bool deep = true) override;-
387 QDomNode::NodeType nodeType() const override { return QDomNode::ProcessingInstructionNode; }-
388 virtual void save(QTextStream& s, int, int) const override;-
389};-
390-
391class QDomDocumentPrivate : public QDomNodePrivate-
392{-
393public:-
394 QDomDocumentPrivate();-
395 QDomDocumentPrivate(const QString& name);-
396 QDomDocumentPrivate(QDomDocumentTypePrivate* dt);-
397 QDomDocumentPrivate(QDomDocumentPrivate* n, bool deep);-
398 ~QDomDocumentPrivate();-
399-
400 bool setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn);-
401 bool setContent(QXmlInputSource *source, QXmlReader *reader, QXmlSimpleReader *simpleReader, QString *errorMsg, int *errorLine, int *errorColumn);-
402-
403-
404 QDomDocumentTypePrivate* doctype() { return type.data(); }-
405 QDomImplementationPrivate* implementation() { return impl.data(); }-
406 QDomElementPrivate* documentElement();-
407-
408-
409 QDomElementPrivate* createElement(const QString& tagName);-
410 QDomElementPrivate* createElementNS(const QString& nsURI, const QString& qName);-
411 QDomDocumentFragmentPrivate* createDocumentFragment();-
412 QDomTextPrivate* createTextNode(const QString& data);-
413 QDomCommentPrivate* createComment(const QString& data);-
414 QDomCDATASectionPrivate* createCDATASection(const QString& data);-
415 QDomProcessingInstructionPrivate* createProcessingInstruction(const QString& target, const QString& data);-
416 QDomAttrPrivate* createAttribute(const QString& name);-
417 QDomAttrPrivate* createAttributeNS(const QString& nsURI, const QString& qName);-
418 QDomEntityReferencePrivate* createEntityReference(const QString& name);-
419-
420 QDomNodePrivate* importNode(QDomNodePrivate* importedNode, bool deep);-
421-
422-
423 QDomNodePrivate* cloneNode(bool deep = true) override;-
424 QDomNode::NodeType nodeType() const override { return QDomNode::DocumentNode; }-
425 void clear() override;-
426-
427-
428 QExplicitlySharedDataPointer<QDomImplementationPrivate> impl;-
429 QExplicitlySharedDataPointer<QDomDocumentTypePrivate> type;-
430-
431 void saveDocument(QTextStream& stream, const int indent, QDomNode::EncodingPolicy encUsed) const;-
432 long nodeListTime;-
433};-
434-
435-
436-
437-
438-
439-
440-
441class QDomHandler : public QXmlDefaultHandler-
442{-
443public:-
444 QDomHandler(QDomDocumentPrivate* d, QXmlSimpleReader *reader, bool namespaceProcessing);-
445 ~QDomHandler();-
446-
447-
448 bool endDocument() override;-
449 bool startElement(const QString& nsURI, const QString& localName, const QString& qName, const QXmlAttributes& atts) override;-
450 bool endElement(const QString& nsURI, const QString& localName, const QString& qName) override;-
451 bool characters(const QString& ch) override;-
452 bool processingInstruction(const QString& target, const QString& data) override;-
453 bool skippedEntity(const QString& name) override;-
454-
455-
456 bool fatalError(const QXmlParseException& exception) override;-
457-
458-
459 bool startCDATA() override;-
460 bool endCDATA() override;-
461 bool startEntity(const QString &) override;-
462 bool endEntity(const QString &) override;-
463 bool startDTD(const QString& name, const QString& publicId, const QString& systemId) override;-
464 bool comment(const QString& ch) override;-
465-
466-
467 bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId) override ;-
468-
469-
470 bool notationDecl(const QString & name, const QString & publicId, const QString & systemId) override;-
471 bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName) override ;-
472-
473 void setDocumentLocator(QXmlLocator *locator) override;-
474-
475 QString errorMsg;-
476 int errorLine;-
477 int errorColumn;-
478-
479private:-
480 QDomDocumentPrivate *doc;-
481 QDomNodePrivate *node;-
482 QString entityName;-
483 bool cdata;-
484 bool nsProcessing;-
485 QXmlLocator *locator;-
486 QXmlSimpleReader *reader;-
487};-
488-
489-
490-
491-
492-
493-
494QDomImplementation::InvalidDataPolicy QDomImplementationPrivate::invalidDataPolicy-
495 = QDomImplementation::AcceptInvalidChars;-
496-
497-
498-
499static QString fixedXmlName(const QString &_name, bool *ok, bool namespaces = false)-
500{-
501 QString name, prefix;-
502 if (namespaces)-
503 qt_split_namespace(prefix, name, _name, true);-
504 else-
505 name = _name;-
506-
507 if (name.isEmpty()) {-
508 *ok = false;-
509 return QString();-
510 }-
511-
512 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {-
513 *ok = true;-
514 return _name;-
515 }-
516-
517 QString result;-
518 bool firstChar = true;-
519 for (int i = 0; i < name.size(); ++i) {-
520 QChar c = name.at(i);-
521 if (firstChar) {-
522 if (QXmlUtils::isLetter(c) || c.unicode() == '_' || c.unicode() == ':') {-
523 result.append(c);-
524 firstChar = false;-
525 } else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {-
526 *ok = false;-
527 return QString();-
528 }-
529 } else {-
530 if (QXmlUtils::isNameChar(c))-
531 result.append(c);-
532 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {-
533 *ok = false;-
534 return QString();-
535 }-
536 }-
537 }-
538-
539 if (result.isEmpty()) {-
540 *ok = false;-
541 return QString();-
542 }-
543-
544 *ok = true;-
545 if (namespaces && !prefix.isEmpty())-
546 return prefix + QLatin1Char(':') + result;-
547 return result;-
548}-
549-
550-
551-
552-
553static QString fixedCharData(const QString &data, bool *ok)-
554{-
555 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {-
556 *ok = true;-
557 return data;-
558 }-
559-
560 QString result;-
561 for (int i = 0; i < data.size(); ++i) {-
562 QChar c = data.at(i);-
563 if (QXmlUtils::isChar(c)) {-
564 result.append(c);-
565 } else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {-
566 *ok = false;-
567 return QString();-
568 }-
569 }-
570-
571 *ok = true;-
572 return result;-
573}-
574-
575-
576-
577-
578static QString fixedComment(const QString &data, bool *ok)-
579{-
580 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {-
581 *ok = true;-
582 return data;-
583 }-
584-
585 QString fixedData = fixedCharData(data, ok);-
586 if (!*ok)-
587 return QString();-
588-
589 for (;;) {-
590 int idx = fixedData.indexOf(QLatin1String("--"));-
591 if (idx == -1)-
592 break;-
593 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {-
594 *ok = false;-
595 return QString();-
596 }-
597 fixedData.remove(idx, 2);-
598 }-
599-
600 *ok = true;-
601 return fixedData;-
602}-
603-
604-
605-
606-
607static QString fixedCDataSection(const QString &data, bool *ok)-
608{-
609 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {-
610 *ok = true;-
611 return data;-
612 }-
613-
614 QString fixedData = fixedCharData(data, ok);-
615 if (!*ok)-
616 return QString();-
617-
618 for (;;) {-
619 int idx = fixedData.indexOf(QLatin1String("]]>"));-
620 if (idx == -1)-
621 break;-
622 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {-
623 *ok = false;-
624 return QString();-
625 }-
626 fixedData.remove(idx, 3);-
627 }-
628-
629 *ok = true;-
630 return fixedData;-
631}-
632-
633-
634-
635static QString fixedPIData(const QString &data, bool *ok)-
636{-
637 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {-
638 *ok = true;-
639 return data;-
640 }-
641-
642 QString fixedData = fixedCharData(data, ok);-
643 if (!*ok)-
644 return QString();-
645-
646 for (;;) {-
647 int idx = fixedData.indexOf(QLatin1String("?>"));-
648 if (idx == -1)-
649 break;-
650 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {-
651 *ok = false;-
652 return QString();-
653 }-
654 fixedData.remove(idx, 2);-
655 }-
656-
657 *ok = true;-
658 return fixedData;-
659}-
660-
661-
662-
663-
664static QString fixedPubidLiteral(const QString &data, bool *ok)-
665{-
666 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {-
667 *ok = true;-
668 return data;-
669 }-
670-
671 QString result;-
672-
673 if(QXmlUtils::isPublicID(data))-
674 result = data;-
675 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {-
676 *ok = false;-
677 return QString();-
678 }-
679-
680 if (result.indexOf(QLatin1Char('\'')) != -1-
681 && result.indexOf(QLatin1Char('"')) != -1) {-
682 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {-
683 *ok = false;-
684 return QString();-
685 } else {-
686 result.remove(QLatin1Char('\''));-
687 }-
688 }-
689-
690 *ok = true;-
691 return result;-
692}-
693-
694-
695-
696-
697static QString fixedSystemLiteral(const QString &data, bool *ok)-
698{-
699 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {-
700 *ok = true;-
701 return data;-
702 }-
703-
704 QString result = data;-
705-
706 if (result.indexOf(QLatin1Char('\'')) != -1-
707 && result.indexOf(QLatin1Char('"')) != -1) {-
708 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {-
709 *ok = false;-
710 return QString();-
711 } else {-
712 result.remove(QLatin1Char('\''));-
713 }-
714 }-
715-
716 *ok = true;-
717 return result;-
718}-
719-
720-
721-
722-
723-
724-
725-
726QDomImplementationPrivate* QDomImplementationPrivate::clone()-
727{-
728 return new QDomImplementationPrivate;-
729}-
730QDomImplementation::QDomImplementation()-
731{-
732 impl = 0;-
733}-
734-
735-
736-
737-
738QDomImplementation::QDomImplementation(const QDomImplementation &x)-
739{-
740 impl = x.impl;-
741 if (impl)-
742 impl->ref.ref();-
743}-
744-
745QDomImplementation::QDomImplementation(QDomImplementationPrivate *p)-
746{-
747-
748 impl = p;-
749 if (impl)-
750 impl->ref.ref();-
751}-
752-
753-
754-
755-
756QDomImplementation& QDomImplementation::operator=(const QDomImplementation &x)-
757{-
758 if (x.impl)-
759 x.impl->ref.ref();-
760 if (impl && !impl->ref.deref())-
761 delete impl;-
762 impl = x.impl;-
763 return *this;-
764}-
765-
766-
767-
768-
769-
770bool QDomImplementation::operator==(const QDomImplementation &x) const-
771{-
772 return (impl == x.impl);-
773}-
774-
775-
776-
777-
778-
779bool QDomImplementation::operator!=(const QDomImplementation &x) const-
780{-
781 return (impl != x.impl);-
782}-
783-
784-
785-
786-
787QDomImplementation::~QDomImplementation()-
788{-
789 if (impl && !impl->ref.deref())-
790 delete impl;-
791}-
792bool QDomImplementation::hasFeature(const QString& feature, const QString& version) const-
793{-
794 if (feature == QLatin1String("XML")) {-
795 if (version.isEmpty() || version == QLatin1String("1.0")) {-
796 return true;-
797 }-
798 }-
799-
800 return false;-
801}-
802QDomDocumentType QDomImplementation::createDocumentType(const QString& qName, const QString& publicId, const QString& systemId)-
803{-
804 bool ok;-
805 QString fixedName = fixedXmlName(qName, &ok, true);-
806 if (!ok)-
807 return QDomDocumentType();-
808-
809 QString fixedPublicId = fixedPubidLiteral(publicId, &ok);-
810 if (!ok)-
811 return QDomDocumentType();-
812-
813 QString fixedSystemId = fixedSystemLiteral(systemId, &ok);-
814 if (!ok)-
815 return QDomDocumentType();-
816-
817 QDomDocumentTypePrivate *dt = new QDomDocumentTypePrivate(0);-
818 dt->name = fixedName;-
819 if (systemId.isNull()) {-
820 dt->publicId.clear();-
821 dt->systemId.clear();-
822 } else {-
823 dt->publicId = fixedPublicId;-
824 dt->systemId = fixedSystemId;-
825 }-
826 dt->ref.deref();-
827 return QDomDocumentType(dt);-
828}-
829-
830-
831-
832-
833-
834-
835QDomDocument QDomImplementation::createDocument(const QString& nsURI, const QString& qName, const QDomDocumentType& doctype)-
836{-
837 QDomDocument doc(doctype);-
838 QDomElement root = doc.createElementNS(nsURI, qName);-
839 if (root.isNull())-
840 return QDomDocument();-
841 doc.appendChild(root);-
842 return doc;-
843}-
844-
845-
846-
847-
848-
849bool QDomImplementation::isNull()-
850{-
851 return (impl == 0);-
852}-
853QDomImplementation::InvalidDataPolicy QDomImplementation::invalidDataPolicy()-
854{-
855 return QDomImplementationPrivate::invalidDataPolicy;-
856}-
857void QDomImplementation::setInvalidDataPolicy(InvalidDataPolicy policy)-
858{-
859 QDomImplementationPrivate::invalidDataPolicy = policy;-
860}-
861-
862-
863-
864-
865-
866-
867-
868QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl) : ref(1)-
869{-
870 node_impl = n_impl;-
871 if (node_impl)-
872 node_impl->ref.ref();-
873 timestamp = 0;-
874}-
875-
876QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &name) :-
877 ref(1)-
878{-
879 node_impl = n_impl;-
880 if (node_impl)-
881 node_impl->ref.ref();-
882 tagname = name;-
883 timestamp = 0;-
884}-
885-
886QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &_nsURI, const QString &localName) :-
887 ref(1)-
888{-
889 node_impl = n_impl;-
890 if (node_impl)-
891 node_impl->ref.ref();-
892 tagname = localName;-
893 nsURI = _nsURI;-
894 timestamp = 0;-
895}-
896-
897QDomNodeListPrivate::~QDomNodeListPrivate()-
898{-
899 if (node_impl && !node_impl->ref.deref())-
900 delete node_impl;-
901}-
902-
903bool QDomNodeListPrivate::operator==(const QDomNodeListPrivate &other) const-
904{-
905 return (node_impl == other.node_impl) && (tagname == other.tagname);-
906}-
907-
908bool QDomNodeListPrivate::operator!=(const QDomNodeListPrivate &other) const-
909{-
910 return (node_impl != other.node_impl) || (tagname != other.tagname);-
911}-
912-
913void QDomNodeListPrivate::createList()-
914{-
915 if (!node_impl)-
916 return;-
917-
918 const QDomDocumentPrivate *const doc = node_impl->ownerDocument();-
919 if (doc && timestamp != doc->nodeListTime)-
920 timestamp = doc->nodeListTime;-
921-
922 QDomNodePrivate* p = node_impl->first;-
923-
924 list.clear();-
925 if (tagname.isNull()) {-
926 while (p) {-
927 list.append(p);-
928 p = p->next;-
929 }-
930 } else if (nsURI.isNull()) {-
931 while (p && p != node_impl) {-
932 if (p->isElement() && p->nodeName() == tagname) {-
933 list.append(p);-
934 }-
935 if (p->first)-
936 p = p->first;-
937 else if (p->next)-
938 p = p->next;-
939 else {-
940 p = p->parent();-
941 while (p && p != node_impl && !p->next)-
942 p = p->parent();-
943 if (p && p != node_impl)-
944 p = p->next;-
945 }-
946 }-
947 } else {-
948 while (p && p != node_impl) {-
949 if (p->isElement() && p->name==tagname && p->namespaceURI==nsURI) {-
950 list.append(p);-
951 }-
952 if (p->first)-
953 p = p->first;-
954 else if (p->next)-
955 p = p->next;-
956 else {-
957 p = p->parent();-
958 while (p && p != node_impl && !p->next)-
959 p = p->parent();-
960 if (p && p != node_impl)-
961 p = p->next;-
962 }-
963 }-
964 }-
965}-
966-
967QDomNodePrivate* QDomNodeListPrivate::item(int index)-
968{-
969 if (!node_impl)-
970 return 0;-
971-
972 const QDomDocumentPrivate *const doc = node_impl->ownerDocument();-
973 if (!doc || timestamp != doc->nodeListTime)-
974 createList();-
975-
976 if (index >= list.size())-
977 return 0;-
978-
979 return list.at(index);-
980}-
981-
982int QDomNodeListPrivate::length() const-
983{-
984 if (!node_impl)-
985 return 0;-
986-
987 const QDomDocumentPrivate *const doc = node_impl->ownerDocument();-
988 if (!doc || timestamp != doc->nodeListTime) {-
989 QDomNodeListPrivate *that = const_cast<QDomNodeListPrivate *>(this);-
990 that->createList();-
991 }-
992-
993 return list.count();-
994}-
995QDomNodeList::QDomNodeList()-
996{-
997 impl = 0;-
998}-
999-
1000QDomNodeList::QDomNodeList(QDomNodeListPrivate* p)-
1001{-
1002 impl = p;-
1003}-
1004-
1005-
1006-
1007-
1008QDomNodeList::QDomNodeList(const QDomNodeList& n)-
1009{-
1010 impl = n.impl;-
1011 if (impl)-
1012 impl->ref.ref();-
1013}-
1014-
1015-
1016-
1017-
1018QDomNodeList& QDomNodeList::operator=(const QDomNodeList &n)-
1019{-
1020 if (n.impl)-
1021 n.impl->ref.ref();-
1022 if (impl && !impl->ref.deref())-
1023 delete impl;-
1024 impl = n.impl;-
1025 return *this;-
1026}-
1027-
1028-
1029-
1030-
1031-
1032bool QDomNodeList::operator==(const QDomNodeList &n) const-
1033{-
1034 if (impl == n.impl)-
1035 return true;-
1036 if (!impl || !n.impl)-
1037 return false;-
1038 return (*impl == *n.impl);-
1039}-
1040-
1041-
1042-
1043-
1044-
1045bool QDomNodeList::operator!=(const QDomNodeList &n) const-
1046{-
1047 return !operator==(n);-
1048}-
1049-
1050-
1051-
1052-
1053QDomNodeList::~QDomNodeList()-
1054{-
1055 if (impl && !impl->ref.deref())-
1056 delete impl;-
1057}-
1058QDomNode QDomNodeList::item(int index) const-
1059{-
1060 if (!impl)-
1061 return QDomNode();-
1062-
1063 return QDomNode(impl->item(index));-
1064}-
1065-
1066-
1067-
1068-
1069int QDomNodeList::length() const-
1070{-
1071 if (!impl)-
1072 return 0;-
1073 return impl->length();-
1074}-
1075inline void QDomNodePrivate::setOwnerDocument(QDomDocumentPrivate *doc)-
1076{-
1077 ownerNode = doc;-
1078 hasParent = false;-
1079}-
1080-
1081QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) : ref(1)-
1082{-
1083 if (par)-
1084 setParent(par);-
1085 else-
1086 setOwnerDocument(doc);-
1087 prev = 0;-
1088 next = 0;-
1089 first = 0;-
1090 last = 0;-
1091 createdWithDom1Interface = true;-
1092 lineNumber = -1;-
1093 columnNumber = -1;-
1094}-
1095-
1096QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n, bool deep) : ref(1)-
1097{-
1098 setOwnerDocument(n->ownerDocument());-
1099 prev = 0;-
1100 next = 0;-
1101 first = 0;-
1102 last = 0;-
1103-
1104 name = n->name;-
1105 value = n->value;-
1106 prefix = n->prefix;-
1107 namespaceURI = n->namespaceURI;-
1108 createdWithDom1Interface = n->createdWithDom1Interface;-
1109 lineNumber = -1;-
1110 columnNumber = -1;-
1111-
1112 if (!deep)-
1113 return;-
1114-
1115 for (QDomNodePrivate* x = n->first; x; x = x->next)-
1116 appendChild(x->cloneNode(true));-
1117}-
1118-
1119QDomNodePrivate::~QDomNodePrivate()-
1120{-
1121 QDomNodePrivate* p = first;-
1122 QDomNodePrivate* n;-
1123-
1124 while (p) {-
1125 n = p->next;-
1126 if (!p->ref.deref())-
1127 delete p;-
1128 else-
1129 p->setNoParent();-
1130 p = n;-
1131 }-
1132 first = 0;-
1133 last = 0;-
1134}-
1135-
1136void QDomNodePrivate::clear()-
1137{-
1138 QDomNodePrivate* p = first;-
1139 QDomNodePrivate* n;-
1140-
1141 while (p) {-
1142 n = p->next;-
1143 if (!p->ref.deref())-
1144 delete p;-
1145 p = n;-
1146 }-
1147 first = 0;-
1148 last = 0;-
1149}-
1150-
1151QDomNodePrivate* QDomNodePrivate::namedItem(const QString &n)-
1152{-
1153 QDomNodePrivate* p = first;-
1154 while (p) {-
1155 if (p->nodeName() == n)-
1156 return p;-
1157 p = p->next;-
1158 }-
1159 return 0;-
1160}-
1161-
1162-
1163QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild)-
1164{-
1165-
1166 if (!newChild)-
1167 return 0;-
1168-
1169-
1170 if (newChild == refChild)-
1171 return 0;-
1172-
1173-
1174 if (refChild && refChild->parent() != this)-
1175 return 0;-
1176-
1177-
1178 QDomDocumentPrivate *const doc = ownerDocument();-
1179 if(doc)-
1180 doc->nodeListTime++;-
1181-
1182-
1183-
1184 if (newChild->isDocumentFragment()) {-
1185-
1186 if (newChild->first == 0)-
1187 return newChild;-
1188-
1189-
1190 QDomNodePrivate* n = newChild->first;-
1191 while (n) {-
1192 n->setParent(this);-
1193 n = n->next;-
1194 }-
1195-
1196-
1197 if (!refChild || refChild->prev == 0) {-
1198 if (first)-
1199 first->prev = newChild->last;-
1200 newChild->last->next = first;-
1201 if (!last)-
1202 last = newChild->last;-
1203 first = newChild->first;-
1204 } else {-
1205-
1206 newChild->last->next = refChild;-
1207 newChild->first->prev = refChild->prev;-
1208 refChild->prev->next = newChild->first;-
1209 refChild->prev = newChild->last;-
1210 }-
1211-
1212-
1213-
1214-
1215-
1216 newChild->first = 0;-
1217 newChild->last = 0;-
1218 return newChild;-
1219 }-
1220-
1221-
1222-
1223 newChild->ref.ref();-
1224-
1225 if (newChild->parent())-
1226 newChild->parent()->removeChild(newChild);-
1227-
1228 newChild->setParent(this);-
1229-
1230 if (!refChild) {-
1231 if (first)-
1232 first->prev = newChild;-
1233 newChild->next = first;-
1234 if (!last)-
1235 last = newChild;-
1236 first = newChild;-
1237 return newChild;-
1238 }-
1239-
1240 if (refChild->prev == 0) {-
1241 if (first)-
1242 first->prev = newChild;-
1243 newChild->next = first;-
1244 if (!last)-
1245 last = newChild;-
1246 first = newChild;-
1247 return newChild;-
1248 }-
1249-
1250 newChild->next = refChild;-
1251 newChild->prev = refChild->prev;-
1252 refChild->prev->next = newChild;-
1253 refChild->prev = newChild;-
1254-
1255 return newChild;-
1256}-
1257-
1258QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild)-
1259{-
1260-
1261 if (!newChild)-
1262 return 0;-
1263-
1264-
1265 if (newChild == refChild)-
1266 return 0;-
1267-
1268-
1269 if (refChild && refChild->parent() != this)-
1270 return 0;-
1271-
1272-
1273 QDomDocumentPrivate *const doc = ownerDocument();-
1274 if(doc)-
1275 doc->nodeListTime++;-
1276-
1277-
1278-
1279 if (newChild->isDocumentFragment()) {-
1280-
1281 if (newChild->first == 0)-
1282 return newChild;-
1283-
1284-
1285 QDomNodePrivate* n = newChild->first;-
1286 while (n) {-
1287 n->setParent(this);-
1288 n = n->next;-
1289 }-
1290-
1291-
1292 if (!refChild || refChild->next == 0) {-
1293 if (last)-
1294 last->next = newChild->first;-
1295 newChild->first->prev = last;-
1296 if (!first)-
1297 first = newChild->first;-
1298 last = newChild->last;-
1299 } else {-
1300 newChild->first->prev = refChild;-
1301 newChild->last->next = refChild->next;-
1302 refChild->next->prev = newChild->last;-
1303 refChild->next = newChild->first;-
1304 }-
1305-
1306-
1307-
1308-
1309-
1310 newChild->first = 0;-
1311 newChild->last = 0;-
1312 return newChild;-
1313 }-
1314-
1315-
1316 if (newChild->parent())-
1317 newChild->parent()->removeChild(newChild);-
1318-
1319-
1320-
1321 newChild->ref.ref();-
1322-
1323 newChild->setParent(this);-
1324-
1325-
1326 if (!refChild) {-
1327 if (last)-
1328 last->next = newChild;-
1329 newChild->prev = last;-
1330 if (!first)-
1331 first = newChild;-
1332 last = newChild;-
1333 return newChild;-
1334 }-
1335-
1336 if (refChild->next == 0) {-
1337 if (last)-
1338 last->next = newChild;-
1339 newChild->prev = last;-
1340 if (!first)-
1341 first = newChild;-
1342 last = newChild;-
1343 return newChild;-
1344 }-
1345-
1346 newChild->prev = refChild;-
1347 newChild->next = refChild->next;-
1348 refChild->next->prev = newChild;-
1349 refChild->next = newChild;-
1350-
1351 return newChild;-
1352}-
1353-
1354QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild)-
1355{-
1356 if (!newChild || !oldChild)-
1357 return 0;-
1358 if (oldChild->parent() != this)-
1359 return 0;-
1360 if (newChild == oldChild)-
1361 return 0;-
1362-
1363-
1364 QDomDocumentPrivate *const doc = ownerDocument();-
1365 if(doc)-
1366 doc->nodeListTime++;-
1367-
1368-
1369-
1370 if (newChild->isDocumentFragment()) {-
1371-
1372 if (newChild->first == 0)-
1373 return newChild;-
1374-
1375-
1376 QDomNodePrivate* n = newChild->first;-
1377 while (n) {-
1378 n->setParent(this);-
1379 n = n->next;-
1380 }-
1381-
1382-
1383 if (oldChild->next)-
1384 oldChild->next->prev = newChild->last;-
1385 if (oldChild->prev)-
1386 oldChild->prev->next = newChild->first;-
1387-
1388 newChild->last->next = oldChild->next;-
1389 newChild->first->prev = oldChild->prev;-
1390-
1391 if (first == oldChild)-
1392 first = newChild->first;-
1393 if (last == oldChild)-
1394 last = newChild->last;-
1395-
1396 oldChild->setNoParent();-
1397 oldChild->next = 0;-
1398 oldChild->prev = 0;-
1399-
1400-
1401-
1402-
1403-
1404 newChild->first = 0;-
1405 newChild->last = 0;-
1406-
1407-
1408 if (oldChild)-
1409 oldChild->ref.deref();-
1410-
1411 return oldChild;-
1412 }-
1413-
1414-
1415-
1416 newChild->ref.ref();-
1417-
1418-
1419 if (newChild->parent())-
1420 newChild->parent()->removeChild(newChild);-
1421-
1422 newChild->setParent(this);-
1423-
1424 if (oldChild->next)-
1425 oldChild->next->prev = newChild;-
1426 if (oldChild->prev)-
1427 oldChild->prev->next = newChild;-
1428-
1429 newChild->next = oldChild->next;-
1430 newChild->prev = oldChild->prev;-
1431-
1432 if (first == oldChild)-
1433 first = newChild;-
1434 if (last == oldChild)-
1435 last = newChild;-
1436-
1437 oldChild->setNoParent();-
1438 oldChild->next = 0;-
1439 oldChild->prev = 0;-
1440-
1441-
1442 if (oldChild)-
1443 oldChild->ref.deref();-
1444-
1445 return oldChild;-
1446}-
1447-
1448QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild)-
1449{-
1450-
1451 if (oldChild->parent() != this)-
1452 return 0;-
1453-
1454-
1455 QDomDocumentPrivate *const doc = ownerDocument();-
1456 if(doc)-
1457 doc->nodeListTime++;-
1458-
1459-
1460-
1461 if (oldChild->next == 0 && oldChild->prev == 0 && first != oldChild)-
1462 return 0;-
1463-
1464 if (oldChild->next)-
1465 oldChild->next->prev = oldChild->prev;-
1466 if (oldChild->prev)-
1467 oldChild->prev->next = oldChild->next;-
1468-
1469 if (last == oldChild)-
1470 last = oldChild->prev;-
1471 if (first == oldChild)-
1472 first = oldChild->next;-
1473-
1474 oldChild->setNoParent();-
1475 oldChild->next = 0;-
1476 oldChild->prev = 0;-
1477-
1478-
1479 oldChild->ref.deref();-
1480-
1481 return oldChild;-
1482}-
1483-
1484QDomNodePrivate* QDomNodePrivate::appendChild(QDomNodePrivate* newChild)-
1485{-
1486-
1487 return insertAfter(newChild, 0);-
1488}-
1489-
1490QDomDocumentPrivate* QDomNodePrivate::ownerDocument()-
1491{-
1492 QDomNodePrivate* p = this;-
1493 while (p && !p->isDocument()) {-
1494 if (!p->hasParent)-
1495 return (QDomDocumentPrivate*)p->ownerNode;-
1496 p = p->parent();-
1497 }-
1498-
1499 return static_cast<QDomDocumentPrivate *>(p);-
1500}-
1501-
1502QDomNodePrivate* QDomNodePrivate::cloneNode(bool deep)-
1503{-
1504 QDomNodePrivate* p = new QDomNodePrivate(this, deep);-
1505-
1506 p->ref.deref();-
1507 return p;-
1508}-
1509-
1510static void qNormalizeNode(QDomNodePrivate* n)-
1511{-
1512 QDomNodePrivate* p = n->first;-
1513 QDomTextPrivate* t = 0;-
1514-
1515 while (p) {-
1516 if (p->isText()) {-
1517 if (t) {-
1518 QDomNodePrivate* tmp = p->next;-
1519 t->appendData(p->nodeValue());-
1520 n->removeChild(p);-
1521 p = tmp;-
1522 } else {-
1523 t = (QDomTextPrivate*)p;-
1524 p = p->next;-
1525 }-
1526 } else {-
1527 p = p->next;-
1528 t = 0;-
1529 }-
1530 }-
1531}-
1532void QDomNodePrivate::normalize()-
1533{-
1534-
1535-
1536 qNormalizeNode(this);-
1537}-
1538-
1539-
1540-
1541-
1542void QDomNodePrivate::save(QTextStream& s, int depth, int indent) const-
1543{-
1544 const QDomNodePrivate* n = first;-
1545 while (n) {-
1546 n->save(s, depth, indent);-
1547 n = n->next;-
1548 }-
1549}-
1550-
1551void QDomNodePrivate::setLocation(int lineNumber, int columnNumber)-
1552{-
1553 this->lineNumber = lineNumber;-
1554 this->columnNumber = columnNumber;-
1555}-
1556QDomNode::QDomNode()-
1557{-
1558 impl = 0;-
1559}-
1560QDomNode::QDomNode(const QDomNode &n)-
1561{-
1562 impl = n.impl;-
1563 if (impl)-
1564 impl->ref.ref();-
1565}-
1566-
1567-
1568-
1569-
1570QDomNode::QDomNode(QDomNodePrivate *n)-
1571{-
1572 impl = n;-
1573 if (impl)-
1574 impl->ref.ref();-
1575}-
1576QDomNode& QDomNode::operator=(const QDomNode &n)-
1577{-
1578 if (n.impl)-
1579 n.impl->ref.ref();-
1580 if (impl && !impl->ref.deref())-
1581 delete impl;-
1582 impl = n.impl;-
1583 return *this;-
1584}-
1585bool QDomNode::operator== (const QDomNode& n) const-
1586{-
1587 return (impl == n.impl);-
1588}-
1589-
1590-
1591-
1592-
1593-
1594bool QDomNode::operator!= (const QDomNode& n) const-
1595{-
1596 return (impl != n.impl);-
1597}-
1598-
1599-
1600-
1601-
1602QDomNode::~QDomNode()-
1603{-
1604 if (impl && !impl->ref.deref())-
1605 delete impl;-
1606}-
1607QString QDomNode::nodeName() const-
1608{-
1609 if (!impl)-
1610 return QString();-
1611-
1612 if (!((QDomNodePrivate*)impl)->prefix.isEmpty())-
1613 return ((QDomNodePrivate*)impl)->prefix + QLatin1Char(':') + ((QDomNodePrivate*)impl)->name;-
1614 return ((QDomNodePrivate*)impl)->name;-
1615}-
1616QString QDomNode::nodeValue() const-
1617{-
1618 if (!impl)-
1619 return QString();-
1620 return ((QDomNodePrivate*)impl)->value;-
1621}-
1622-
1623-
1624-
1625-
1626-
1627-
1628void QDomNode::setNodeValue(const QString& v)-
1629{-
1630 if (!impl)-
1631 return;-
1632 ((QDomNodePrivate*)impl)->setNodeValue(v);-
1633}-
1634QDomNode::NodeType QDomNode::nodeType() const-
1635{-
1636 if (!impl)-
1637 return QDomNode::BaseNode;-
1638 return ((QDomNodePrivate*)impl)->nodeType();-
1639}-
1640-
1641-
1642-
1643-
1644-
1645QDomNode QDomNode::parentNode() const-
1646{-
1647 if (!impl)-
1648 return QDomNode();-
1649 return QDomNode(((QDomNodePrivate*)impl)->parent());-
1650}-
1651QDomNodeList QDomNode::childNodes() const-
1652{-
1653 if (!impl)-
1654 return QDomNodeList();-
1655 return QDomNodeList(new QDomNodeListPrivate(impl));-
1656}-
1657QDomNode QDomNode::firstChild() const-
1658{-
1659 if (!impl)-
1660 return QDomNode();-
1661 return QDomNode(((QDomNodePrivate*)impl)->first);-
1662}-
1663QDomNode QDomNode::lastChild() const-
1664{-
1665 if (!impl)-
1666 return QDomNode();-
1667 return QDomNode(((QDomNodePrivate*)impl)->last);-
1668}-
1669QDomNode QDomNode::previousSibling() const-
1670{-
1671 if (!impl)-
1672 return QDomNode();-
1673 return QDomNode(((QDomNodePrivate*)impl)->prev);-
1674}-
1675QDomNode QDomNode::nextSibling() const-
1676{-
1677 if (!impl)-
1678 return QDomNode();-
1679 return QDomNode(((QDomNodePrivate*)impl)->next);-
1680}-
1681QDomNamedNodeMap QDomNode::attributes() const-
1682{-
1683 if (!impl || !impl->isElement())-
1684 return QDomNamedNodeMap();-
1685-
1686 return QDomNamedNodeMap(static_cast<QDomElementPrivate *>(impl)->attributes());-
1687}-
1688-
1689-
1690-
1691-
1692QDomDocument QDomNode::ownerDocument() const-
1693{-
1694 if (!impl)-
1695 return QDomDocument();-
1696 return QDomDocument(((QDomNodePrivate*)impl)->ownerDocument());-
1697}-
1698QDomNode QDomNode::cloneNode(bool deep) const-
1699{-
1700 if (!impl)-
1701 return QDomNode();-
1702 return QDomNode(((QDomNodePrivate*)impl)->cloneNode(deep));-
1703}-
1704-
1705-
1706-
1707-
1708-
1709-
1710-
1711void QDomNode::normalize()-
1712{-
1713 if (!impl)-
1714 return;-
1715 ((QDomNodePrivate*)impl)->normalize();-
1716}-
1717bool QDomNode::isSupported(const QString& feature, const QString& version) const-
1718{-
1719 QDomImplementation i;-
1720 return i.hasFeature(feature, version);-
1721}-
1722QString QDomNode::namespaceURI() const-
1723{-
1724 if (!impl)-
1725 return QString();-
1726 return ((QDomNodePrivate*)impl)->namespaceURI;-
1727}-
1728QString QDomNode::prefix() const-
1729{-
1730 if (!impl)-
1731 return QString();-
1732 return ((QDomNodePrivate*)impl)->prefix;-
1733}-
1734void QDomNode::setPrefix(const QString& pre)-
1735{-
1736 if (!impl || ((QDomNodePrivate*)impl)->prefix.isNull())-
1737 return;-
1738 if (isAttr() || isElement())-
1739 ((QDomNodePrivate*)impl)->prefix = pre;-
1740}-
1741QString QDomNode::localName() const-
1742{-
1743 if (!impl || ((QDomNodePrivate*)impl)->createdWithDom1Interface)-
1744 return QString();-
1745 return ((QDomNodePrivate*)impl)->name;-
1746}-
1747-
1748-
1749-
1750-
1751-
1752-
1753bool QDomNode::hasAttributes() const-
1754{-
1755 if (!impl || !impl->isElement())-
1756 return false;-
1757 return static_cast<QDomElementPrivate *>(impl)->hasAttributes();-
1758}-
1759QDomNode QDomNode::insertBefore(const QDomNode& newChild, const QDomNode& refChild)-
1760{-
1761 if (!impl)-
1762 return QDomNode();-
1763 return QDomNode(((QDomNodePrivate*)impl)->insertBefore(newChild.impl, refChild.impl));-
1764}-
1765QDomNode QDomNode::insertAfter(const QDomNode& newChild, const QDomNode& refChild)-
1766{-
1767 if (!impl)-
1768 return QDomNode();-
1769 return QDomNode(((QDomNodePrivate*)impl)->insertAfter(newChild.impl, refChild.impl));-
1770}-
1771QDomNode QDomNode::replaceChild(const QDomNode& newChild, const QDomNode& oldChild)-
1772{-
1773 if (!impl || !newChild.impl || !oldChild.impl)-
1774 return QDomNode();-
1775 return QDomNode(((QDomNodePrivate*)impl)->replaceChild(newChild.impl, oldChild.impl));-
1776}-
1777QDomNode QDomNode::removeChild(const QDomNode& oldChild)-
1778{-
1779 if (!impl)-
1780 return QDomNode();-
1781-
1782 if (oldChild.isNull())-
1783 return QDomNode();-
1784-
1785 return QDomNode(((QDomNodePrivate*)impl)->removeChild(oldChild.impl));-
1786}-
1787QDomNode QDomNode::appendChild(const QDomNode& newChild)-
1788{-
1789 if (!impl) {-
1790 QMessageLogger(__FILE__, 25982604, __PRETTY_FUNCTION__).warning("Calling appendChild() on a null node does nothing.");-
1791 return QDomNode();-
1792 }-
1793 return QDomNode(((QDomNodePrivate*)impl)->appendChild(newChild.impl));-
1794}-
1795-
1796-
1797-
1798-
1799-
1800bool QDomNode::hasChildNodes() const-
1801{-
1802 if (!impl)-
1803 return false;-
1804 return ((QDomNodePrivate*)impl)->first != 0;-
1805}-
1806-
1807-
1808-
1809-
1810-
1811bool QDomNode::isNull() const-
1812{-
1813 return (impl == 0);-
1814}-
1815-
1816-
1817-
1818-
1819-
1820-
1821-
1822void QDomNode::clear()-
1823{-
1824 if (impl && !impl->ref.deref())-
1825 delete impl;-
1826 impl = 0;-
1827}-
1828QDomNode QDomNode::namedItem(const QString& name) const-
1829{-
1830 if (!impl)-
1831 return QDomNode();-
1832 return QDomNode(impl->namedItem(name));-
1833}-
1834void QDomNode::save(QTextStream& stream, int indent, EncodingPolicy encodingPolicy) const-
1835{-
1836 if (!impl)-
1837 return;-
1838-
1839 if(isDocument())-
1840 static_cast<const QDomDocumentPrivate *>(impl)->saveDocument(stream, indent, encodingPolicy);-
1841 else-
1842 ((QDomNodePrivate*)impl)->save(stream, 1, indent);-
1843}-
1844-
1845-
1846-
1847-
1848-
1849-
1850-
1851QTextStream& operator<<(QTextStream& str, const QDomNode& node)-
1852{-
1853 node.save(str, 1);-
1854-
1855 return str;-
1856}-
1857bool QDomNode::isAttr() const-
1858{-
1859 if(impl)-
1860 return impl->isAttr();-
1861 return false;-
1862}-
1863bool QDomNode::isCDATASection() const-
1864{-
1865 if(impl)-
1866 return impl->isCDATASection();-
1867 return false;-
1868}-
1869bool QDomNode::isDocumentFragment() const-
1870{-
1871 if(impl)-
1872 return impl->isDocumentFragment();-
1873 return false;-
1874}-
1875bool QDomNode::isDocument() const-
1876{-
1877 if(impl)-
1878 return impl->isDocument();-
1879 return false;-
1880}-
1881bool QDomNode::isDocumentType() const-
1882{-
1883 if(impl)-
1884 return impl->isDocumentType();-
1885 return false;-
1886}-
1887bool QDomNode::isElement() const-
1888{-
1889 if(impl)-
1890 return impl->isElement();-
1891 return false;-
1892}-
1893bool QDomNode::isEntityReference() const-
1894{-
1895 if(impl)-
1896 return impl->isEntityReference();-
1897 return false;-
1898}-
1899bool QDomNode::isText() const-
1900{-
1901 if(impl)-
1902 return impl->isText();-
1903 return false;-
1904}-
1905bool QDomNode::isEntity() const-
1906{-
1907 if(impl)-
1908 return impl->isEntity();-
1909 return false;-
1910}-
1911bool QDomNode::isNotation() const-
1912{-
1913 if(impl)-
1914 return impl->isNotation();-
1915 return false;-
1916}-
1917bool QDomNode::isProcessingInstruction() const-
1918{-
1919 if(impl)-
1920 return impl->isProcessingInstruction();-
1921 return false;-
1922}-
1923bool QDomNode::isCharacterData() const-
1924{-
1925 if (impl)-
1926 return impl->isCharacterData();-
1927 return false;-
1928}-
1929bool QDomNode::isComment() const-
1930{-
1931 if (impl)-
1932 return impl->isComment();-
1933 return false;-
1934}-
1935QDomElement QDomNode::firstChildElement(const QString &tagName) const-
1936{-
1937 for (QDomNode child = firstChild(); !child.isNull(); child = child.nextSibling()) {-
1938 if (child.isElement()) {-
1939 QDomElement elt = child.toElement();-
1940 if (tagName.isEmpty() || elt.tagName() == tagName)-
1941 return elt;-
1942 }-
1943 }-
1944 return QDomElement();-
1945}-
1946QDomElement QDomNode::lastChildElement(const QString &tagName) const-
1947{-
1948 for (QDomNode child = lastChild(); !child.isNull(); child = child.previousSibling()) {-
1949 if (child.isElement()) {-
1950 QDomElement elt = child.toElement();-
1951 if (tagName.isEmpty() || elt.tagName() == tagName)-
1952 return elt;-
1953 }-
1954 }-
1955 return QDomElement();-
1956}-
1957QDomElement QDomNode::nextSiblingElement(const QString &tagName) const-
1958{-
1959 for (QDomNode sib = nextSibling(); !sib.isNull(); sib = sib.nextSibling()) {-
1960 if (sib.isElement()) {-
1961 QDomElement elt = sib.toElement();-
1962 if (tagName.isEmpty() || elt.tagName() == tagName)-
1963 return elt;-
1964 }-
1965 }-
1966 return QDomElement();-
1967}-
1968QDomElement QDomNode::previousSiblingElement(const QString &tagName) const-
1969{-
1970 for (QDomNode sib = previousSibling(); !sib.isNull(); sib = sib.previousSibling()) {-
1971 if (sib.isElement()) {-
1972 QDomElement elt = sib.toElement();-
1973 if (tagName.isEmpty() || elt.tagName() == tagName)-
1974 return elt;-
1975 }-
1976 }-
1977 return QDomElement();-
1978}-
1979int QDomNode::lineNumber() const-
1980{-
1981 return impl ? impl->lineNumber : -1;-
1982}-
1983int QDomNode::columnNumber() const-
1984{-
1985 return impl ? impl->columnNumber : -1;-
1986}-
1987QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate(QDomNodePrivate* n) : ref(1)-
1988{-
1989 readonly = false;-
1990 parent = n;-
1991 appendToParent = false;-
1992}-
1993-
1994QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate()-
1995{-
1996 clearMap();-
1997}-
1998-
1999QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate* p)-
2000{-
2001 QScopedPointer<QDomNamedNodeMapPrivate> m(new QDomNamedNodeMapPrivate(p));-
2002 m->readonly = readonly;-
2003 m->appendToParent = appendToParent;-
2004-
2005 QHash<QString, QDomNodePrivate*>::const_iterator it = map.constBegin();-
2006 for (; it != map.constEnd(); ++it) {-
2007 QDomNodePrivate *new_node = (*it)->cloneNode();-
2008 new_node->setParent(p);-
2009 m->setNamedItem(new_node);-
2010 }-
2011-
2012-
2013 m->ref.deref();-
2014 return m.take();-
2015}-
2016-
2017void QDomNamedNodeMapPrivate::clearMap()-
2018{-
2019-
2020 if (!appendToParent) {-
2021 QHash<QString, QDomNodePrivate *>::const_iterator it = map.constBegin();-
2022 for (; it != map.constEnd(); ++it)-
2023 if (!(*it)->ref.deref())-
2024 delete *it;-
2025 }-
2026 map.clear();-
2027}-
2028-
2029QDomNodePrivate* QDomNamedNodeMapPrivate::namedItem(const QString& name) const-
2030{-
2031 QDomNodePrivate* p = map[name];-
2032 return p;-
2033}-
2034-
2035QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(const QString& nsURI, const QString& localName) const-
2036{-
2037 QHash<QString, QDomNodePrivate *>::const_iterator it = map.constBegin();-
2038 QDomNodePrivate *n;-
2039 for (; it != map.constEnd(); ++it) {-
2040 n = *it;-
2041 if (!n->prefix.isNull()) {-
2042-
2043 if (n->namespaceURI == nsURI && n->name == localName)-
2044 return n;-
2045 }-
2046 }-
2047 return 0;-
2048}-
2049-
2050QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg)-
2051{-
2052 if (readonly || !arg)-
2053 return 0;-
2054-
2055 if (appendToParent)-
2056 return parent->appendChild(arg);-
2057-
2058 QDomNodePrivate *n = map.value(arg->nodeName());-
2059-
2060 arg->ref.ref();-
2061 map.insertMulti(arg->nodeName(), arg);-
2062 return n;-
2063}-
2064-
2065QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg)-
2066{-
2067 if (readonly || !arg)-
2068 return 0;-
2069-
2070 if (appendToParent)-
2071 return parent->appendChild(arg);-
2072-
2073 if (!arg->prefix.isNull()) {-
2074-
2075 QDomNodePrivate *n = namedItemNS(arg->namespaceURI, arg->name);-
2076-
2077 arg->ref.ref();-
2078 map.insertMulti(arg->nodeName(), arg);-
2079 return n;-
2080 } else {-
2081-
2082 return setNamedItem(arg);-
2083 }-
2084}-
2085-
2086QDomNodePrivate* QDomNamedNodeMapPrivate::removeNamedItem(const QString& name)-
2087{-
2088 if (readonly)-
2089 return 0;-
2090-
2091 QDomNodePrivate* p = namedItem(name);-
2092 if (p == 0)-
2093 return 0;-
2094 if (appendToParent)-
2095 return parent->removeChild(p);-
2096-
2097 map.remove(p->nodeName());-
2098-
2099 p->ref.deref();-
2100 return p;-
2101}-
2102-
2103QDomNodePrivate* QDomNamedNodeMapPrivate::item(int index) const-
2104{-
2105 if (index >= length() || index < 0)-
2106 return 0;-
2107 return *(map.constBegin() + index);-
2108}-
2109-
2110int QDomNamedNodeMapPrivate::length() const-
2111{-
2112 return map.count();-
2113}-
2114-
2115bool QDomNamedNodeMapPrivate::contains(const QString& name) const-
2116{-
2117 return map.value(name) != 0;-
2118}-
2119-
2120bool QDomNamedNodeMapPrivate::containsNS(const QString& nsURI, const QString & localName) const-
2121{-
2122 return namedItemNS(nsURI, localName) != 0;-
2123}-
2124QDomNamedNodeMap::QDomNamedNodeMap()-
2125{-
2126 impl = 0;-
2127}-
2128-
2129-
2130-
2131-
2132QDomNamedNodeMap::QDomNamedNodeMap(const QDomNamedNodeMap &n)-
2133{-
2134 impl = n.impl;-
2135 if (impl)-
2136 impl->ref.ref();-
2137}-
2138-
2139QDomNamedNodeMap::QDomNamedNodeMap(QDomNamedNodeMapPrivate *n)-
2140{-
2141 impl = n;-
2142 if (impl)-
2143 impl->ref.ref();-
2144}-
2145-
2146-
2147-
2148-
2149QDomNamedNodeMap& QDomNamedNodeMap::operator=(const QDomNamedNodeMap &n)-
2150{-
2151 if (n.impl)-
2152 n.impl->ref.ref();-
2153 if (impl && !impl->ref.deref())-
2154 delete impl;-
2155 impl = n.impl;-
2156 return *this;-
2157}-
2158-
2159-
2160-
2161-
2162-
2163bool QDomNamedNodeMap::operator== (const QDomNamedNodeMap& n) const-
2164{-
2165 return (impl == n.impl);-
2166}-
2167-
2168-
2169-
2170-
2171-
2172bool QDomNamedNodeMap::operator!= (const QDomNamedNodeMap& n) const-
2173{-
2174 return (impl != n.impl);-
2175}-
2176-
2177-
2178-
2179-
2180QDomNamedNodeMap::~QDomNamedNodeMap()-
2181{-
2182 if (impl && !impl->ref.deref())-
2183 delete impl;-
2184}-
2185QDomNode QDomNamedNodeMap::namedItem(const QString& name) const-
2186{-
2187 if (!impl)-
2188 return QDomNode();-
2189 return QDomNode(((QDomNamedNodeMapPrivate*)impl)->namedItem(name));-
2190}-
2191QDomNode QDomNamedNodeMap::setNamedItem(const QDomNode& newNode)-
2192{-
2193 if (!impl)-
2194 return QDomNode();-
2195 return QDomNode(((QDomNamedNodeMapPrivate*)impl)->setNamedItem((QDomNodePrivate*)newNode.impl));-
2196}-
2197QDomNode QDomNamedNodeMap::removeNamedItem(const QString& name)-
2198{-
2199 if (!impl)-
2200 return QDomNode();-
2201 return QDomNode(((QDomNamedNodeMapPrivate*)impl)->removeNamedItem(name));-
2202}-
2203QDomNode QDomNamedNodeMap::item(int index) const-
2204{-
2205 if (!impl)-
2206 return QDomNode();-
2207 return QDomNode(((QDomNamedNodeMapPrivate*)impl)->item(index));-
2208}-
2209QDomNode QDomNamedNodeMap::namedItemNS(const QString& nsURI, const QString& localName) const-
2210{-
2211 if (!impl)-
2212 return QDomNode();-
2213 return QDomNode(((QDomNamedNodeMapPrivate*)impl)->namedItemNS(nsURI, localName));-
2214}-
2215QDomNode QDomNamedNodeMap::setNamedItemNS(const QDomNode& newNode)-
2216{-
2217 if (!impl)-
2218 return QDomNode();-
2219 return QDomNode(((QDomNamedNodeMapPrivate*)impl)->setNamedItemNS((QDomNodePrivate*)newNode.impl));-
2220}-
2221QDomNode QDomNamedNodeMap::removeNamedItemNS(const QString& nsURI, const QString& localName)-
2222{-
2223 if (!impl)-
2224 return QDomNode();-
2225 QDomNodePrivate *n = ((QDomNamedNodeMapPrivate*)impl)->namedItemNS(nsURI, localName);-
2226 if (!n)-
2227 return QDomNode();-
2228 return QDomNode(((QDomNamedNodeMapPrivate*)impl)->removeNamedItem(n->name));-
2229}-
2230-
2231-
2232-
2233-
2234-
2235-
2236int QDomNamedNodeMap::length() const-
2237{-
2238 if (!impl)-
2239 return 0;-
2240 return ((QDomNamedNodeMapPrivate*)impl)->length();-
2241}-
2242bool QDomNamedNodeMap::contains(const QString& name) const-
2243{-
2244 if (!impl)-
2245 return false;-
2246 return ((QDomNamedNodeMapPrivate*)impl)->contains(name);-
2247}-
2248QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent)-
2249 : QDomNodePrivate(doc, parent)-
2250{-
2251 init();-
2252}-
2253-
2254QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentTypePrivate* n, bool deep)-
2255 : QDomNodePrivate(n, deep)-
2256{-
2257 init();-
2258-
2259 QDomNodePrivate* p = first;-
2260 while (p) {-
2261 if (p->isEntity())-
2262-
2263 entities->map.insertMulti(p->nodeName(), p);-
2264 if (p->isNotation())-
2265-
2266 notations->map.insertMulti(p->nodeName(), p);-
2267 p = p->next;-
2268 }-
2269}-
2270-
2271QDomDocumentTypePrivate::~QDomDocumentTypePrivate()-
2272{-
2273 if (!entities->ref.deref())-
2274 delete entities;-
2275 if (!notations->ref.deref())-
2276 delete notations;-
2277}-
2278-
2279void QDomDocumentTypePrivate::init()-
2280{-
2281 entities = new QDomNamedNodeMapPrivate(this);-
2282 if (true) {-
2283 notations = new QDomNamedNodeMapPrivate(this);-
2284 publicId.clear();-
2285 systemId.clear();-
2286 internalSubset.clear();-
2287-
2288 entities->setAppendToParent(true);-
2289 notations->setAppendToParent(true);-
2290 } else {
dead code: { delete entities; qt_noop(); }
-
2291 delete entities;
dead code: { delete entities; qt_noop(); }
-
2292 qt_noop();
dead code: { delete entities; qt_noop(); }
-
2293 }
dead code: { delete entities; qt_noop(); }
-
2294}-
2295-
2296QDomNodePrivate* QDomDocumentTypePrivate::cloneNode(bool deep)-
2297{-
2298 QDomNodePrivate* p = new QDomDocumentTypePrivate(this, deep);-
2299-
2300 p->ref.deref();-
2301 return p;-
2302}-
2303-
2304QDomNodePrivate* QDomDocumentTypePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild)-
2305{-
2306-
2307 QDomNodePrivate* p = QDomNodePrivate::insertBefore(newChild, refChild);-
2308-
2309 if (p && p->isEntity())-
2310 entities->map.insertMulti(p->nodeName(), p);-
2311 else if (p && p->isNotation())-
2312 notations->map.insertMulti(p->nodeName(), p);-
2313-
2314 return p;-
2315}-
2316-
2317QDomNodePrivate* QDomDocumentTypePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild)-
2318{-
2319-
2320 QDomNodePrivate* p = QDomNodePrivate::insertAfter(newChild, refChild);-
2321-
2322 if (p && p->isEntity())-
2323 entities->map.insertMulti(p->nodeName(), p);-
2324 else if (p && p->isNotation())-
2325 notations->map.insertMulti(p->nodeName(), p);-
2326-
2327 return p;-
2328}-
2329-
2330QDomNodePrivate* QDomDocumentTypePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild)-
2331{-
2332-
2333 QDomNodePrivate* p = QDomNodePrivate::replaceChild(newChild, oldChild);-
2334-
2335 if (p) {-
2336 if (oldChild && oldChild->isEntity())-
2337 entities->map.remove(oldChild->nodeName());-
2338 else if (oldChild && oldChild->isNotation())-
2339 notations->map.remove(oldChild->nodeName());-
2340-
2341 if (p->isEntity())-
2342 entities->map.insertMulti(p->nodeName(), p);-
2343 else if (p->isNotation())-
2344 notations->map.insertMulti(p->nodeName(), p);-
2345 }-
2346-
2347 return p;-
2348}-
2349-
2350QDomNodePrivate* QDomDocumentTypePrivate::removeChild(QDomNodePrivate* oldChild)-
2351{-
2352-
2353 QDomNodePrivate* p = QDomNodePrivate::removeChild( oldChild);-
2354-
2355 if (p && p->isEntity())-
2356 entities->map.remove(p->nodeName());-
2357 else if (p && p->isNotation())-
2358 notations->map.remove(p ->nodeName());-
2359-
2360 return p;-
2361}-
2362-
2363QDomNodePrivate* QDomDocumentTypePrivate::appendChild(QDomNodePrivate* newChild)-
2364{-
2365 return insertAfter(newChild, 0);-
2366}-
2367-
2368static QString quotedValue(const QString &data)-
2369{-
2370 QChar quote = data.indexOf(QLatin1Char('\'')) == -1-
2371 ? QLatin1Char('\'')-
2372 : QLatin1Char('"');-
2373 return quote + data + quote;-
2374}-
2375-
2376void QDomDocumentTypePrivate::save(QTextStream& s, int, int indent) const-
2377{-
2378 if (name.isEmpty())-
2379 return;-
2380-
2381 s << "<!DOCTYPE " << name;-
2382-
2383 if (!publicId.isNull()) {-
2384 s << " PUBLIC " << quotedValue(publicId);-
2385 if (!systemId.isNull()) {-
2386 s << ' ' << quotedValue(systemId);-
2387 }-
2388 } else if (!systemId.isNull()) {-
2389 s << " SYSTEM " << quotedValue(systemId);-
2390 }-
2391-
2392 if (entities->length()>0 || notations->length()>0) {-
2393 s << " [" << endl;-
2394-
2395 QHash<QString, QDomNodePrivate *>::const_iterator it2 = notations->map.constBegin();-
2396 for (; it2 != notations->map.constEnd(); ++it2)-
2397 (*it2)->save(s, 0, indent);-
2398-
2399 QHash<QString, QDomNodePrivate *>::const_iterator it = entities->map.constBegin();-
2400 for (; it != entities->map.constEnd(); ++it)-
2401 (*it)->save(s, 0, indent);-
2402-
2403 s << ']';-
2404 }-
2405-
2406 s << '>' << endl;-
2407}-
2408QDomDocumentType::QDomDocumentType() : QDomNode()-
2409{-
2410}-
2411QDomDocumentType::QDomDocumentType(const QDomDocumentType& n)-
2412 : QDomNode(n)-
2413{-
2414}-
2415-
2416QDomDocumentType::QDomDocumentType(QDomDocumentTypePrivate* n)-
2417 : QDomNode(n)-
2418{-
2419}-
2420QDomDocumentType& QDomDocumentType::operator= (const QDomDocumentType& n)-
2421{-
2422 return (QDomDocumentType&) QDomNode::operator=(n);-
2423}-
2424-
2425-
2426-
2427-
2428-
2429-
2430-
2431QString QDomDocumentType::name() const-
2432{-
2433 if (!impl)-
2434 return QString();-
2435 return ((QDomDocumentTypePrivate*)impl)->nodeName();-
2436}-
2437-
2438-
2439-
2440-
2441QDomNamedNodeMap QDomDocumentType::entities() const-
2442{-
2443 if (!impl)-
2444 return QDomNamedNodeMap();-
2445 return QDomNamedNodeMap(((QDomDocumentTypePrivate*)impl)->entities);-
2446}-
2447-
2448-
2449-
2450-
2451QDomNamedNodeMap QDomDocumentType::notations() const-
2452{-
2453 if (!impl)-
2454 return QDomNamedNodeMap();-
2455 return QDomNamedNodeMap(((QDomDocumentTypePrivate*)impl)->notations);-
2456}-
2457-
2458-
2459-
2460-
2461-
2462-
2463-
2464QString QDomDocumentType::publicId() const-
2465{-
2466 if (!impl)-
2467 return QString();-
2468 return ((QDomDocumentTypePrivate*)impl)->publicId;-
2469}-
2470-
2471-
2472-
2473-
2474-
2475-
2476-
2477QString QDomDocumentType::systemId() const-
2478{-
2479 if (!impl)-
2480 return QString();-
2481 return ((QDomDocumentTypePrivate*)impl)->systemId;-
2482}-
2483-
2484-
2485-
2486-
2487-
2488-
2489-
2490QString QDomDocumentType::internalSubset() const-
2491{-
2492 if (!impl)-
2493 return QString();-
2494 return ((QDomDocumentTypePrivate*)impl)->internalSubset;-
2495}-
2496QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent)-
2497 : QDomNodePrivate(doc, parent)-
2498{-
2499 name = QLatin1String("#document-fragment");-
2500}-
2501-
2502QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomNodePrivate* n, bool deep)-
2503 : QDomNodePrivate(n, deep)-
2504{-
2505}-
2506-
2507QDomNodePrivate* QDomDocumentFragmentPrivate::cloneNode(bool deep)-
2508{-
2509 QDomNodePrivate* p = new QDomDocumentFragmentPrivate(this, deep);-
2510-
2511 p->ref.deref();-
2512 return p;-
2513}-
2514QDomDocumentFragment::QDomDocumentFragment()-
2515{-
2516}-
2517-
2518QDomDocumentFragment::QDomDocumentFragment(QDomDocumentFragmentPrivate* n)-
2519 : QDomNode(n)-
2520{-
2521}-
2522QDomDocumentFragment::QDomDocumentFragment(const QDomDocumentFragment& x)-
2523 : QDomNode(x)-
2524{-
2525}-
2526QDomDocumentFragment& QDomDocumentFragment::operator= (const QDomDocumentFragment& x)-
2527{-
2528 return (QDomDocumentFragment&) QDomNode::operator=(x);-
2529}-
2530QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,-
2531 const QString& data)-
2532 : QDomNodePrivate(d, p)-
2533{-
2534 value = data;-
2535 name = QLatin1String("#character-data");-
2536}-
2537-
2538QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomCharacterDataPrivate* n, bool deep)-
2539 : QDomNodePrivate(n, deep)-
2540{-
2541}-
2542-
2543QDomNodePrivate* QDomCharacterDataPrivate::cloneNode(bool deep)-
2544{-
2545 QDomNodePrivate* p = new QDomCharacterDataPrivate(this, deep);-
2546-
2547 p->ref.deref();-
2548 return p;-
2549}-
2550-
2551int QDomCharacterDataPrivate::dataLength() const-
2552{-
2553 return value.length();-
2554}-
2555-
2556QString QDomCharacterDataPrivate::substringData(unsigned long offset, unsigned long n) const-
2557{-
2558 return value.mid(offset, n);-
2559}-
2560-
2561void QDomCharacterDataPrivate::insertData(unsigned long offset, const QString& arg)-
2562{-
2563 value.insert(offset, arg);-
2564}-
2565-
2566void QDomCharacterDataPrivate::deleteData(unsigned long offset, unsigned long n)-
2567{-
2568 value.remove(offset, n);-
2569}-
2570-
2571void QDomCharacterDataPrivate::replaceData(unsigned long offset, unsigned long n, const QString& arg)-
2572{-
2573 value.replace(offset, n, arg);-
2574}-
2575-
2576void QDomCharacterDataPrivate::appendData(const QString& arg)-
2577{-
2578 value += arg;-
2579}-
2580QDomCharacterData::QDomCharacterData()-
2581{-
2582}-
2583QDomCharacterData::QDomCharacterData(const QDomCharacterData& x)-
2584 : QDomNode(x)-
2585{-
2586}-
2587-
2588QDomCharacterData::QDomCharacterData(QDomCharacterDataPrivate* n)-
2589 : QDomNode(n)-
2590{-
2591}-
2592QDomCharacterData& QDomCharacterData::operator= (const QDomCharacterData& x)-
2593{-
2594 return (QDomCharacterData&) QDomNode::operator=(x);-
2595}-
2596-
2597-
2598-
2599-
2600-
2601-
2602-
2603QString QDomCharacterData::data() const-
2604{-
2605 if (!impl)-
2606 return QString();-
2607 return impl->nodeValue();-
2608}-
2609-
2610-
2611-
2612-
2613void QDomCharacterData::setData(const QString& v)-
2614{-
2615 if (impl)-
2616 impl->setNodeValue(v);-
2617}-
2618-
2619-
2620-
2621-
2622int QDomCharacterData::length() const-
2623{-
2624 if (impl)-
2625 return ((QDomCharacterDataPrivate*)impl)->dataLength();-
2626 return 0;-
2627}-
2628-
2629-
2630-
2631-
2632QString QDomCharacterData::substringData(unsigned long offset, unsigned long count)-
2633{-
2634 if (!impl)-
2635 return QString();-
2636 return ((QDomCharacterDataPrivate*)impl)->substringData(offset, count);-
2637}-
2638-
2639-
2640-
2641-
2642void QDomCharacterData::appendData(const QString& arg)-
2643{-
2644 if (impl)-
2645 ((QDomCharacterDataPrivate*)impl)->appendData(arg);-
2646}-
2647-
2648-
2649-
2650-
2651void QDomCharacterData::insertData(unsigned long offset, const QString& arg)-
2652{-
2653 if (impl)-
2654 ((QDomCharacterDataPrivate*)impl)->insertData(offset, arg);-
2655}-
2656-
2657-
2658-
2659-
2660void QDomCharacterData::deleteData(unsigned long offset, unsigned long count)-
2661{-
2662 if (impl)-
2663 ((QDomCharacterDataPrivate*)impl)->deleteData(offset, count);-
2664}-
2665-
2666-
2667-
2668-
2669-
2670void QDomCharacterData::replaceData(unsigned long offset, unsigned long count, const QString& arg)-
2671{-
2672 if (impl)-
2673 ((QDomCharacterDataPrivate*)impl)->replaceData(offset, count, arg);-
2674}-
2675-
2676-
2677-
2678-
2679-
2680-
2681QDomNode::NodeType QDomCharacterData::nodeType() const-
2682{-
2683 if (!impl)-
2684 return CharacterDataNode;-
2685 return QDomNode::nodeType();-
2686}-
2687QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& name_)-
2688 : QDomNodePrivate(d, parent)-
2689{-
2690 name = name_;-
2691 m_specified = false;-
2692}-
2693-
2694QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p, const QString& nsURI, const QString& qName)-
2695 : QDomNodePrivate(d, p)-
2696{-
2697 qt_split_namespace(prefix, name, qName, !nsURI.isNull());-
2698 namespaceURI = nsURI;-
2699 createdWithDom1Interface = false;-
2700 m_specified = false;-
2701}-
2702-
2703QDomAttrPrivate::QDomAttrPrivate(QDomAttrPrivate* n, bool deep)-
2704 : QDomNodePrivate(n, deep)-
2705{-
2706 m_specified = n->specified();-
2707}-
2708-
2709void QDomAttrPrivate::setNodeValue(const QString& v)-
2710{-
2711 value = v;-
2712 QDomTextPrivate *t = new QDomTextPrivate(0, this, v);-
2713-
2714 t->ref.deref();-
2715 if (first) {-
2716 delete removeChild(first);-
2717 }-
2718 appendChild(t);-
2719}-
2720-
2721QDomNodePrivate* QDomAttrPrivate::cloneNode(bool deep)-
2722{-
2723 QDomNodePrivate* p = new QDomAttrPrivate(this, deep);-
2724-
2725 p->ref.deref();-
2726 return p;-
2727}-
2728-
2729bool QDomAttrPrivate::specified() const-
2730{-
2731 return m_specified;-
2732}-
2733static QString encodeText(const QString &str,-
2734 QTextStream &s,-
2735 const bool encodeQuotes = true,-
2736 const bool performAVN = false,-
2737 const bool encodeEOLs = false)-
2738{-
2739-
2740-
2741-
2742 const QTextCodec *const codec = s.codec();-
2743 ((!(codec)) ? qt_assert("codec",__FILE__,41504156) : qt_noop());-
2744-
2745 QString retval(str);-
2746 int len = retval.length();-
2747 int i = 0;-
2748-
2749 while (i < len) {-
2750 const QChar ati(retval.at(i));-
2751-
2752 if (ati == QLatin1Char('<')) {-
2753 retval.replace(i, 1, QLatin1String("&lt;"));-
2754 len += 3;-
2755 i += 4;-
2756 } else if (encodeQuotes && (ati == QLatin1Char('"'))) {-
2757 retval.replace(i, 1, QLatin1String("&quot;"));-
2758 len += 5;-
2759 i += 6;-
2760 } else if (ati == QLatin1Char('&')) {-
2761 retval.replace(i, 1, QLatin1String("&amp;"));-
2762 len += 4;-
2763 i += 5;-
2764 } else if (ati == QLatin1Char('>') && i >= 2 && retval[i - 1] == QLatin1Char(']') && retval[i - 2] == QLatin1Char(']')) {-
2765 retval.replace(i, 1, QLatin1String("&gt;"));-
2766 len += 3;-
2767 i += 4;-
2768 } else if (performAVN &&-
2769 (ati == QChar(0xA) ||-
2770 ati == QChar(0xD) ||-
2771 ati == QChar(0x9))) {-
2772 const QString replacement(QLatin1String("&#x") + QString::number(ati.unicode(), 16) + QLatin1Char(';'));-
2773 retval.replace(i, 1, replacement);-
2774 i += replacement.length();-
2775 len += replacement.length() - 1;-
2776 } else if (encodeEOLs && ati == QChar(0xD)) {-
2777 retval.replace(i, 1, QLatin1String("&#xd;"));-
2778 len += 4;-
2779 i += 5;-
2780 } else {-
2781-
2782 if(codec->canEncode(ati))-
2783 ++i;-
2784 else-
2785-
2786 {-
2787-
2788 const ushort codepoint(ati.unicode());-
2789 const QString replacement(QLatin1String("&#x") + QString::number(codepoint, 16) + QLatin1Char(';'));-
2790 retval.replace(i, 1, replacement);-
2791 i += replacement.length();-
2792 len += replacement.length() - 1;-
2793 }-
2794 }-
2795 }-
2796-
2797 return retval;-
2798}-
2799-
2800void QDomAttrPrivate::save(QTextStream& s, int, int) const-
2801{-
2802 if (namespaceURI.isNull()) {-
2803 s << name << "=\"" << encodeText(value, s, true, true) << '\"';-
2804 } else {-
2805 s << prefix << ':' << name << "=\"" << encodeText(value, s, true, true) << '\"';-
2806 if(!ownerNode ||-
2807 ownerNode->prefix != prefix) {-
2808 s << " xmlns:" << prefix << "=\"" << encodeText(namespaceURI, s, true, true) << '\"';-
2809 }-
2810 }-
2811}-
2812QDomAttr::QDomAttr()-
2813{-
2814}-
2815QDomAttr::QDomAttr(const QDomAttr& x)-
2816 : QDomNode(x)-
2817{-
2818}-
2819-
2820QDomAttr::QDomAttr(QDomAttrPrivate* n)-
2821 : QDomNode(n)-
2822{-
2823}-
2824QDomAttr& QDomAttr::operator= (const QDomAttr& x)-
2825{-
2826 return (QDomAttr&) QDomNode::operator=(x);-
2827}-
2828-
2829-
2830-
2831-
2832QString QDomAttr::name() const-
2833{-
2834 if (!impl)-
2835 return QString();-
2836 return impl->nodeName();-
2837}-
2838-
2839-
2840-
2841-
2842-
2843-
2844-
2845bool QDomAttr::specified() const-
2846{-
2847 if (!impl)-
2848 return false;-
2849 return ((QDomAttrPrivate*)impl)->specified();-
2850}-
2851-
2852-
2853-
2854-
2855-
2856-
2857QDomElement QDomAttr::ownerElement() const-
2858{-
2859 ((!(impl->parent())) ? qt_assert("impl->parent()",__FILE__,43404346) : qt_noop());-
2860 if (!impl->parent()->isElement())-
2861 return QDomElement();-
2862 return QDomElement((QDomElementPrivate*)(impl->parent()));-
2863}-
2864-
2865-
2866-
2867-
2868-
2869-
2870-
2871QString QDomAttr::value() const-
2872{-
2873 if (!impl)-
2874 return QString();-
2875 return impl->nodeValue();-
2876}-
2877-
2878-
2879-
2880-
2881-
2882-
2883void QDomAttr::setValue(const QString& v)-
2884{-
2885 if (!impl)-
2886 return;-
2887 impl->setNodeValue(v);-
2888 ((QDomAttrPrivate*)impl)->m_specified = true;-
2889}-
2890QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,-
2891 const QString& tagname)-
2892 : QDomNodePrivate(d, p)-
2893{-
2894 name = tagname;-
2895 m_attr = new QDomNamedNodeMapPrivate(this);-
2896}-
2897-
2898QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,-
2899 const QString& nsURI, const QString& qName)-
2900 : QDomNodePrivate(d, p)-
2901{-
2902 qt_split_namespace(prefix, name, qName, !nsURI.isNull());-
2903 namespaceURI = nsURI;-
2904 createdWithDom1Interface = false;-
2905 m_attr = new QDomNamedNodeMapPrivate(this);-
2906}-
2907-
2908QDomElementPrivate::QDomElementPrivate(QDomElementPrivate* n, bool deep) :-
2909 QDomNodePrivate(n, deep)-
2910{-
2911 m_attr = n->m_attr->clone(this);-
2912-
2913 m_attr->ref.ref();-
2914}-
2915-
2916QDomElementPrivate::~QDomElementPrivate()-
2917{-
2918 if (!m_attr->ref.deref())-
2919 delete m_attr;-
2920}-
2921-
2922QDomNodePrivate* QDomElementPrivate::cloneNode(bool deep)-
2923{-
2924 QDomNodePrivate* p = new QDomElementPrivate(this, deep);-
2925-
2926 p->ref.deref();-
2927 return p;-
2928}-
2929-
2930QString QDomElementPrivate::attribute(const QString& name_, const QString& defValue) const-
2931{-
2932 QDomNodePrivate* n = m_attr->namedItem(name_);-
2933 if (!n)-
2934 return defValue;-
2935-
2936 return n->nodeValue();-
2937}-
2938-
2939QString QDomElementPrivate::attributeNS(const QString& nsURI, const QString& localName, const QString& defValue) const-
2940{-
2941 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);-
2942 if (!n)-
2943 return defValue;-
2944-
2945 return n->nodeValue();-
2946}-
2947-
2948void QDomElementPrivate::setAttribute(const QString& aname, const QString& newValue)-
2949{-
2950 QDomNodePrivate* n = m_attr->namedItem(aname);-
2951 if (!n) {-
2952 n = new QDomAttrPrivate(ownerDocument(), this, aname);-
2953 n->setNodeValue(newValue);-
2954-
2955-
2956-
2957 n->ref.deref();-
2958 m_attr->setNamedItem(n);-
2959 } else {-
2960 n->setNodeValue(newValue);-
2961 }-
2962}-
2963-
2964void QDomElementPrivate::setAttributeNS(const QString& nsURI, const QString& qName, const QString& newValue)-
2965{-
2966 QString prefix, localName;-
2967 qt_split_namespace(prefix, localName, qName, true);-
2968 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);-
2969 if (!n) {-
2970 n = new QDomAttrPrivate(ownerDocument(), this, nsURI, qName);-
2971 n->setNodeValue(newValue);-
2972-
2973-
2974-
2975 n->ref.deref();-
2976 m_attr->setNamedItem(n);-
2977 } else {-
2978 n->setNodeValue(newValue);-
2979 n->prefix = prefix;-
2980 }-
2981}-
2982-
2983void QDomElementPrivate::removeAttribute(const QString& aname)-
2984{-
2985 QDomNodePrivate* p = m_attr->removeNamedItem(aname);-
2986 if (p && p->ref.load() == 0)-
2987 delete p;-
2988}-
2989-
2990QDomAttrPrivate* QDomElementPrivate::attributeNode(const QString& aname)-
2991{-
2992 return (QDomAttrPrivate*)m_attr->namedItem(aname);-
2993}-
2994-
2995QDomAttrPrivate* QDomElementPrivate::attributeNodeNS(const QString& nsURI, const QString& localName)-
2996{-
2997 return (QDomAttrPrivate*)m_attr->namedItemNS(nsURI, localName);-
2998}-
2999-
3000QDomAttrPrivate* QDomElementPrivate::setAttributeNode(QDomAttrPrivate* newAttr)-
3001{-
3002 QDomNodePrivate* n = m_attr->namedItem(newAttr->nodeName());-
3003-
3004-
3005 m_attr->setNamedItem(newAttr);-
3006-
3007 newAttr->setParent(this);-
3008-
3009 return (QDomAttrPrivate*)n;-
3010}-
3011-
3012QDomAttrPrivate* QDomElementPrivate::setAttributeNodeNS(QDomAttrPrivate* newAttr)-
3013{-
3014 QDomNodePrivate* n = 0;-
3015 if (!newAttr->prefix.isNull())-
3016 n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name);-
3017-
3018-
3019 m_attr->setNamedItem(newAttr);-
3020-
3021 return (QDomAttrPrivate*)n;-
3022}-
3023-
3024QDomAttrPrivate* QDomElementPrivate::removeAttributeNode(QDomAttrPrivate* oldAttr)-
3025{-
3026 return (QDomAttrPrivate*)m_attr->removeNamedItem(oldAttr->nodeName());-
3027}-
3028-
3029bool QDomElementPrivate::hasAttribute(const QString& aname)-
3030{-
3031 return m_attr->contains(aname);-
3032}-
3033-
3034bool QDomElementPrivate::hasAttributeNS(const QString& nsURI, const QString& localName)-
3035{-
3036 return m_attr->containsNS(nsURI, localName);-
3037}-
3038-
3039QString QDomElementPrivate::text()-
3040{-
3041 QString t(QLatin1String(""));-
3042-
3043 QDomNodePrivate* p = first;-
3044 while (p) {-
3045 if (p->isText() || p->isCDATASection())-
3046 t += p->nodeValue();-
3047 else if (p->isElement())-
3048 t += ((QDomElementPrivate*)p)->text();-
3049 p = p->next;-
3050 }-
3051-
3052 return t;-
3053}-
3054-
3055void QDomElementPrivate::save(QTextStream& s, int depth, int indent) const-
3056{-
3057 if (!(prev && prev->isText()))-
3058 s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));-
3059-
3060 QString qName(name);-
3061 QString nsDecl(QLatin1String(""));-
3062 if (!namespaceURI.isNull()) {-
3063 if (prefix.isEmpty()) {-
3064 nsDecl = QLatin1String(" xmlns");-
3065 } else {-
3066 qName = prefix + QLatin1Char(':') + name;-
3067 nsDecl = QLatin1String(" xmlns:") + prefix;-
3068 }-
3069 nsDecl += QLatin1String("=\"") + encodeText(namespaceURI, s) + QLatin1Char('\"');-
3070 }-
3071 s << '<' << qName << nsDecl;-
3072-
3073 QSet<QString> outputtedPrefixes;-
3074-
3075-
3076 if (!m_attr->map.isEmpty()) {-
3077 QHash<QString, QDomNodePrivate *>::const_iterator it = m_attr->map.constBegin();-
3078 for (; it != m_attr->map.constEnd(); ++it) {-
3079 s << ' ';-
3080 if (it.value()->namespaceURI.isNull()) {-
3081 s << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';-
3082 } else {-
3083 s << it.value()->prefix << ':' << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';-
3084 if((!it.value()->ownerNode ||-
3085 it.value()->ownerNode->prefix != it.value()->prefix) &&-
3086 !outputtedPrefixes.contains(it.value()->prefix)) {-
3087 s << " xmlns:" << it.value()->prefix << "=\"" << encodeText(it.value()->namespaceURI, s, true, true) << '\"';-
3088 outputtedPrefixes.insert(it.value()->prefix);-
3089 }-
3090 }-
3091 }-
3092 }-
3093-
3094 if (last) {-
3095-
3096 if (first->isText())-
3097 s << '>';-
3098 else {-
3099 s << '>';-
3100-
3101-
3102 if (indent != -1)-
3103 s << endl;-
3104 }-
3105 QDomNodePrivate::save(s, depth + 1, indent); if (!last->isText())-
3106 s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));-
3107-
3108 s << "</" << qName << '>';-
3109 } else {-
3110 s << "/>";-
3111 }-
3112 if (!(next && next->isText())) {-
3113-
3114 if (indent != -1)-
3115 s << endl;-
3116 }-
3117}-
3118QDomElement::QDomElement()-
3119 : QDomNode()-
3120{-
3121}-
3122QDomElement::QDomElement(const QDomElement& x)-
3123 : QDomNode(x)-
3124{-
3125}-
3126-
3127QDomElement::QDomElement(QDomElementPrivate* n)-
3128 : QDomNode(n)-
3129{-
3130}-
3131QDomElement& QDomElement::operator= (const QDomElement& x)-
3132{-
3133 return (QDomElement&) QDomNode::operator=(x);-
3134}-
3135void QDomElement::setTagName(const QString& name)-
3136{-
3137 if (impl)-
3138 impl->name = name;-
3139}-
3140QString QDomElement::tagName() const-
3141{-
3142 if (!impl)-
3143 return QString();-
3144 return impl->nodeName();-
3145}-
3146-
3147-
3148-
3149-
3150-
3151-
3152-
3153QDomNamedNodeMap QDomElement::attributes() const-
3154{-
3155 if (!impl)-
3156 return QDomNamedNodeMap();-
3157 return QDomNamedNodeMap(((QDomElementPrivate*)impl)->attributes());-
3158}-
3159-
3160-
3161-
3162-
3163-
3164-
3165-
3166QString QDomElement::attribute(const QString& name, const QString& defValue) const-
3167{-
3168 if (!impl)-
3169 return defValue;-
3170 return ((QDomElementPrivate*)impl)->attribute(name, defValue);-
3171}-
3172void QDomElement::setAttribute(const QString& name, const QString& value)-
3173{-
3174 if (!impl)-
3175 return;-
3176 ((QDomElementPrivate*)impl)->setAttribute(name, value);-
3177}-
3178void QDomElement::setAttribute(const QString& name, qlonglong value)-
3179{-
3180 if (!impl)-
3181 return;-
3182 QString x;-
3183 x.setNum(value);-
3184 ((QDomElementPrivate*)impl)->setAttribute(name, x);-
3185}-
3186-
3187-
3188-
3189-
3190-
3191-
3192void QDomElement::setAttribute(const QString& name, qulonglong value)-
3193{-
3194 if (!impl)-
3195 return;-
3196 QString x;-
3197 x.setNum(value);-
3198 ((QDomElementPrivate*)impl)->setAttribute(name, x);-
3199}-
3200-
3201-
3202-
3203-
3204-
3205-
3206void QDomElement::setAttribute(const QString& name, float value)-
3207{-
3208 if (!impl)-
3209 return;-
3210 QString x;-
3211 x.setNum(value);-
3212 ((QDomElementPrivate*)impl)->setAttribute(name, x);-
3213}-
3214-
3215-
3216-
3217-
3218-
3219-
3220void QDomElement::setAttribute(const QString& name, double value)-
3221{-
3222 if (!impl)-
3223 return;-
3224 QString x;-
3225 char buf[256];-
3226 int count = qsnprintf(buf, sizeof(buf), "%.16g", value);-
3227 if (count > 0)-
3228 x = QString::fromLatin1(buf, count);-
3229 else-
3230 x.setNum(value);-
3231 ((QDomElementPrivate*)impl)->setAttribute(name, x);-
3232}-
3233-
3234-
3235-
3236-
3237-
3238-
3239void QDomElement::removeAttribute(const QString& name)-
3240{-
3241 if (!impl)-
3242 return;-
3243 ((QDomElementPrivate*)impl)->removeAttribute(name);-
3244}-
3245QDomAttr QDomElement::attributeNode(const QString& name)-
3246{-
3247 if (!impl)-
3248 return QDomAttr();-
3249 return QDomAttr(((QDomElementPrivate*)impl)->attributeNode(name));-
3250}-
3251QDomAttr QDomElement::setAttributeNode(const QDomAttr& newAttr)-
3252{-
3253 if (!impl)-
3254 return QDomAttr();-
3255 return QDomAttr(((QDomElementPrivate*)impl)->setAttributeNode(((QDomAttrPrivate*)newAttr.impl)));-
3256}-
3257-
3258-
3259-
3260-
3261-
3262-
3263QDomAttr QDomElement::removeAttributeNode(const QDomAttr& oldAttr)-
3264{-
3265 if (!impl)-
3266 return QDomAttr();-
3267 return QDomAttr(((QDomElementPrivate*)impl)->removeAttributeNode(((QDomAttrPrivate*)oldAttr.impl)));-
3268}-
3269QDomNodeList QDomElement::elementsByTagName(const QString& tagname) const-
3270{-
3271 return QDomNodeList(new QDomNodeListPrivate(impl, tagname));-
3272}-
3273bool QDomElement::hasAttribute(const QString& name) const-
3274{-
3275 if (!impl)-
3276 return false;-
3277 return ((QDomElementPrivate*)impl)->hasAttribute(name);-
3278}-
3279QString QDomElement::attributeNS(const QString nsURI, const QString& localName, const QString& defValue) const-
3280{-
3281 if (!impl)-
3282 return defValue;-
3283 return ((QDomElementPrivate*)impl)->attributeNS(nsURI, localName, defValue);-
3284}-
3285void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, const QString& value)-
3286{-
3287 if (!impl)-
3288 return;-
3289 ((QDomElementPrivate*)impl)->setAttributeNS(nsURI, qName, value);-
3290}-
3291void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, qlonglong value)-
3292{-
3293 if (!impl)-
3294 return;-
3295 QString x;-
3296 x.setNum(value);-
3297 ((QDomElementPrivate*)impl)->setAttributeNS(nsURI, qName, x);-
3298}-
3299-
3300-
3301-
3302-
3303void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, qulonglong value)-
3304{-
3305 if (!impl)-
3306 return;-
3307 QString x;-
3308 x.setNum(value);-
3309 ((QDomElementPrivate*)impl)->setAttributeNS(nsURI, qName, x);-
3310}-
3311-
3312-
3313-
3314-
3315void QDomElement::setAttributeNS(const QString nsURI, const QString& qName, double value)-
3316{-
3317 if (!impl)-
3318 return;-
3319 QString x;-
3320 x.setNum(value);-
3321 ((QDomElementPrivate*)impl)->setAttributeNS(nsURI, qName, x);-
3322}-
3323-
3324-
3325-
3326-
3327-
3328-
3329-
3330void QDomElement::removeAttributeNS(const QString& nsURI, const QString& localName)-
3331{-
3332 if (!impl)-
3333 return;-
3334 QDomNodePrivate *n = ((QDomElementPrivate*)impl)->attributeNodeNS(nsURI, localName);-
3335 if (!n)-
3336 return;-
3337 ((QDomElementPrivate*)impl)->removeAttribute(n->nodeName());-
3338}-
3339QDomAttr QDomElement::attributeNodeNS(const QString& nsURI, const QString& localName)-
3340{-
3341 if (!impl)-
3342 return QDomAttr();-
3343 return QDomAttr(((QDomElementPrivate*)impl)->attributeNodeNS(nsURI, localName));-
3344}-
3345QDomAttr QDomElement::setAttributeNodeNS(const QDomAttr& newAttr)-
3346{-
3347 if (!impl)-
3348 return QDomAttr();-
3349 return QDomAttr(((QDomElementPrivate*)impl)->setAttributeNodeNS(((QDomAttrPrivate*)newAttr.impl)));-
3350}-
3351QDomNodeList QDomElement::elementsByTagNameNS(const QString& nsURI, const QString& localName) const-
3352{-
3353 return QDomNodeList(new QDomNodeListPrivate(impl, nsURI, localName));-
3354}-
3355-
3356-
3357-
3358-
3359-
3360-
3361bool QDomElement::hasAttributeNS(const QString& nsURI, const QString& localName) const-
3362{-
3363 if (!impl)-
3364 return false;-
3365 return ((QDomElementPrivate*)impl)->hasAttributeNS(nsURI, localName);-
3366}-
3367QString QDomElement::text() const-
3368{-
3369 if (!impl)-
3370 return QString();-
3371 return ((QDomElementPrivate*)impl)->text();-
3372}-
3373QDomTextPrivate::QDomTextPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& val)-
3374 : QDomCharacterDataPrivate(d, parent, val)-
3375{-
3376 name = QLatin1String("#text");-
3377}-
3378-
3379QDomTextPrivate::QDomTextPrivate(QDomTextPrivate* n, bool deep)-
3380 : QDomCharacterDataPrivate(n, deep)-
3381{-
3382}-
3383-
3384QDomNodePrivate* QDomTextPrivate::cloneNode(bool deep)-
3385{-
3386 QDomNodePrivate* p = new QDomTextPrivate(this, deep);-
3387-
3388 p->ref.deref();-
3389 return p;-
3390}-
3391-
3392QDomTextPrivate* QDomTextPrivate::splitText(int offset)-
3393{-
3394 if (!parent()) {-
3395 QMessageLogger(__FILE__, 51765182, __PRETTY_FUNCTION__).warning("QDomText::splitText The node has no parent. So I can not split");-
3396 return 0;-
3397 }-
3398-
3399 QDomTextPrivate* t = new QDomTextPrivate(ownerDocument(), 0, value.mid(offset));-
3400 value.truncate(offset);-
3401-
3402 parent()->insertAfter(t, this);-
3403-
3404 return t;-
3405}-
3406-
3407void QDomTextPrivate::save(QTextStream& s, int, int) const-
3408{-
3409 QDomTextPrivate *that = const_cast<QDomTextPrivate*>(this);-
3410 s << encodeText(value, s, !(that->parent() && that->parent()->isElement()), false, true);-
3411}-
3412QDomText::QDomText()-
3413 : QDomCharacterData()-
3414{-
3415}-
3416QDomText::QDomText(const QDomText& x)-
3417 : QDomCharacterData(x)-
3418{-
3419}-
3420-
3421QDomText::QDomText(QDomTextPrivate* n)-
3422 : QDomCharacterData(n)-
3423{-
3424}-
3425QDomText& QDomText::operator= (const QDomText& x)-
3426{-
3427 return (QDomText&) QDomNode::operator=(x);-
3428}-
3429QDomText QDomText::splitText(int offset)-
3430{-
3431 if (!impl)-
3432 return QDomText();-
3433 return QDomText(((QDomTextPrivate*)impl)->splitText(offset));-
3434}-
3435QDomCommentPrivate::QDomCommentPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& val)-
3436 : QDomCharacterDataPrivate(d, parent, val)-
3437{-
3438 name = QLatin1String("#comment");-
3439}-
3440-
3441QDomCommentPrivate::QDomCommentPrivate(QDomCommentPrivate* n, bool deep)-
3442 : QDomCharacterDataPrivate(n, deep)-
3443{-
3444}-
3445-
3446-
3447QDomNodePrivate* QDomCommentPrivate::cloneNode(bool deep)-
3448{-
3449 QDomNodePrivate* p = new QDomCommentPrivate(this, deep);-
3450-
3451 p->ref.deref();-
3452 return p;-
3453}-
3454-
3455void QDomCommentPrivate::save(QTextStream& s, int depth, int indent) const-
3456{-
3457-
3458 if (!(prev && prev->isText()))-
3459 s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));-
3460-
3461 s << "<!--" << value;-
3462 if (value.endsWith(QLatin1Char('-')))-
3463 s << ' ';-
3464 s << "-->";-
3465-
3466 if (!(next && next->isText()))-
3467 s << endl;-
3468}-
3469QDomComment::QDomComment()-
3470 : QDomCharacterData()-
3471{-
3472}-
3473QDomComment::QDomComment(const QDomComment& x)-
3474 : QDomCharacterData(x)-
3475{-
3476}-
3477-
3478QDomComment::QDomComment(QDomCommentPrivate* n)-
3479 : QDomCharacterData(n)-
3480{-
3481}-
3482QDomComment& QDomComment::operator= (const QDomComment& x)-
3483{-
3484 return (QDomComment&) QDomNode::operator=(x);-
3485}-
3486QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,-
3487 const QString& val)-
3488 : QDomTextPrivate(d, parent, val)-
3489{-
3490 name = QLatin1String("#cdata-section");-
3491}-
3492-
3493QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomCDATASectionPrivate* n, bool deep)-
3494 : QDomTextPrivate(n, deep)-
3495{-
3496}-
3497-
3498QDomNodePrivate* QDomCDATASectionPrivate::cloneNode(bool deep)-
3499{-
3500 QDomNodePrivate* p = new QDomCDATASectionPrivate(this, deep);-
3501-
3502 p->ref.deref();-
3503 return p;-
3504}-
3505-
3506void QDomCDATASectionPrivate::save(QTextStream& s, int, int) const-
3507{-
3508-
3509-
3510 s << "<![CDATA[" << value << "]]>";-
3511}-
3512QDomCDATASection::QDomCDATASection()-
3513 : QDomText()-
3514{-
3515}-
3516QDomCDATASection::QDomCDATASection(const QDomCDATASection& x)-
3517 : QDomText(x)-
3518{-
3519}-
3520-
3521QDomCDATASection::QDomCDATASection(QDomCDATASectionPrivate* n)-
3522 : QDomText(n)-
3523{-
3524}-
3525QDomCDATASection& QDomCDATASection::operator= (const QDomCDATASection& x)-
3526{-
3527 return (QDomCDATASection&) QDomNode::operator=(x);-
3528}-
3529QDomNotationPrivate::QDomNotationPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,-
3530 const QString& aname,-
3531 const QString& pub, const QString& sys)-
3532 : QDomNodePrivate(d, parent)-
3533{-
3534 name = aname;-
3535 m_pub = pub;-
3536 m_sys = sys;-
3537}-
3538-
3539QDomNotationPrivate::QDomNotationPrivate(QDomNotationPrivate* n, bool deep)-
3540 : QDomNodePrivate(n, deep)-
3541{-
3542 m_sys = n->m_sys;-
3543 m_pub = n->m_pub;-
3544}-
3545-
3546QDomNodePrivate* QDomNotationPrivate::cloneNode(bool deep)-
3547{-
3548 QDomNodePrivate* p = new QDomNotationPrivate(this, deep);-
3549-
3550 p->ref.deref();-
3551 return p;-
3552}-
3553-
3554void QDomNotationPrivate::save(QTextStream& s, int, int) const-
3555{-
3556 s << "<!NOTATION " << name << ' ';-
3557 if (!m_pub.isNull()) {-
3558 s << "PUBLIC " << quotedValue(m_pub);-
3559 if (!m_sys.isNull())-
3560 s << ' ' << quotedValue(m_sys);-
3561 } else {-
3562 s << "SYSTEM " << quotedValue(m_sys);-
3563 }-
3564 s << '>' << endl;-
3565}-
3566QDomNotation::QDomNotation()-
3567 : QDomNode()-
3568{-
3569}-
3570QDomNotation::QDomNotation(const QDomNotation& x)-
3571 : QDomNode(x)-
3572{-
3573}-
3574-
3575QDomNotation::QDomNotation(QDomNotationPrivate* n)-
3576 : QDomNode(n)-
3577{-
3578}-
3579QDomNotation& QDomNotation::operator= (const QDomNotation& x)-
3580{-
3581 return (QDomNotation&) QDomNode::operator=(x);-
3582}-
3583QString QDomNotation::publicId() const-
3584{-
3585 if (!impl)-
3586 return QString();-
3587 return ((QDomNotationPrivate*)impl)->m_pub;-
3588}-
3589-
3590-
3591-
3592-
3593QString QDomNotation::systemId() const-
3594{-
3595 if (!impl)-
3596 return QString();-
3597 return ((QDomNotationPrivate*)impl)->m_sys;-
3598}-
3599QDomEntityPrivate::QDomEntityPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,-
3600 const QString& aname,-
3601 const QString& pub, const QString& sys, const QString& notation)-
3602 : QDomNodePrivate(d, parent)-
3603{-
3604 name = aname;-
3605 m_pub = pub;-
3606 m_sys = sys;-
3607 m_notationName = notation;-
3608}-
3609-
3610QDomEntityPrivate::QDomEntityPrivate(QDomEntityPrivate* n, bool deep)-
3611 : QDomNodePrivate(n, deep)-
3612{-
3613 m_sys = n->m_sys;-
3614 m_pub = n->m_pub;-
3615 m_notationName = n->m_notationName;-
3616}-
3617-
3618QDomNodePrivate* QDomEntityPrivate::cloneNode(bool deep)-
3619{-
3620 QDomNodePrivate* p = new QDomEntityPrivate(this, deep);-
3621-
3622 p->ref.deref();-
3623 return p;-
3624}-
3625-
3626-
3627-
3628-
3629static QByteArray encodeEntity(const QByteArray& str)-
3630{-
3631 QByteArray tmp(str);-
3632 int len = tmp.size();-
3633 int i = 0;-
3634 const char* d = tmp.constData();-
3635 while (i < len) {-
3636 if (d[i] == '%'){-
3637 tmp.replace(i, 1, "&#60;");-
3638 d = tmp.constData();-
3639 len += 4;-
3640 i += 5;-
3641 }-
3642 else if (d[i] == '"') {-
3643 tmp.replace(i, 1, "&#34;");-
3644 d = tmp.constData();-
3645 len += 4;-
3646 i += 5;-
3647 } else if (d[i] == '&' && i + 1 < len && d[i+1] == '#') {-
3648-
3649-
3650 tmp.replace(i, 1, "&#38;");-
3651 d = tmp.constData();-
3652 len += 4;-
3653 i += 5;-
3654 } else {-
3655 ++i;-
3656 }-
3657 }-
3658-
3659 return tmp;-
3660}-
3661-
3662void QDomEntityPrivate::save(QTextStream& s, int, int) const-
3663{-
3664 QString _name = name;-
3665 if (_name.startsWith(QLatin1Char('%')))-
3666 _name = QLatin1String("% ") + _name.mid(1);-
3667-
3668 if (m_sys.isNull() && m_pub.isNull()) {-
3669 s << "<!ENTITY " << _name << " \"" << encodeEntity(value.toUtf8()) << "\">" << endl;-
3670 } else {-
3671 s << "<!ENTITY " << _name << ' ';-
3672 if (m_pub.isNull()) {-
3673 s << "SYSTEM " << quotedValue(m_sys);-
3674 } else {-
3675 s << "PUBLIC " << quotedValue(m_pub) << ' ' << quotedValue(m_sys);-
3676 }-
3677 if (! m_notationName.isNull()) {-
3678 s << " NDATA " << m_notationName;-
3679 }-
3680 s << '>' << endl;-
3681 }-
3682}-
3683QDomEntity::QDomEntity()-
3684 : QDomNode()-
3685{-
3686}-
3687QDomEntity::QDomEntity(const QDomEntity& x)-
3688 : QDomNode(x)-
3689{-
3690}-
3691-
3692QDomEntity::QDomEntity(QDomEntityPrivate* n)-
3693 : QDomNode(n)-
3694{-
3695}-
3696QDomEntity& QDomEntity::operator= (const QDomEntity& x)-
3697{-
3698 return (QDomEntity&) QDomNode::operator=(x);-
3699}-
3700QString QDomEntity::publicId() const-
3701{-
3702 if (!impl)-
3703 return QString();-
3704 return ((QDomEntityPrivate*)impl)->m_pub;-
3705}-
3706-
3707-
3708-
3709-
3710-
3711QString QDomEntity::systemId() const-
3712{-
3713 if (!impl)-
3714 return QString();-
3715 return ((QDomEntityPrivate*)impl)->m_sys;-
3716}-
3717-
3718-
3719-
3720-
3721-
3722-
3723QString QDomEntity::notationName() const-
3724{-
3725 if (!impl)-
3726 return QString();-
3727 return ((QDomEntityPrivate*)impl)->m_notationName;-
3728}-
3729QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent, const QString& aname)-
3730 : QDomNodePrivate(d, parent)-
3731{-
3732 name = aname;-
3733}-
3734-
3735QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomNodePrivate* n, bool deep)-
3736 : QDomNodePrivate(n, deep)-
3737{-
3738}-
3739-
3740QDomNodePrivate* QDomEntityReferencePrivate::cloneNode(bool deep)-
3741{-
3742 QDomNodePrivate* p = new QDomEntityReferencePrivate(this, deep);-
3743-
3744 p->ref.deref();-
3745 return p;-
3746}-
3747-
3748void QDomEntityReferencePrivate::save(QTextStream& s, int, int) const-
3749{-
3750 s << '&' << name << ';';-
3751}-
3752QDomEntityReference::QDomEntityReference()-
3753 : QDomNode()-
3754{-
3755}-
3756QDomEntityReference::QDomEntityReference(const QDomEntityReference& x)-
3757 : QDomNode(x)-
3758{-
3759}-
3760-
3761QDomEntityReference::QDomEntityReference(QDomEntityReferencePrivate* n)-
3762 : QDomNode(n)-
3763{-
3764}-
3765QDomEntityReference& QDomEntityReference::operator= (const QDomEntityReference& x)-
3766{-
3767 return (QDomEntityReference&) QDomNode::operator=(x);-
3768}-
3769QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomDocumentPrivate* d,-
3770 QDomNodePrivate* parent, const QString& target, const QString& data)-
3771 : QDomNodePrivate(d, parent)-
3772{-
3773 name = target;-
3774 value = data;-
3775}-
3776-
3777QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomProcessingInstructionPrivate* n, bool deep)-
3778 : QDomNodePrivate(n, deep)-
3779{-
3780}-
3781-
3782-
3783QDomNodePrivate* QDomProcessingInstructionPrivate::cloneNode(bool deep)-
3784{-
3785 QDomNodePrivate* p = new QDomProcessingInstructionPrivate(this, deep);-
3786-
3787 p->ref.deref();-
3788 return p;-
3789}-
3790-
3791void QDomProcessingInstructionPrivate::save(QTextStream& s, int, int) const-
3792{-
3793 s << "<?" << name << ' ' << value << "?>" << endl;-
3794}-
3795QDomProcessingInstruction::QDomProcessingInstruction()-
3796 : QDomNode()-
3797{-
3798}-
3799QDomProcessingInstruction::QDomProcessingInstruction(const QDomProcessingInstruction& x)-
3800 : QDomNode(x)-
3801{-
3802}-
3803-
3804QDomProcessingInstruction::QDomProcessingInstruction(QDomProcessingInstructionPrivate* n)-
3805 : QDomNode(n)-
3806{-
3807}-
3808QDomProcessingInstruction& QDomProcessingInstruction::operator= (const QDomProcessingInstruction& x)-
3809{-
3810 return (QDomProcessingInstruction&) QDomNode::operator=(x);-
3811}-
3812QString QDomProcessingInstruction::target() const-
3813{-
3814 if (!impl)-
3815 return QString();-
3816 return impl->nodeName();-
3817}-
3818-
3819-
3820-
3821-
3822-
3823-
3824QString QDomProcessingInstruction::data() const-
3825{-
3826 if (!impl)-
3827 return QString();-
3828 return impl->nodeValue();-
3829}-
3830-
3831-
3832-
3833-
3834-
3835-
3836void QDomProcessingInstruction::setData(const QString& d)-
3837{-
3838 if (!impl)-
3839 return;-
3840 impl->setNodeValue(d);-
3841}-
3842-
3843-
3844-
3845-
3846-
3847-
3848-
3849QDomDocumentPrivate::QDomDocumentPrivate()-
3850 : QDomNodePrivate(0),-
3851 impl(new QDomImplementationPrivate),-
3852 nodeListTime(1)-
3853{-
3854 type = new QDomDocumentTypePrivate(this, this);-
3855 type->ref.deref();-
3856-
3857 name = QLatin1String("#document");-
3858}-
3859-
3860QDomDocumentPrivate::QDomDocumentPrivate(const QString& aname)-
3861 : QDomNodePrivate(0),-
3862 impl(new QDomImplementationPrivate),-
3863 nodeListTime(1)-
3864{-
3865 type = new QDomDocumentTypePrivate(this, this);-
3866 type->ref.deref();-
3867 type->name = aname;-
3868-
3869 name = QLatin1String("#document");-
3870}-
3871-
3872QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt)-
3873 : QDomNodePrivate(0),-
3874 impl(new QDomImplementationPrivate),-
3875 nodeListTime(1)-
3876{-
3877 if (dt != 0) {-
3878 type = dt;-
3879 } else {-
3880 type = new QDomDocumentTypePrivate(this, this);-
3881 type->ref.deref();-
3882 }-
3883-
3884 name = QLatin1String("#document");-
3885}-
3886-
3887QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentPrivate* n, bool deep)-
3888 : QDomNodePrivate(n, deep),-
3889 impl(n->impl->clone()),-
3890 nodeListTime(1)-
3891{-
3892 type = static_cast<QDomDocumentTypePrivate*>(n->type->cloneNode());-
3893 type->setParent(this);-
3894}-
3895-
3896QDomDocumentPrivate::~QDomDocumentPrivate()-
3897{-
3898}-
3899-
3900void QDomDocumentPrivate::clear()-
3901{-
3902 impl.reset();-
3903 type.reset();-
3904 QDomNodePrivate::clear();-
3905}-
3906-
3907static void initializeReader(QXmlSimpleReader &reader, bool namespaceProcessing)-
3908{-
3909 reader.setFeature(QLatin1String("http://xml.org/sax/features/namespaces"), namespaceProcessing);-
3910 reader.setFeature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"), !namespaceProcessing);-
3911 reader.setFeature(QLatin1String("http://trolltech.com/xml/features/report-whitespace-only-CharData"), false);-
3912}-
3913-
3914bool QDomDocumentPrivate::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)-
3915{-
3916 QXmlSimpleReader reader;-
3917 initializeReader(reader, namespaceProcessing);-
3918 return setContent(source, &reader, &reader, errorMsg, errorLine, errorColumn);-
3919}-
3920-
3921bool QDomDocumentPrivate::setContent(QXmlInputSource *source, QXmlReader *reader, QXmlSimpleReader *simpleReader, QString *errorMsg, int *errorLine, int *errorColumn)-
3922{-
3923 clear();-
3924 impl = new QDomImplementationPrivate;-
3925 type = new QDomDocumentTypePrivate(this, this);-
3926 type->ref.deref();-
3927-
3928 bool namespaceProcessing = reader->feature(QLatin1String("http://xml.org/sax/features/namespaces"))-
3929 && !reader->feature(QLatin1String("http://xml.org/sax/features/namespace-prefixes"));-
3930-
3931 QDomHandler hnd(this, simpleReader, namespaceProcessing);-
3932 reader->setContentHandler(&hnd);-
3933 reader->setErrorHandler(&hnd);-
3934 reader->setLexicalHandler(&hnd);-
3935 reader->setDeclHandler(&hnd);-
3936 reader->setDTDHandler(&hnd);-
3937-
3938 if (!reader->parse(source)) {-
3939 if (errorMsg)-
3940 *errorMsg = hnd.errorMsg;-
3941 if (errorLine)-
3942 *errorLine = hnd.errorLine;-
3943 if (errorColumn)-
3944 *errorColumn = hnd.errorColumn;-
3945 return false;-
3946 }-
3947-
3948 return true;-
3949}-
3950-
3951QDomNodePrivate* QDomDocumentPrivate::cloneNode(bool deep)-
3952{-
3953 QDomNodePrivate *p = new QDomDocumentPrivate(this, deep);-
3954-
3955 p->ref.deref();-
3956 return p;-
3957}-
3958-
3959QDomElementPrivate* QDomDocumentPrivate::documentElement()-
3960{-
3961 QDomNodePrivate *p = first;-
3962 while (p && !p->isElement())-
3963 p = p->next;-
3964-
3965 return static_cast<QDomElementPrivate *>(p);-
3966}-
3967-
3968QDomElementPrivate* QDomDocumentPrivate::createElement(const QString &tagName)-
3969{-
3970 bool ok;-
3971 QString fixedName = fixedXmlName(tagName, &ok);-
3972 if (!ok)-
3973 return 0;-
3974-
3975 QDomElementPrivate *e = new QDomElementPrivate(this, 0, fixedName);-
3976 e->ref.deref();-
3977 return e;-
3978}-
3979-
3980QDomElementPrivate* QDomDocumentPrivate::createElementNS(const QString &nsURI, const QString &qName)-
3981{-
3982 bool ok;-
3983 QString fixedName = fixedXmlName(qName, &ok, true);-
3984 if (!ok)-
3985 return 0;-
3986-
3987 QDomElementPrivate *e = new QDomElementPrivate(this, 0, nsURI, fixedName);-
3988 e->ref.deref();-
3989 return e;-
3990}-
3991-
3992QDomDocumentFragmentPrivate* QDomDocumentPrivate::createDocumentFragment()-
3993{-
3994 QDomDocumentFragmentPrivate *f = new QDomDocumentFragmentPrivate(this, (QDomNodePrivate*)0);-
3995 f->ref.deref();-
3996 return f;-
3997}-
3998-
3999QDomTextPrivate* QDomDocumentPrivate::createTextNode(const QString &data)-
4000{-
4001 bool ok;-
4002 QString fixedData = fixedCharData(data, &ok);-
4003 if (!ok)-
4004 return 0;-
4005-
4006 QDomTextPrivate *t = new QDomTextPrivate(this, 0, fixedData);-
4007 t->ref.deref();-
4008 return t;-
4009}-
4010-
4011QDomCommentPrivate* QDomDocumentPrivate::createComment(const QString &data)-
4012{-
4013 bool ok;-
4014 QString fixedData = fixedComment(data, &ok);-
4015 if (!ok)-
4016 return 0;-
4017-
4018 QDomCommentPrivate *c = new QDomCommentPrivate(this, 0, fixedData);-
4019 c->ref.deref();-
4020 return c;-
4021}-
4022-
4023QDomCDATASectionPrivate* QDomDocumentPrivate::createCDATASection(const QString &data)-
4024{-
4025 bool ok;-
4026 QString fixedData = fixedCDataSection(data, &ok);-
4027 if (!ok)-
4028 return 0;-
4029-
4030 QDomCDATASectionPrivate *c = new QDomCDATASectionPrivate(this, 0, fixedData);-
4031 c->ref.deref();-
4032 return c;-
4033}-
4034-
4035QDomProcessingInstructionPrivate* QDomDocumentPrivate::createProcessingInstruction(const QString &target,-
4036 const QString &data)-
4037{-
4038 bool ok;-
4039 QString fixedData = fixedPIData(data, &ok);-
4040 if (!ok)-
4041 return 0;-
4042-
4043 QString fixedTarget = fixedXmlName(target, &ok);-
4044 if (!ok)-
4045 return 0;-
4046-
4047 QDomProcessingInstructionPrivate *p = new QDomProcessingInstructionPrivate(this, 0, fixedTarget, fixedData);-
4048 p->ref.deref();-
4049 return p;-
4050}-
4051QDomAttrPrivate* QDomDocumentPrivate::createAttribute(const QString &aname)-
4052{-
4053 bool ok;-
4054 QString fixedName = fixedXmlName(aname, &ok);-
4055 if (!ok)-
4056 return 0;-
4057-
4058 QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, fixedName);-
4059 a->ref.deref();-
4060 return a;-
4061}-
4062-
4063QDomAttrPrivate* QDomDocumentPrivate::createAttributeNS(const QString &nsURI, const QString &qName)-
4064{-
4065 bool ok;-
4066 QString fixedName = fixedXmlName(qName, &ok, true);-
4067 if (!ok)-
4068 return 0;-
4069-
4070 QDomAttrPrivate *a = new QDomAttrPrivate(this, 0, nsURI, fixedName);-
4071 a->ref.deref();-
4072 return a;-
4073}-
4074-
4075QDomEntityReferencePrivate* QDomDocumentPrivate::createEntityReference(const QString &aname)-
4076{-
4077 bool ok;-
4078 QString fixedName = fixedXmlName(aname, &ok);-
4079 if (!ok)-
4080 return 0;-
4081-
4082 QDomEntityReferencePrivate *e = new QDomEntityReferencePrivate(this, 0, fixedName);-
4083 e->ref.deref();-
4084 return e;-
4085}-
4086-
4087QDomNodePrivate* QDomDocumentPrivate::importNode(QDomNodePrivate *importedNode, bool deep)-
4088{-
4089 QDomNodePrivate *node = 0;-
4090 switch (importedNode->nodeType()) {-
4091 case QDomNode::AttributeNode:-
4092 node = new QDomAttrPrivate((QDomAttrPrivate*)importedNode, true);-
4093 break;-
4094 case QDomNode::DocumentFragmentNode:-
4095 node = new QDomDocumentFragmentPrivate((QDomDocumentFragmentPrivate*)importedNode, deep);-
4096 break;-
4097 case QDomNode::ElementNode:-
4098 node = new QDomElementPrivate((QDomElementPrivate*)importedNode, deep);-
4099 break;-
4100 case QDomNode::EntityNode:-
4101 node = new QDomEntityPrivate((QDomEntityPrivate*)importedNode, deep);-
4102 break;-
4103 case QDomNode::EntityReferenceNode:-
4104 node = new QDomEntityReferencePrivate((QDomEntityReferencePrivate*)importedNode, false);-
4105 break;-
4106 case QDomNode::NotationNode:-
4107 node = new QDomNotationPrivate((QDomNotationPrivate*)importedNode, deep);-
4108 break;-
4109 case QDomNode::ProcessingInstructionNode:-
4110 node = new QDomProcessingInstructionPrivate((QDomProcessingInstructionPrivate*)importedNode, deep);-
4111 break;-
4112 case QDomNode::TextNode:-
4113 node = new QDomTextPrivate((QDomTextPrivate*)importedNode, deep);-
4114 break;-
4115 case QDomNode::CDATASectionNode:-
4116 node = new QDomCDATASectionPrivate((QDomCDATASectionPrivate*)importedNode, deep);-
4117 break;-
4118 case QDomNode::CommentNode:-
4119 node = new QDomCommentPrivate((QDomCommentPrivate*)importedNode, deep);-
4120 break;-
4121 default:-
4122 break;-
4123 }-
4124 if (node) {-
4125 node->setOwnerDocument(this);-
4126-
4127-
4128 node->ref.deref();-
4129 }-
4130 return node;-
4131}-
4132-
4133void QDomDocumentPrivate::saveDocument(QTextStream& s, const int indent, QDomNode::EncodingPolicy encUsed) const-
4134{-
4135 const QDomNodePrivate* n = first;-
4136-
4137 if(encUsed == QDomNode::EncodingFromDocument) {-
4138-
4139 const QDomNodePrivate* n = first;-
4140-
4141 QTextCodec *codec = 0;-
4142-
4143 if (n && n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) {-
4144-
4145 QString data = n->nodeValue();-
4146 QRegExp encoding(QString::fromLatin1("encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))"));-
4147 encoding.indexIn(data);-
4148 QString enc = encoding.cap(3);-
4149 if (enc.isEmpty())-
4150 enc = encoding.cap(5);-
4151 if (!enc.isEmpty())-
4152 codec = QTextCodec::codecForName(enc.toLatin1().data());-
4153 }-
4154 if (!codec)-
4155 codec = QTextCodec::codecForName("UTF-8");-
4156 if (codec)-
4157 s.setCodec(codec);-
4158-
4159 bool doc = false;-
4160-
4161 while (n) {-
4162 if (!doc && !(n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml"))) {-
4163-
4164 type->save(s, 0, indent);-
4165 doc = true;-
4166 }-
4167 n->save(s, 0, indent);-
4168 n = n->next;-
4169 }-
4170 }-
4171 else {-
4172-
4173-
4174-
4175-
4176-
4177 const QTextCodec *const codec = s.codec();-
4178 ((!(codec)) ? qt_assert_x("QDomNode::save()", "A codec must be specified in the text stream.",__FILE__,64656471) : qt_noop());-
4179 const QByteArray codecName = codec->name();-
4180-
4181-
4182 s << "<?xml version=\"1.0\" encoding=\""-
4183 << codecName-
4184 << "\"?>\n";-
4185-
4186-
4187 const QDomNodePrivate* startNode = n;-
4188-
4189-
4190 while (n) {-
4191 if(n->isProcessingInstruction() && n->nodeName() == QLatin1String("xml")) {-
4192 startNode = n->next;-
4193 break;-
4194 }-
4195 else-
4196 n = n->next;-
4197 }-
4198-
4199-
4200 while(startNode) {-
4201 startNode->save(s, 0, indent);-
4202 startNode = startNode->next;-
4203 }-
4204 }-
4205}-
4206QDomDocument::QDomDocument()-
4207{-
4208 impl = 0;-
4209}-
4210-
4211-
4212-
4213-
4214-
4215QDomDocument::QDomDocument(const QString& name)-
4216{-
4217-
4218 impl = new QDomDocumentPrivate(name);-
4219}-
4220-
4221-
4222-
4223-
4224-
4225-
4226QDomDocument::QDomDocument(const QDomDocumentType& doctype)-
4227{-
4228 impl = new QDomDocumentPrivate((QDomDocumentTypePrivate*)(doctype.impl));-
4229}-
4230QDomDocument::QDomDocument(const QDomDocument& x)-
4231 : QDomNode(x)-
4232{-
4233}-
4234-
4235QDomDocument::QDomDocument(QDomDocumentPrivate* x)-
4236 : QDomNode(x)-
4237{-
4238}-
4239QDomDocument& QDomDocument::operator= (const QDomDocument& x)-
4240{-
4241 return (QDomDocument&) QDomNode::operator=(x);-
4242}-
4243-
4244-
4245-
4246-
4247QDomDocument::~QDomDocument()-
4248{-
4249}-
4250bool QDomDocument::setContent(const QString& text, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)-
4251{-
4252 if (!impl)-
4253 impl = new QDomDocumentPrivate();-
4254 QXmlInputSource source;-
4255 source.setData(text);-
4256 return ((QDomDocumentPrivate*)impl)->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);-
4257}-
4258bool QDomDocument::setContent(const QByteArray &data, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)-
4259{-
4260 if (!impl)-
4261 impl = new QDomDocumentPrivate();-
4262 QBuffer buf;-
4263 buf.setData(data);-
4264 QXmlInputSource source(&buf);-
4265 return ((QDomDocumentPrivate*)impl)->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);-
4266}-
4267-
4268-
4269-
4270-
4271-
4272-
4273-
4274bool QDomDocument::setContent(QIODevice* dev, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn)-
4275{-
4276 if (!impl)-
4277 impl = new QDomDocumentPrivate();-
4278 QXmlInputSource source(dev);-
4279 return ((QDomDocumentPrivate*)impl)->setContent(&source, namespaceProcessing, errorMsg, errorLine, errorColumn);-
4280}-
4281bool QDomDocument::setContent(QXmlInputSource *source, bool namespaceProcessing, QString *errorMsg, int *errorLine, int *errorColumn )-
4282{-
4283 if (!impl)-
4284 impl = new QDomDocumentPrivate();-
4285 QXmlSimpleReader reader;-
4286 initializeReader(reader, namespaceProcessing);-
4287 return ((QDomDocumentPrivate*)impl)->setContent(source, &reader, &reader, errorMsg, errorLine, errorColumn);-
4288}-
4289bool QDomDocument::setContent(const QString& text, QString *errorMsg, int *errorLine, int *errorColumn)-
4290{-
4291 return setContent(text, false, errorMsg, errorLine, errorColumn);-
4292}-
4293bool QDomDocument::setContent(const QByteArray& buffer, QString *errorMsg, int *errorLine, int *errorColumn )-
4294{-
4295 return setContent(buffer, false, errorMsg, errorLine, errorColumn);-
4296}-
4297bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg, int *errorLine, int *errorColumn )-
4298{-
4299 return setContent(dev, false, errorMsg, errorLine, errorColumn);-
4300}-
4301bool QDomDocument::setContent(QXmlInputSource *source, QXmlReader *reader, QString *errorMsg, int *errorLine, int *errorColumn )-
4302{-
4303 if (!impl)-
4304 impl = new QDomDocumentPrivate();-
4305 return ((QDomDocumentPrivate*)impl)->setContent(source, reader, 0, errorMsg, errorLine, errorColumn);-
4306}-
4307QString QDomDocument::toString(int indent) const-
4308{-
4309 QString str;-
4310 QTextStream s(&str, QIODevice::WriteOnly);-
4311 save(s, indent);-
4312 return str;-
4313}-
4314QByteArray QDomDocument::toByteArray(int indent) const-
4315{-
4316-
4317-
4318 return toString(indent).toUtf8();-
4319}-
4320-
4321-
4322-
4323-
4324-
4325QDomDocumentType QDomDocument::doctype() const-
4326{-
4327 if (!impl)-
4328 return QDomDocumentType();-
4329 return QDomDocumentType(((QDomDocumentPrivate*)impl)->doctype());-
4330}-
4331-
4332-
4333-
4334-
4335QDomImplementation QDomDocument::implementation() const-
4336{-
4337 if (!impl)-
4338 return QDomImplementation();-
4339 return QDomImplementation(((QDomDocumentPrivate*)impl)->implementation());-
4340}-
4341-
4342-
4343-
4344-
4345QDomElement QDomDocument::documentElement() const-
4346{-
4347 if (!impl)-
4348 return QDomElement();-
4349 return QDomElement(((QDomDocumentPrivate*)impl)->documentElement());-
4350}-
4351QDomElement QDomDocument::createElement(const QString& tagName)-
4352{-
4353 if (!impl)-
4354 impl = new QDomDocumentPrivate();-
4355 return QDomElement(((QDomDocumentPrivate*)impl)->createElement(tagName));-
4356}-
4357-
4358-
4359-
4360-
4361-
4362-
4363QDomDocumentFragment QDomDocument::createDocumentFragment()-
4364{-
4365 if (!impl)-
4366 impl = new QDomDocumentPrivate();-
4367 return QDomDocumentFragment(((QDomDocumentPrivate*)impl)->createDocumentFragment());-
4368}-
4369QDomText QDomDocument::createTextNode(const QString& value)-
4370{-
4371 if (!impl)-
4372 impl = new QDomDocumentPrivate();-
4373 return QDomText(((QDomDocumentPrivate*)impl)->createTextNode(value));-
4374}-
4375QDomComment QDomDocument::createComment(const QString& value)-
4376{-
4377 if (!impl)-
4378 impl = new QDomDocumentPrivate();-
4379 return QDomComment(((QDomDocumentPrivate*)impl)->createComment(value));-
4380}-
4381QDomCDATASection QDomDocument::createCDATASection(const QString& value)-
4382{-
4383 if (!impl)-
4384 impl = new QDomDocumentPrivate();-
4385 return QDomCDATASection(((QDomDocumentPrivate*)impl)->createCDATASection(value));-
4386}-
4387QDomProcessingInstruction QDomDocument::createProcessingInstruction(const QString& target,-
4388 const QString& data)-
4389{-
4390 if (!impl)-
4391 impl = new QDomDocumentPrivate();-
4392 return QDomProcessingInstruction(((QDomDocumentPrivate*)impl)->createProcessingInstruction(target, data));-
4393}-
4394QDomAttr QDomDocument::createAttribute(const QString& name)-
4395{-
4396 if (!impl)-
4397 impl = new QDomDocumentPrivate();-
4398 return QDomAttr(((QDomDocumentPrivate*)impl)->createAttribute(name));-
4399}-
4400QDomEntityReference QDomDocument::createEntityReference(const QString& name)-
4401{-
4402 if (!impl)-
4403 impl = new QDomDocumentPrivate();-
4404 return QDomEntityReference(((QDomDocumentPrivate*)impl)->createEntityReference(name));-
4405}-
4406QDomNodeList QDomDocument::elementsByTagName(const QString& tagname) const-
4407{-
4408 return QDomNodeList(new QDomNodeListPrivate(impl, tagname));-
4409}-
4410QDomNode QDomDocument::importNode(const QDomNode& importedNode, bool deep)-
4411{-
4412 if (importedNode.isNull())-
4413 return QDomNode();-
4414 if (!impl)-
4415 impl = new QDomDocumentPrivate();-
4416 return QDomNode(((QDomDocumentPrivate*)impl)->importNode(importedNode.impl, deep));-
4417}-
4418QDomElement QDomDocument::createElementNS(const QString& nsURI, const QString& qName)-
4419{-
4420 if (!impl)-
4421 impl = new QDomDocumentPrivate();-
4422 return QDomElement(((QDomDocumentPrivate*)impl)->createElementNS(nsURI, qName));-
4423}-
4424QDomAttr QDomDocument::createAttributeNS(const QString& nsURI, const QString& qName)-
4425{-
4426 if (!impl)-
4427 impl = new QDomDocumentPrivate();-
4428 return QDomAttr(((QDomDocumentPrivate*)impl)->createAttributeNS(nsURI, qName));-
4429}-
4430QDomNodeList QDomDocument::elementsByTagNameNS(const QString& nsURI, const QString& localName)-
4431{-
4432 return QDomNodeList(new QDomNodeListPrivate(impl, nsURI, localName));-
4433}-
4434QDomElement QDomDocument::elementById(const QString& )-
4435{-
4436 QMessageLogger(__FILE__, 71697175, __PRETTY_FUNCTION__).warning("elementById() is not implemented and will always return a null node.");-
4437 return QDomElement();-
4438}-
4439QDomAttr QDomNode::toAttr() const-
4440{-
4441 if (impl && impl->isAttr())-
4442 return QDomAttr(((QDomAttrPrivate*)impl));-
4443 return QDomAttr();-
4444}-
4445-
4446-
4447-
4448-
4449-
4450-
4451-
4452QDomCDATASection QDomNode::toCDATASection() const-
4453{-
4454 if (impl && impl->isCDATASection())-
4455 return QDomCDATASection(((QDomCDATASectionPrivate*)impl));-
4456 return QDomCDATASection();-
4457}-
4458-
4459-
4460-
4461-
4462-
4463-
4464-
4465QDomDocumentFragment QDomNode::toDocumentFragment() const-
4466{-
4467 if (impl && impl->isDocumentFragment())-
4468 return QDomDocumentFragment(((QDomDocumentFragmentPrivate*)impl));-
4469 return QDomDocumentFragment();-
4470}-
4471-
4472-
4473-
4474-
4475-
4476-
4477-
4478QDomDocument QDomNode::toDocument() const-
4479{-
4480 if (impl && impl->isDocument())-
4481 return QDomDocument(((QDomDocumentPrivate*)impl));-
4482 return QDomDocument();-
4483}-
4484-
4485-
4486-
4487-
4488-
4489-
4490-
4491QDomDocumentType QDomNode::toDocumentType() const-
4492{-
4493 if (impl && impl->isDocumentType())-
4494 return QDomDocumentType(((QDomDocumentTypePrivate*)impl));-
4495 return QDomDocumentType();-
4496}-
4497-
4498-
4499-
4500-
4501-
4502-
4503-
4504QDomElement QDomNode::toElement() const-
4505{-
4506 if (impl && impl->isElement())-
4507 return QDomElement(((QDomElementPrivate*)impl));-
4508 return QDomElement();-
4509}-
4510-
4511-
4512-
4513-
4514-
4515-
4516-
4517QDomEntityReference QDomNode::toEntityReference() const-
4518{-
4519 if (impl && impl->isEntityReference())-
4520 return QDomEntityReference(((QDomEntityReferencePrivate*)impl));-
4521 return QDomEntityReference();-
4522}-
4523-
4524-
4525-
4526-
4527-
4528-
4529-
4530QDomText QDomNode::toText() const-
4531{-
4532 if (impl && impl->isText())-
4533 return QDomText(((QDomTextPrivate*)impl));-
4534 return QDomText();-
4535}-
4536-
4537-
4538-
4539-
4540-
4541-
4542-
4543QDomEntity QDomNode::toEntity() const-
4544{-
4545 if (impl && impl->isEntity())-
4546 return QDomEntity(((QDomEntityPrivate*)impl));-
4547 return QDomEntity();-
4548}-
4549-
4550-
4551-
4552-
4553-
4554-
4555-
4556QDomNotation QDomNode::toNotation() const-
4557{-
4558 if (impl && impl->isNotation())-
4559 return QDomNotation(((QDomNotationPrivate*)impl));-
4560 return QDomNotation();-
4561}-
4562-
4563-
4564-
4565-
4566-
4567-
4568-
4569QDomProcessingInstruction QDomNode::toProcessingInstruction() const-
4570{-
4571 if (impl && impl->isProcessingInstruction())-
4572 return QDomProcessingInstruction(((QDomProcessingInstructionPrivate*)impl));-
4573 return QDomProcessingInstruction();-
4574}-
4575-
4576-
4577-
4578-
4579-
4580-
4581-
4582QDomCharacterData QDomNode::toCharacterData() const-
4583{-
4584 if (impl && impl->isCharacterData())-
4585 return QDomCharacterData(((QDomCharacterDataPrivate*)impl));-
4586 return QDomCharacterData();-
4587}-
4588-
4589-
4590-
4591-
4592-
4593-
4594-
4595QDomComment QDomNode::toComment() const-
4596{-
4597 if (impl && impl->isComment())-
4598 return QDomComment(((QDomCommentPrivate*)impl));-
4599 return QDomComment();-
4600}-
4601-
4602-
4603-
4604-
4605-
4606-
4607-
4608QDomHandler::QDomHandler(QDomDocumentPrivate* adoc, QXmlSimpleReader* areader, bool namespaceProcessing)-
4609 : errorLine(0), errorColumn(0), doc(adoc), node(adoc), cdata(false),-
4610 nsProcessing(namespaceProcessing), locator(0), reader(areader)-
4611{-
4612}-
4613-
4614QDomHandler::~QDomHandler()-
4615{-
4616}-
4617-
4618bool QDomHandler::endDocument()-
4619{-
4620-
4621 if (node != doc)-
4622 return false;-
4623 return true;-
4624}-
4625-
4626bool QDomHandler::startDTD(const QString& name, const QString& publicId, const QString& systemId)-
4627{-
4628 doc->doctype()->name = name;-
4629 doc->doctype()->publicId = publicId;-
4630 doc->doctype()->systemId = systemId;-
4631 return true;-
4632}-
4633-
4634bool QDomHandler::startElement(const QString& nsURI, const QString&, const QString& qName, const QXmlAttributes& atts)-
4635{-
4636-
4637 QDomNodePrivate* n;-
4638 if (nsProcessing) {-
4639 n = doc->createElementNS(nsURI, qName);-
4640 } else {-
4641 n = doc->createElement(qName);-
4642 }-
4643-
4644 if (!n)-
4645 return false;-
4646-
4647 n->setLocation(locator->lineNumber(), locator->columnNumber());-
4648-
4649 node->appendChild(n);-
4650 node = n;-
4651-
4652-
4653 for (int i=0; i<atts.length(); i++)-
4654 {-
4655 if (nsProcessing) {-
4656 ((QDomElementPrivate*)node)->setAttributeNS(atts.uri(i), atts.qName(i), atts.value(i));-
4657 } else {-
4658 ((QDomElementPrivate*)node)->setAttribute(atts.qName(i), atts.value(i));-
4659 }-
4660 }-
4661-
4662 return true;-
4663}-
4664-
4665bool QDomHandler::endElement(const QString&, const QString&, const QString&)-
4666{-
4667 if (!node || node == doc)-
4668 return false;-
4669 node = node->parent();-
4670-
4671 return true;-
4672}-
4673-
4674bool QDomHandler::characters(const QString& ch)-
4675{-
4676-
4677 if (node == doc)-
4678 return false;-
4679-
4680 QScopedPointer<QDomNodePrivate> n;-
4681 if (cdata) {-
4682 n.reset(doc->createCDATASection(ch));-
4683 } else if (!entityName.isEmpty()) {-
4684 QScopedPointer<QDomEntityPrivate> e(new QDomEntityPrivate(doc, 0, entityName,-
4685 QString(), QString(), QString()));-
4686 e->value = ch;-
4687 e->ref.deref();-
4688 doc->doctype()->appendChild(e.data());-
4689 e.take();-
4690 n.reset(doc->createEntityReference(entityName));-
4691 } else {-
4692 n.reset(doc->createTextNode(ch));-
4693 }-
4694 n->setLocation(locator->lineNumber(), locator->columnNumber());-
4695 node->appendChild(n.data());-
4696 n.take();-
4697-
4698 return true;-
4699}-
4700-
4701bool QDomHandler::processingInstruction(const QString& target, const QString& data)-
4702{-
4703 QDomNodePrivate *n;-
4704 n = doc->createProcessingInstruction(target, data);-
4705 if (n) {-
4706 n->setLocation(locator->lineNumber(), locator->columnNumber());-
4707 node->appendChild(n);-
4708 return true;-
4709 }-
4710 else-
4711 return false;-
4712}-
4713-
4714bool QDomHandler::skippedEntity(const QString& name)-
4715{-
4716-
4717 if (reader && !reader->d_ptr->skipped_entity_in_content)-
4718 return true;-
4719-
4720 QDomNodePrivate *n = doc->createEntityReference(name);-
4721 n->setLocation(locator->lineNumber(), locator->columnNumber());-
4722 node->appendChild(n);-
4723 return true;-
4724}-
4725-
4726bool QDomHandler::fatalError(const QXmlParseException& exception)-
4727{-
4728 errorMsg = exception.message();-
4729 errorLine = exception.lineNumber();-
4730 errorColumn = exception.columnNumber();-
4731 return QXmlDefaultHandler::fatalError(exception);-
4732}-
4733-
4734bool QDomHandler::startCDATA()-
4735{-
4736 cdata = true;-
4737 return true;-
4738}-
4739-
4740bool QDomHandler::endCDATA()-
4741{-
4742 cdata = false;-
4743 return true;-
4744}-
4745-
4746bool QDomHandler::startEntity(const QString &name)-
4747{-
4748 entityName = name;-
4749 return true;-
4750}-
4751-
4752bool QDomHandler::endEntity(const QString &)-
4753{-
4754 entityName.clear();-
4755 return true;-
4756}-
4757-
4758bool QDomHandler::comment(const QString& ch)-
4759{-
4760 QDomNodePrivate *n;-
4761 n = doc->createComment(ch);-
4762 n->setLocation(locator->lineNumber(), locator->columnNumber());-
4763 node->appendChild(n);-
4764 return true;-
4765}-
4766-
4767bool QDomHandler::unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, const QString &notationName)-
4768{-
4769 QDomEntityPrivate* e = new QDomEntityPrivate(doc, 0, name,-
4770 publicId, systemId, notationName);-
4771-
4772 e->ref.deref();-
4773 doc->doctype()->appendChild(e);-
4774 return true;-
4775}-
4776-
4777bool QDomHandler::externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId)-
4778{-
4779 return unparsedEntityDecl(name, publicId, systemId, QString());-
4780}-
4781-
4782bool QDomHandler::notationDecl(const QString & name, const QString & publicId, const QString & systemId)-
4783{-
4784 QDomNotationPrivate* n = new QDomNotationPrivate(doc, 0, name, publicId, systemId);-
4785-
4786 n->ref.deref();-
4787 doc->doctype()->appendChild(n);-
4788 return true;-
4789}-
4790-
4791void QDomHandler::setDocumentLocator(QXmlLocator *locator)-
4792{-
4793 this->locator = locator;-
4794}-
4795-
4796-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9