4#include <qplatformdefs.h>
6#include "private/qxmlutils_p.h"
11#include "qdomhelpers_p.h"
16#if QT_CONFIG(regularexpression)
17#include <qregularexpression.h>
19#include <qtextstream.h>
21#include <qshareddata.h>
23#include <qxmlstream.h>
24#include <private/qduplicatetracker_p.h>
25#include <private/qstringiterator_p.h>
26#include <qvarlengtharray.h>
34using namespace Qt::StringLiterals;
37
38
39
40
41
42
43
44
45
46
49
50
51
52
53
54
57
58
59
60
61
62
63
64
65
66
67
71
72
73static void qt_split_namespace(QString& prefix, QString& name,
const QString& qName,
bool hasURI)
75 qsizetype i = qName.indexOf(u':');
83 prefix = qName.left(i);
84 name = qName.mid(i + 1);
89
90
91
92
93QDomImplementation::InvalidDataPolicy QDomImplementationPrivate::invalidDataPolicy
94 = QDomImplementation::AcceptInvalidChars;
98static QString fixedXmlName(
const QString &_name,
bool *ok,
bool namespaces =
false)
100 QString name, prefix;
102 qt_split_namespace(prefix, name, _name,
true);
106 if (name.isEmpty()) {
111 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
117 bool firstChar =
true;
118 for (
int i = 0; i < name.size(); ++i) {
119 QChar c = name.at(i);
121 if (QXmlUtils::isLetter(c) || c.unicode() ==
'_' || c.unicode() ==
':') {
124 }
else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
129 if (QXmlUtils::isNameChar(c))
131 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
138 if (result.isEmpty()) {
144 if (namespaces && !prefix.isEmpty())
145 return prefix + u':' + result;
152static QString fixedCharData(
const QString &data,
bool *ok)
154 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
160 QStringIterator it(data);
161 while (it.hasNext()) {
162 const char32_t c = it.next(QChar::Null);
163 if (QXmlUtils::isChar(c)) {
164 result.append(QChar::fromUcs4(c));
165 }
else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
178static QString fixedComment(
const QString &data,
bool *ok)
180 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
185 QString fixedData = fixedCharData(data, ok);
190 qsizetype idx = fixedData.indexOf(
"--"_L1);
193 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
197 fixedData.remove(idx, 2);
207static QString fixedCDataSection(
const QString &data,
bool *ok)
209 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
214 QString fixedData = fixedCharData(data, ok);
219 qsizetype idx = fixedData.indexOf(
"]]>"_L1);
222 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
226 fixedData.remove(idx, 3);
235static QString fixedPIData(
const QString &data,
bool *ok)
237 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
242 QString fixedData = fixedCharData(data, ok);
247 qsizetype idx = fixedData.indexOf(
"?>"_L1);
250 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
254 fixedData.remove(idx, 2);
264static QString fixedPubidLiteral(
const QString &data,
bool *ok)
266 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
273 if (QXmlUtils::isPublicID(data))
275 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
280 if (result.indexOf(u'\'') != -1 && result.indexOf(u'"') != -1) {
281 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
285 result.remove(u'\'');
296static QString fixedSystemLiteral(
const QString &data,
bool *ok)
298 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
303 QString result = data;
305 if (result.indexOf(u'\'') != -1 && result.indexOf(u'"') != -1) {
306 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
310 result.remove(u'\'');
319
320
321
322
324QDomImplementationPrivate* QDomImplementationPrivate::clone()
326 return new QDomImplementationPrivate;
330
331
332
333
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
369
370
371QDomImplementation::QDomImplementation()
377
378
379QDomImplementation::QDomImplementation(
const QDomImplementation &implementation)
380 : impl(implementation.impl)
386QDomImplementation::QDomImplementation(QDomImplementationPrivate *pimpl)
395
396
397QDomImplementation& QDomImplementation::operator=(
const QDomImplementation &other)
400 other.impl->ref.ref();
401 if (impl && !impl->ref.deref())
408
409
410
411bool QDomImplementation::operator==(
const QDomImplementation &other)
const
413 return impl == other.impl;
417
418
419
420bool QDomImplementation::operator!=(
const QDomImplementation &other)
const
422 return !operator==(other);
426
427
428QDomImplementation::~QDomImplementation()
430 if (impl && !impl->ref.deref())
435
436
437
438
439
440
441
442
443
444bool QDomImplementation::hasFeature(
const QString& feature,
const QString& version)
const
446 if (feature ==
"XML"_L1) {
447 if (version.isEmpty() || version ==
"1.0"_L1)
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486QDomDocumentType QDomImplementation::createDocumentType(
const QString& qName,
const QString& publicId,
const QString& systemId)
489 QString fixedName = fixedXmlName(qName, &ok,
true);
491 return QDomDocumentType();
493 QString fixedPublicId = fixedPubidLiteral(publicId, &ok);
495 return QDomDocumentType();
497 QString fixedSystemId = fixedSystemLiteral(systemId, &ok);
499 return QDomDocumentType();
501 QDomDocumentTypePrivate *dt =
new QDomDocumentTypePrivate(
nullptr);
502 dt->name = fixedName;
503 if (systemId.isNull()) {
504 dt->publicId.clear();
505 dt->systemId.clear();
507 dt->publicId = fixedPublicId;
508 dt->systemId = fixedSystemId;
511 return QDomDocumentType(dt);
515
516
517
518
519QDomDocument QDomImplementation::createDocument(
const QString& nsURI,
const QString& qName,
const QDomDocumentType& doctype)
521 QDomDocument doc(doctype);
522 QDomElement root = doc.createElementNS(nsURI, qName);
524 return QDomDocument();
525 doc.appendChild(root);
530
531
532
533bool QDomImplementation::isNull()
535 return (impl ==
nullptr);
539
540
541
542
543
544
545
546
547
548
549
550
551
554
555
556
557
558
559
560
561
562
563
564
567
568
569
570
571
572
573
574
576QDomImplementation::InvalidDataPolicy QDomImplementation::invalidDataPolicy()
578 return QDomImplementationPrivate::invalidDataPolicy;
582
583
584
585
586
587
588
589
590
591
592
593
594
596void QDomImplementation::setInvalidDataPolicy(InvalidDataPolicy policy)
598 QDomImplementationPrivate::invalidDataPolicy = policy;
602
603
604
605
607QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl) : ref(1)
611 node_impl->ref.ref();
615QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl,
const QString &name) :
620 node_impl->ref.ref();
625QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl,
const QString &_nsURI,
const QString &localName) :
630 node_impl->ref.ref();
636QDomNodeListPrivate::~QDomNodeListPrivate()
638 if (node_impl && !node_impl->ref.deref())
642bool QDomNodeListPrivate::operator==(
const QDomNodeListPrivate &other)
const noexcept
644 return (node_impl == other.node_impl) && (tagname == other.tagname);
647void QDomNodeListPrivate::createList()
const
653 const QDomDocumentPrivate *
const doc = node_impl->ownerDocument();
654 if (doc && timestamp != doc->nodeListTime)
655 timestamp = doc->nodeListTime;
656 forEachNode([&](QDomNodePrivate *p){ list.append(p); });
660
661
662
663
664bool QDomNodeListPrivate::checkNode(QDomNodePrivate *p)
const
666 return p && p->isElement() && (nsURI.isNull()
667 ? p->nodeName() == tagname
668 : p->name == tagname && p->namespaceURI == nsURI);
672
673
674
675
676
677
678
679
680QDomNodePrivate *QDomNodeListPrivate::findNextInOrder(QDomNodePrivate *p)
const
685 if (tagname.isNull()) {
688 else if (p && p->next)
692 if (p == node_impl) {
697 while (p && p != node_impl) {
700 }
else if (p->next) {
704 while (p && p != node_impl && !p->next)
706 if (p && p != node_impl)
716
717
718
719
720
721QDomNodePrivate *QDomNodeListPrivate::findPrevInOrder(QDomNodePrivate *p)
const
726 if (tagname.isNull() && p == node_impl)
728 if (tagname.isNull())
733 if (p == node_impl) {
755void QDomNodeListPrivate::forEachNode(qxp::function_ref<
void(QDomNodePrivate*)> yield)
const
760 QDomNodePrivate *current = findNextInOrder(node_impl);
761 while (current && current != node_impl) {
763 current = findNextInOrder(current);
767bool QDomNodeListPrivate::maybeCreateList()
const
772 const QDomDocumentPrivate *
const doc = node_impl->ownerDocument();
773 if (!doc || timestamp != doc->nodeListTime)
779QDomNodePrivate *QDomNodeListPrivate::item(
int index)
781 if (!maybeCreateList() || index >= list.size() || index < 0)
784 return list.at(index);
787int QDomNodeListPrivate::length()
const
789 if (!maybeCreateList())
795int QDomNodeListPrivate::noexceptLength()
const noexcept
798 forEachNode([&](QDomNodePrivate*){ ++count; });
803
804
805
806
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
834
835
836QDomNodeList::QDomNodeList()
841QDomNodeList::QDomNodeList(QDomNodeListPrivate *pimpl)
847
848
849QDomNodeList::QDomNodeList(
const QDomNodeList &nodeList)
850 : impl(nodeList.impl)
857
858
859QDomNodeList& QDomNodeList::operator=(
const QDomNodeList &other)
862 other.impl->ref.ref();
863 if (impl && !impl->ref.deref())
870
871
872
873
874
875bool comparesEqual(
const QDomNodeList &lhs,
const QDomNodeList &rhs)
noexcept
877 if (lhs.impl == rhs.impl)
879 if (!lhs.impl || !rhs.impl)
881 return *lhs.impl == *rhs.impl;
885
886
887
888
889
892
893
894QDomNodeList::~QDomNodeList()
896 if (impl && !impl->ref.deref())
901
902
903
904
905
906
907
908
909QDomNode QDomNodeList::item(
int index)
const
914 return QDomNode(impl->item(index));
918
919
920int QDomNodeList::length()
const
924 return impl->length();
928
929
930int QDomNodeList::noexceptLength()
const noexcept
934 return impl->noexceptLength();
938
939
940
941
942
945
946
947
948
951
952
953
954
957
958
959
960
961
962
963
964
965
968
969
970
971
972
973
974
975
976
977
980
981
982
983
984
985
986
987
988
989
990
991
992
993
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1015QDomNodeList::It::It(
const QDomNodeListPrivate *lp,
bool start)
noexcept
1018 if (!lp || !lp->node_impl)
1021 current = lp->findNextInOrder(lp->node_impl);
1023 current = lp->node_impl;
1026QDomNodePrivate *QDomNodeList::It::findNextInOrder(
const QDomNodeListPrivate *parent, QDomNodePrivate *current)
1028 return parent->findNextInOrder(current);
1031QDomNodePrivate *QDomNodeList::It::findPrevInOrder(
const QDomNodeListPrivate *parent, QDomNodePrivate *current)
1033 return parent->findPrevInOrder(current);
1037
1038
1039
1040
1042inline void QDomNodePrivate::setOwnerDocument(QDomDocumentPrivate *doc)
1048QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) : ref(1)
1053 setOwnerDocument(doc);
1058 createdWithDom1Interface =
true;
1063QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n,
bool deep) : ref(1)
1065 setOwnerDocument(n->ownerDocument());
1074 namespaceURI = n->namespaceURI;
1075 createdWithDom1Interface = n->createdWithDom1Interface;
1082 for (QDomNodePrivate* x = n->first; x; x = x->next)
1083 appendChild(x->cloneNode(
true));
1086QDomNodePrivate::~QDomNodePrivate()
1088 QDomNodePrivate* p = first;
1093 if (!p->ref.deref())
1103void QDomNodePrivate::clear()
1105 QDomNodePrivate* p = first;
1110 if (!p->ref.deref())
1118QDomNodePrivate* QDomNodePrivate::namedItem(
const QString &n)
1120 QDomNodePrivate* p = first;
1122 if (p->nodeName() == n)
1130QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
1137 if (newChild == refChild)
1141 if (refChild && refChild->parent() !=
this)
1145 QDomDocumentPrivate *
const doc = ownerDocument();
1147 doc->nodeListTime++;
1151 if (newChild->isDocumentFragment()) {
1153 if (newChild->first ==
nullptr)
1157 QDomNodePrivate* n = newChild->first;
1164 if (!refChild || refChild->prev ==
nullptr) {
1166 first->prev = newChild->last;
1167 newChild->last->next = first;
1169 last = newChild->last;
1170 first = newChild->first;
1173 newChild->last->next = refChild;
1174 newChild->first->prev = refChild->prev;
1175 refChild->prev->next = newChild->first;
1176 refChild->prev = newChild->last;
1183 newChild->first =
nullptr;
1184 newChild->last =
nullptr;
1190 newChild->ref.ref();
1192 if (newChild->parent())
1193 newChild->parent()->removeChild(newChild);
1195 newChild->setParent(
this);
1199 first->prev = newChild;
1200 newChild->next = first;
1207 if (refChild->prev ==
nullptr) {
1209 first->prev = newChild;
1210 newChild->next = first;
1217 newChild->next = refChild;
1218 newChild->prev = refChild->prev;
1219 refChild->prev->next = newChild;
1220 refChild->prev = newChild;
1225QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
1232 if (newChild == refChild)
1236 if (refChild && refChild->parent() !=
this)
1240 QDomDocumentPrivate *
const doc = ownerDocument();
1242 doc->nodeListTime++;
1246 if (newChild->isDocumentFragment()) {
1248 if (newChild->first ==
nullptr)
1252 QDomNodePrivate* n = newChild->first;
1259 if (!refChild || refChild->next ==
nullptr) {
1261 last->next = newChild->first;
1262 newChild->first->prev = last;
1264 first = newChild->first;
1265 last = newChild->last;
1267 newChild->first->prev = refChild;
1268 newChild->last->next = refChild->next;
1269 refChild->next->prev = newChild->last;
1270 refChild->next = newChild->first;
1277 newChild->first =
nullptr;
1278 newChild->last =
nullptr;
1283 if (newChild->parent())
1284 newChild->parent()->removeChild(newChild);
1288 newChild->ref.ref();
1290 newChild->setParent(
this);
1295 last->next = newChild;
1296 newChild->prev = last;
1303 if (refChild->next ==
nullptr) {
1305 last->next = newChild;
1306 newChild->prev = last;
1313 newChild->prev = refChild;
1314 newChild->next = refChild->next;
1315 refChild->next->prev = newChild;
1316 refChild->next = newChild;
1321QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild)
1323 if (!newChild || !oldChild)
1325 if (oldChild->parent() !=
this)
1327 if (newChild == oldChild)
1331 QDomDocumentPrivate *
const doc = ownerDocument();
1333 doc->nodeListTime++;
1337 if (newChild->isDocumentFragment()) {
1339 if (newChild->first ==
nullptr)
1343 QDomNodePrivate* n = newChild->first;
1351 oldChild->next->prev = newChild->last;
1353 oldChild->prev->next = newChild->first;
1355 newChild->last->next = oldChild->next;
1356 newChild->first->prev = oldChild->prev;
1358 if (first == oldChild)
1359 first = newChild->first;
1360 if (last == oldChild)
1361 last = newChild->last;
1363 oldChild->setNoParent();
1364 oldChild->next =
nullptr;
1365 oldChild->prev =
nullptr;
1371 newChild->first =
nullptr;
1372 newChild->last =
nullptr;
1375 oldChild->ref.deref();
1382 newChild->ref.ref();
1385 if (newChild->parent())
1386 newChild->parent()->removeChild(newChild);
1388 newChild->setParent(
this);
1391 oldChild->next->prev = newChild;
1393 oldChild->prev->next = newChild;
1395 newChild->next = oldChild->next;
1396 newChild->prev = oldChild->prev;
1398 if (first == oldChild)
1400 if (last == oldChild)
1403 oldChild->setNoParent();
1404 oldChild->next =
nullptr;
1405 oldChild->prev =
nullptr;
1408 oldChild->ref.deref();
1413QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild)
1416 if (oldChild->parent() !=
this)
1420 QDomDocumentPrivate *
const doc = ownerDocument();
1422 doc->nodeListTime++;
1426 if (oldChild->next ==
nullptr && oldChild->prev ==
nullptr && first != oldChild)
1430 oldChild->next->prev = oldChild->prev;
1432 oldChild->prev->next = oldChild->next;
1434 if (last == oldChild)
1435 last = oldChild->prev;
1436 if (first == oldChild)
1437 first = oldChild->next;
1439 oldChild->setNoParent();
1440 oldChild->next =
nullptr;
1441 oldChild->prev =
nullptr;
1444 oldChild->ref.deref();
1449QDomNodePrivate* QDomNodePrivate::appendChild(QDomNodePrivate* newChild)
1452 return insertAfter(newChild,
nullptr);
1455QDomDocumentPrivate* QDomNodePrivate::ownerDocument()
1457 QDomNodePrivate* p =
this;
1458 while (p && !p->isDocument()) {
1460 return static_cast<QDomDocumentPrivate *>(p->ownerNode);
1464 return static_cast<QDomDocumentPrivate *>(p);
1467QDomNodePrivate* QDomNodePrivate::cloneNode(
bool deep)
1469 QDomNodePrivate* p =
new QDomNodePrivate(
this, deep);
1475static void qNormalizeNode(QDomNodePrivate* n)
1477 QDomNodePrivate* p = n->first;
1478 QDomTextPrivate* t =
nullptr;
1483 QDomNodePrivate* tmp = p->next;
1484 t->appendData(p->nodeValue());
1488 t =
static_cast<QDomTextPrivate *>(p);
1497void QDomNodePrivate::normalize()
1501 qNormalizeNode(
this);
1504void QDomNodePrivate::saveSubTree(
const QDomNodePrivate *n, QTextStream &s,
1505 int depth,
int indent)
const
1510 const QDomNodePrivate *root = n->first;
1511 n->save(s, depth, indent);
1513 const int branchDepth = depth + 1;
1516 root->save(s, layerDepth + branchDepth, indent);
1523 root->afterSave(s, layerDepth + branchDepth, indent);
1524 const QDomNodePrivate *prev = root;
1527 while (!root && (layerDepth > 0)) {
1528 root = prev->parent();
1530 root->afterSave(s, layerDepth + branchDepth, indent);
1535 Q_ASSERT(layerDepth == 0);
1537 n->afterSave(s, depth, indent);
1540void QDomNodePrivate::setLocation(
int lineNumber,
int columnNumber)
1542 this->lineNumber = lineNumber;
1543 this->columnNumber = columnNumber;
1547
1548
1549
1550
1552#define IMPL static_cast<QDomNodePrivate *>(impl)
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1639
1640
1647
1648
1649
1650
1651
1652
1653QDomNode::QDomNode(
const QDomNode &node)
1661
1662
1663QDomNode::QDomNode(QDomNodePrivate *pimpl)
1671
1672
1673
1674
1675
1676
1677QDomNode& QDomNode::operator=(
const QDomNode &other)
1680 other.impl->ref.ref();
1681 if (impl && !impl->ref.deref())
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707bool QDomNode::operator==(
const QDomNode &other)
const
1709 return impl == other.impl;
1713
1714
1715
1716bool QDomNode::operator!=(
const QDomNode &other)
const
1718 return !operator==(other);
1722
1723
1724QDomNode::~QDomNode()
1726 if (impl && !impl->ref.deref())
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759QString QDomNode::nodeName()
const
1764 if (!IMPL->prefix.isEmpty())
1765 return IMPL->prefix + u':' + IMPL->name;
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787QString QDomNode::nodeValue()
const
1795
1796
1797
1798
1799void QDomNode::setNodeValue(
const QString& value)
1802 IMPL->setNodeValue(value);
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1826
1827
1828
1829
1830
1831
1832
1833QDomNode::NodeType QDomNode::nodeType()
const
1836 return QDomNode::BaseNode;
1837 return IMPL->nodeType();
1841
1842
1843
1844QDomNode QDomNode::parentNode()
const
1848 return QDomNode(IMPL->parent());
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869QDomNodeList QDomNode::childNodes()
const
1872 return QDomNodeList();
1873 return QDomNodeList(
new QDomNodeListPrivate(impl));
1877
1878
1879
1880
1881
1882
1883QDomNode QDomNode::firstChild()
const
1887 return QDomNode(IMPL->first);
1891
1892
1893
1894
1895
1896
1897QDomNode QDomNode::lastChild()
const
1901 return QDomNode(IMPL->last);
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917QDomNode QDomNode::previousSibling()
const
1921 return QDomNode(IMPL->prev);
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937QDomNode QDomNode::nextSibling()
const
1941 return QDomNode(IMPL->next);
1947
1948
1949
1950
1951
1952
1953QDomNamedNodeMap QDomNode::attributes()
const
1955 if (!impl || !impl->isElement())
1956 return QDomNamedNodeMap();
1958 return QDomNamedNodeMap(
static_cast<QDomElementPrivate *>(impl)->attributes());
1962
1963
1964QDomDocument QDomNode::ownerDocument()
const
1967 return QDomDocument();
1968 return QDomDocument(IMPL->ownerDocument());
1972
1973
1974
1975
1976
1977
1978
1979QDomNode QDomNode::cloneNode(
bool deep)
const
1983 return QDomNode(IMPL->cloneNode(deep));
1987
1988
1989
1990
1991
1992void QDomNode::normalize()
2000
2001
2002
2003
2004
2005
2006bool QDomNode::isSupported(
const QString& feature,
const QString& version)
const
2008 QDomImplementation i;
2009 return i.hasFeature(feature, version);
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024QString QDomNode::namespaceURI()
const
2028 return IMPL->namespaceURI;
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053QString QDomNode::prefix()
const
2057 return IMPL->prefix;
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074void QDomNode::setPrefix(
const QString& pre)
2076 if (!impl || IMPL->prefix.isNull())
2078 if (isAttr() || isElement())
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094QString QDomNode::localName()
const
2096 if (!impl || IMPL->createdWithDom1Interface)
2102
2103
2104
2105
2106bool QDomNode::hasAttributes()
const
2108 if (!impl || !impl->isElement())
2110 return static_cast<QDomElementPrivate *>(impl)->hasAttributes();
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134QDomNode QDomNode::insertBefore(
const QDomNode& newChild,
const QDomNode& refChild)
2138 return QDomNode(IMPL->insertBefore(newChild.impl, refChild.impl));
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162QDomNode QDomNode::insertAfter(
const QDomNode& newChild,
const QDomNode& refChild)
2166 return QDomNode(IMPL->insertAfter(newChild.impl, refChild.impl));
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184QDomNode QDomNode::replaceChild(
const QDomNode& newChild,
const QDomNode& oldChild)
2186 if (!impl || !newChild.impl || !oldChild.impl)
2188 return QDomNode(IMPL->replaceChild(newChild.impl, oldChild.impl));
2192
2193
2194
2195
2196
2197
2198
2199QDomNode QDomNode::removeChild(
const QDomNode& oldChild)
2204 if (oldChild.isNull())
2207 return QDomNode(IMPL->removeChild(oldChild.impl));
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234QDomNode QDomNode::appendChild(
const QDomNode& newChild)
2237 qWarning(
"Calling appendChild() on a null node does nothing.");
2240 return QDomNode(IMPL->appendChild(newChild.impl));
2244
2245
2246
2247bool QDomNode::hasChildNodes()
const
2251 return IMPL->first !=
nullptr;
2255
2256
2257
2258bool QDomNode::isNull()
const
2260 return (impl ==
nullptr);
2264
2265
2266
2267
2268
2269void QDomNode::clear()
2271 if (impl && !impl->ref.deref())
2277
2278
2279
2280
2281
2282
2283
2284
2285QDomNode QDomNode::namedItem(
const QString& name)
const
2289 return QDomNode(impl->namedItem(name));
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317void QDomNode::save(QTextStream& stream,
int indent, EncodingPolicy encodingPolicy)
const
2323 static_cast<
const QDomDocumentPrivate *>(impl)->saveDocument(stream, indent, encodingPolicy);
2325 IMPL->saveSubTree(IMPL, stream, 1, indent);
2329
2330
2331
2332
2333
2334QTextStream& operator<<(QTextStream& str,
const QDomNode& node)
2342
2343
2344
2345
2346
2347
2348
2349
2350bool QDomNode::isAttr()
const
2353 return impl->isAttr();
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367bool QDomNode::isCDATASection()
const
2370 return impl->isCDATASection();
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384bool QDomNode::isDocumentFragment()
const
2387 return impl->isDocumentFragment();
2392
2393
2394
2395
2396
2397
2398
2399bool QDomNode::isDocument()
const
2402 return impl->isDocument();
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416bool QDomNode::isDocumentType()
const
2419 return impl->isDocumentType();
2424
2425
2426
2427
2428
2429
2430
2431bool QDomNode::isElement()
const
2434 return impl->isElement();
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448bool QDomNode::isEntityReference()
const
2451 return impl->isEntityReference();
2456
2457
2458
2459
2460
2461
2462
2463bool QDomNode::isText()
const
2466 return impl->isText();
2471
2472
2473
2474
2475
2476
2477
2478bool QDomNode::isEntity()
const
2481 return impl->isEntity();
2486
2487
2488
2489
2490
2491
2492
2493bool QDomNode::isNotation()
const
2496 return impl->isNotation();
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510bool QDomNode::isProcessingInstruction()
const
2513 return impl->isProcessingInstruction();
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527bool QDomNode::isCharacterData()
const
2530 return impl->isCharacterData();
2535
2536
2537
2538
2539
2540
2541
2542bool QDomNode::isComment()
const
2545 return impl->isComment();
2552
2553
2554
2555
2556
2557
2558
2559
2561QDomElement QDomNode::firstChildElement(
const QString &tagName,
const QString &namespaceURI)
const
2563 for (QDomNode child = firstChild(); !child.isNull(); child = child.nextSibling()) {
2564 if (child.isElement() && (namespaceURI.isEmpty() || child.namespaceURI() == namespaceURI)) {
2565 QDomElement elt = child.toElement();
2566 if (tagName.isEmpty() || elt.tagName() == tagName)
2570 return QDomElement();
2574
2575
2576
2577
2578
2579
2580
2581
2583QDomElement QDomNode::lastChildElement(
const QString &tagName,
const QString &namespaceURI)
const
2585 for (QDomNode child = lastChild(); !child.isNull(); child = child.previousSibling()) {
2586 if (child.isElement() && (namespaceURI.isEmpty() || child.namespaceURI() == namespaceURI)) {
2587 QDomElement elt = child.toElement();
2588 if (tagName.isEmpty() || elt.tagName() == tagName)
2592 return QDomElement();
2596
2597
2598
2599
2600
2601
2602
2603
2604
2606QDomElement QDomNode::nextSiblingElement(
const QString &tagName,
const QString &namespaceURI)
const
2608 for (QDomNode sib = nextSibling(); !sib.isNull(); sib = sib.nextSibling()) {
2609 if (sib.isElement() && (namespaceURI.isEmpty() || sib.namespaceURI() == namespaceURI)) {
2610 QDomElement elt = sib.toElement();
2611 if (tagName.isEmpty() || elt.tagName() == tagName)
2615 return QDomElement();
2619
2620
2621
2622
2623
2624
2625
2626
2627
2629QDomElement QDomNode::previousSiblingElement(
const QString &tagName,
const QString &namespaceURI)
const
2631 for (QDomNode sib = previousSibling(); !sib.isNull(); sib = sib.previousSibling()) {
2632 if (sib.isElement() && (namespaceURI.isEmpty() || sib.namespaceURI() == namespaceURI)) {
2633 QDomElement elt = sib.toElement();
2634 if (tagName.isEmpty() || elt.tagName() == tagName)
2638 return QDomElement();
2642
2643
2644
2645
2646
2647
2648
2649
2650int QDomNode::lineNumber()
const
2652 return impl ? impl->lineNumber : -1;
2656
2657
2658
2659
2660
2661
2662
2663
2664int QDomNode::columnNumber()
const
2666 return impl ? impl->columnNumber : -1;
2671
2672
2673
2674
2676QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate(QDomNodePrivate *pimpl)
2680 , appendToParent(
false)
2684QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate()
2689QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate *pimpl)
2691 std::unique_ptr<QDomNamedNodeMapPrivate> m(
new QDomNamedNodeMapPrivate(pimpl));
2692 m->readonly = readonly;
2693 m->appendToParent = appendToParent;
2695 auto it = map.constBegin();
2696 for (; it != map.constEnd(); ++it) {
2697 QDomNodePrivate *new_node = it.value()->cloneNode();
2698 new_node->setParent(pimpl);
2699 m->setNamedItem(new_node);
2707void QDomNamedNodeMapPrivate::clearMap()
2710 if (!appendToParent) {
2711 auto it = map.constBegin();
2712 for (; it != map.constEnd(); ++it)
2713 if (!it.value()->ref.deref())
2719QDomNodePrivate* QDomNamedNodeMapPrivate::namedItem(
const QString& name)
const
2721 auto it = map.find(name);
2722 return it == map.end() ?
nullptr : it.value();
2725QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(
const QString& nsURI,
const QString& localName)
const
2727 auto it = map.constBegin();
2729 for (; it != map.constEnd(); ++it) {
2731 if (!n->prefix.isNull()) {
2733 if (n->namespaceURI == nsURI && n->name == localName)
2740QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg)
2742 if (readonly || !arg)
2746 return parent->appendChild(arg);
2748 QDomNodePrivate *n = map.value(arg->nodeName());
2751 map.insert(arg->nodeName(), arg);
2755QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg)
2757 if (readonly || !arg)
2761 return parent->appendChild(arg);
2763 if (!arg->prefix.isNull()) {
2765 QDomNodePrivate *n = namedItemNS(arg->namespaceURI, arg->name);
2768 map.insert(arg->nodeName(), arg);
2772 return setNamedItem(arg);
2776QDomNodePrivate* QDomNamedNodeMapPrivate::removeNamedItem(
const QString& name)
2781 QDomNodePrivate* p = namedItem(name);
2785 return parent->removeChild(p);
2787 map.remove(p->nodeName());
2793QDomNodePrivate* QDomNamedNodeMapPrivate::item(
int index)
const
2795 if (index >= length() || index < 0)
2797 return std::next(map.begin(), index).value();
2800int QDomNamedNodeMapPrivate::length()
const
2805bool QDomNamedNodeMapPrivate::contains(
const QString& name)
const
2807 return map.contains(name);
2810bool QDomNamedNodeMapPrivate::containsNS(
const QString& nsURI,
const QString & localName)
const
2812 return namedItemNS(nsURI, localName) !=
nullptr;
2816
2817
2818
2819
2821#define IMPL static_cast<QDomNamedNodeMapPrivate *>(impl)
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2862
2863
2864QDomNamedNodeMap::QDomNamedNodeMap()
2870
2871
2872QDomNamedNodeMap::QDomNamedNodeMap(
const QDomNamedNodeMap &namedNodeMap)
2873 : impl(namedNodeMap.impl)
2879QDomNamedNodeMap::QDomNamedNodeMap(QDomNamedNodeMapPrivate *pimpl)
2887
2888
2889QDomNamedNodeMap& QDomNamedNodeMap::operator=(
const QDomNamedNodeMap &other)
2892 other.impl->ref.ref();
2893 if (impl && !impl->ref.deref())
2900
2901
2902
2903bool QDomNamedNodeMap::operator==(
const QDomNamedNodeMap &other)
const
2905 return impl == other.impl;
2909
2910
2911
2912bool QDomNamedNodeMap::operator!=(
const QDomNamedNodeMap &other)
const
2914 return !operator==(other);
2918
2919
2920QDomNamedNodeMap::~QDomNamedNodeMap()
2922 if (impl && !impl->ref.deref())
2927
2928
2929
2930
2931
2932
2933
2934
2935QDomNode QDomNamedNodeMap::namedItem(
const QString& name)
const
2939 return QDomNode(IMPL->namedItem(name));
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952QDomNode QDomNamedNodeMap::setNamedItem(
const QDomNode& newNode)
2956 return QDomNode(IMPL->setNamedItem(
static_cast<QDomNodePrivate *>(newNode.impl)));
2960
2961
2962
2963
2964
2965
2966
2967
2968QDomNode QDomNamedNodeMap::removeNamedItem(
const QString& name)
2972 return QDomNode(IMPL->removeNamedItem(name));
2976
2977
2978
2979
2980
2981
2982
2983QDomNode QDomNamedNodeMap::item(
int index)
const
2987 return QDomNode(IMPL->item(index));
2991
2992
2993
2994
2995
2996
2997
2998
2999QDomNode QDomNamedNodeMap::namedItemNS(
const QString& nsURI,
const QString& localName)
const
3003 return QDomNode(IMPL->namedItemNS(nsURI, localName));
3007
3008
3009
3010
3011
3012
3013
3014QDomNode QDomNamedNodeMap::setNamedItemNS(
const QDomNode& newNode)
3018 return QDomNode(IMPL->setNamedItemNS(
static_cast<QDomNodePrivate *>(newNode.impl)));
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032QDomNode QDomNamedNodeMap::removeNamedItemNS(
const QString& nsURI,
const QString& localName)
3036 QDomNodePrivate *n = IMPL->namedItemNS(nsURI, localName);
3039 return QDomNode(IMPL->removeNamedItem(n->name));
3043
3044
3045
3046
3047int QDomNamedNodeMap::length()
const
3051 return IMPL->length();
3055
3056
3057
3058
3059
3062
3063
3064
3065
3068
3069
3070
3071
3074
3075
3076
3077
3078
3079
3080
3081bool QDomNamedNodeMap::contains(
const QString& name)
const
3085 return IMPL->contains(name);
3091
3092
3093
3094
3096QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent)
3097 : QDomNodePrivate(doc, parent)
3102QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentTypePrivate* n,
bool deep)
3103 : QDomNodePrivate(n, deep)
3107 QDomNodePrivate* p = first;
3111 entities->map.insert(p->nodeName(), p);
3112 if (p->isNotation())
3114 notations->map.insert(p->nodeName(), p);
3119QDomDocumentTypePrivate::~QDomDocumentTypePrivate()
3121 if (!entities->ref.deref())
3123 if (!notations->ref.deref())
3127void QDomDocumentTypePrivate::init()
3129 entities =
new QDomNamedNodeMapPrivate(
this);
3131 notations =
new QDomNamedNodeMapPrivate(
this);
3134 internalSubset.clear();
3136 entities->setAppendToParent(
true);
3137 notations->setAppendToParent(
true);
3144QDomNodePrivate* QDomDocumentTypePrivate::cloneNode(
bool deep)
3146 QDomNodePrivate* p =
new QDomDocumentTypePrivate(
this, deep);
3152QDomNodePrivate* QDomDocumentTypePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
3155 QDomNodePrivate* p = QDomNodePrivate::insertBefore(newChild, refChild);
3157 if (p && p->isEntity())
3158 entities->map.insert(p->nodeName(), p);
3159 else if (p && p->isNotation())
3160 notations->map.insert(p->nodeName(), p);
3165QDomNodePrivate* QDomDocumentTypePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
3168 QDomNodePrivate* p = QDomNodePrivate::insertAfter(newChild, refChild);
3170 if (p && p->isEntity())
3171 entities->map.insert(p->nodeName(), p);
3172 else if (p && p->isNotation())
3173 notations->map.insert(p->nodeName(), p);
3178QDomNodePrivate* QDomDocumentTypePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild)
3181 QDomNodePrivate* p = QDomNodePrivate::replaceChild(newChild, oldChild);
3184 if (oldChild && oldChild->isEntity())
3185 entities->map.remove(oldChild->nodeName());
3186 else if (oldChild && oldChild->isNotation())
3187 notations->map.remove(oldChild->nodeName());
3190 entities->map.insert(p->nodeName(), p);
3191 else if (p->isNotation())
3192 notations->map.insert(p->nodeName(), p);
3198QDomNodePrivate* QDomDocumentTypePrivate::removeChild(QDomNodePrivate* oldChild)
3201 QDomNodePrivate* p = QDomNodePrivate::removeChild( oldChild);
3203 if (p && p->isEntity())
3204 entities->map.remove(p->nodeName());
3205 else if (p && p->isNotation())
3206 notations->map.remove(p ->nodeName());
3211QDomNodePrivate* QDomDocumentTypePrivate::appendChild(QDomNodePrivate* newChild)
3213 return insertAfter(newChild,
nullptr);
3216static QString quotedValue(
const QString &data)
3218 QChar quote = data.indexOf(u'\'') == -1 ? u'\'' : u'"';
3219 return quote + data + quote;
3222void QDomDocumentTypePrivate::save(QTextStream& s,
int,
int indent)
const
3227 s <<
"<!DOCTYPE " << name;
3229 if (!publicId.isNull()) {
3230 s <<
" PUBLIC " << quotedValue(publicId);
3231 if (!systemId.isNull()) {
3232 s <<
' ' << quotedValue(systemId);
3234 }
else if (!systemId.isNull()) {
3235 s <<
" SYSTEM " << quotedValue(systemId);
3238 if (entities->length()>0 || notations->length()>0) {
3239 s <<
" [" << Qt::endl;
3241 auto it2 = notations->map.constBegin();
3242 for (; it2 != notations->map.constEnd(); ++it2)
3243 it2.value()->saveSubTree(it2.value(), s, 0, indent);
3245 auto it = entities->map.constBegin();
3246 for (; it != entities->map.constEnd(); ++it)
3247 it.value()->saveSubTree(it.value(), s, 0, indent);
3252 s <<
'>' << Qt::endl;
3256
3257
3258
3259
3261#define IMPL static_cast<QDomDocumentTypePrivate *>(impl)
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3283
3284
3285QDomDocumentType::QDomDocumentType() : QDomNode()
3290
3291
3292
3293
3294
3295
3296QDomDocumentType::QDomDocumentType(
const QDomDocumentType &documentType)
3297 : QDomNode(documentType)
3301QDomDocumentType::QDomDocumentType(QDomDocumentTypePrivate *pimpl)
3307
3308
3309
3310
3311
3312
3313QDomDocumentType &QDomDocumentType::operator=(
const QDomDocumentType &other) =
default;
3315
3316
3317
3318
3319
3320QString QDomDocumentType::name()
const
3324 return IMPL->nodeName();
3328
3329
3330QDomNamedNodeMap QDomDocumentType::entities()
const
3333 return QDomNamedNodeMap();
3334 return QDomNamedNodeMap(IMPL->entities);
3338
3339
3340QDomNamedNodeMap QDomDocumentType::notations()
const
3343 return QDomNamedNodeMap();
3344 return QDomNamedNodeMap(IMPL->notations);
3348
3349
3350
3351
3352
3353QString QDomDocumentType::publicId()
const
3357 return IMPL->publicId;
3361
3362
3363
3364
3365
3366QString QDomDocumentType::systemId()
const
3370 return IMPL->systemId;
3374
3375
3376
3377
3378
3379QString QDomDocumentType::internalSubset()
const
3383 return IMPL->internalSubset;
3387
3388
3389
3390
3393
3394
3395
3396
3397
3398
3403
3404
3405
3406
3408QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent)
3409 : QDomNodePrivate(doc, parent)
3411 name = u"#document-fragment"_s;
3414QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomNodePrivate* n,
bool deep)
3415 : QDomNodePrivate(n, deep)
3419QDomNodePrivate* QDomDocumentFragmentPrivate::cloneNode(
bool deep)
3421 QDomNodePrivate* p =
new QDomDocumentFragmentPrivate(
this, deep);
3428
3429
3430
3431
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3459
3460
3461QDomDocumentFragment::QDomDocumentFragment()
3465QDomDocumentFragment::QDomDocumentFragment(QDomDocumentFragmentPrivate* n)
3471
3472
3473
3474
3475
3476
3477QDomDocumentFragment::QDomDocumentFragment(
const QDomDocumentFragment &documentFragment)
3478 : QDomNode(documentFragment)
3483
3484
3485
3486
3487
3488
3489QDomDocumentFragment &QDomDocumentFragment::operator=(
const QDomDocumentFragment &other) =
default;
3492
3493
3494
3495
3496
3497
3500
3501
3502
3503
3505QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
3506 const QString& data)
3507 : QDomNodePrivate(d, p)
3510 name = u"#character-data"_s;
3513QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomCharacterDataPrivate* n,
bool deep)
3514 : QDomNodePrivate(n, deep)
3518QDomNodePrivate* QDomCharacterDataPrivate::cloneNode(
bool deep)
3520 QDomNodePrivate* p =
new QDomCharacterDataPrivate(
this, deep);
3526int QDomCharacterDataPrivate::dataLength()
const
3528 return value.size();
3531QString QDomCharacterDataPrivate::substringData(
unsigned long offset,
unsigned long n)
const
3533 return value.mid(offset, n);
3536void QDomCharacterDataPrivate::insertData(
unsigned long offset,
const QString& arg)
3538 value.insert(offset, arg);
3541void QDomCharacterDataPrivate::deleteData(
unsigned long offset,
unsigned long n)
3543 value.remove(offset, n);
3546void QDomCharacterDataPrivate::replaceData(
unsigned long offset,
unsigned long n,
const QString& arg)
3548 value.replace(offset, n, arg);
3551void QDomCharacterDataPrivate::appendData(
const QString& arg)
3557
3558
3559
3560
3562#define IMPL static_cast<QDomCharacterDataPrivate *>(impl)
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3590
3591
3592QDomCharacterData::QDomCharacterData()
3597
3598
3599
3600
3601
3602
3603QDomCharacterData::QDomCharacterData(
const QDomCharacterData &characterData)
3604 : QDomNode(characterData)
3608QDomCharacterData::QDomCharacterData(QDomCharacterDataPrivate* n)
3614
3615
3616
3617
3618
3619
3620QDomCharacterData &QDomCharacterData::operator=(
const QDomCharacterData &other) =
default;
3623
3624
3625
3626
3627
3628QString QDomCharacterData::data()
const
3632 return impl->nodeValue();
3636
3637
3638void QDomCharacterData::setData(
const QString &data)
3641 impl->setNodeValue(data);
3645
3646
3647int QDomCharacterData::length()
const
3650 return IMPL->dataLength();
3655
3656
3657QString QDomCharacterData::substringData(
unsigned long offset,
unsigned long count)
3661 return IMPL->substringData(offset, count);
3665
3666
3667void QDomCharacterData::appendData(
const QString& arg)
3670 IMPL->appendData(arg);
3674
3675
3676void QDomCharacterData::insertData(
unsigned long offset,
const QString& arg)
3679 IMPL->insertData(offset, arg);
3683
3684
3685void QDomCharacterData::deleteData(
unsigned long offset,
unsigned long count)
3688 IMPL->deleteData(offset, count);
3692
3693
3694
3695void QDomCharacterData::replaceData(
unsigned long offset,
unsigned long count,
const QString& arg)
3698 IMPL->replaceData(offset, count, arg);
3702
3703
3704
3705
3706QDomNode::NodeType QDomCharacterData::nodeType()
const
3709 return CharacterDataNode;
3710 return QDomNode::nodeType();
3716
3717
3718
3719
3721QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& name_)
3722 : QDomNodePrivate(d, parent)
3725 m_specified =
false;
3728QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
const QString& nsURI,
const QString& qName)
3729 : QDomNodePrivate(d, p)
3731 qt_split_namespace(prefix, name, qName, !nsURI.isNull());
3732 namespaceURI = nsURI;
3733 createdWithDom1Interface =
false;
3734 m_specified =
false;
3737QDomAttrPrivate::QDomAttrPrivate(QDomAttrPrivate* n,
bool deep)
3738 : QDomNodePrivate(n, deep)
3740 m_specified = n->specified();
3743void QDomAttrPrivate::setNodeValue(
const QString& v)
3746 QDomTextPrivate *t =
new QDomTextPrivate(
nullptr,
this, v);
3750 auto removed = removeChild(first);
3751 if (removed && !removed->ref.loadRelaxed())
3757QDomNodePrivate* QDomAttrPrivate::cloneNode(
bool deep)
3759 QDomNodePrivate* p =
new QDomAttrPrivate(
this, deep);
3765bool QDomAttrPrivate::specified()
const
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780static QString encodeText(
const QString &str,
3781 const bool encodeQuotes =
true,
3782 const bool performAVN =
false,
3783 const bool encodeEOLs =
false)
3786 qsizetype start = 0;
3787 auto appendToOutput = [&](qsizetype cur,
const auto &replacement)
3790 retval.reserve(str.size() + replacement.size());
3791 retval.append(QStringView(str).first(cur).sliced(start));
3795 retval.append(replacement);
3798 const qsizetype len = str.size();
3799 for (qsizetype cur = 0; cur < len; ++cur) {
3800 switch (str[cur].unicode()) {
3802 appendToOutput(cur,
"<"_L1);
3806 appendToOutput(cur,
"""_L1);
3809 appendToOutput(cur,
"&"_L1);
3812 if (cur >= 2 && str[cur - 1] == u']' && str[cur - 2] == u']')
3813 appendToOutput(cur,
">"_L1);
3816 if (performAVN || encodeEOLs)
3817 appendToOutput(cur,
"
"_L1);
3821 appendToOutput(cur,
"
"_L1);
3825 appendToOutput(cur,
"	"_L1);
3832 retval.append(QStringView(str).first(len).sliced(start));
3838void QDomAttrPrivate::save(QTextStream& s,
int,
int)
const
3840 if (namespaceURI.isNull()) {
3841 s << name <<
"=\"" << encodeText(value,
true,
true) <<
'\"';
3843 s << prefix <<
':' << name <<
"=\"" << encodeText(value,
true,
true) <<
'\"';
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3856 ownerNode->prefix != prefix) {
3857 s <<
" xmlns:" << prefix <<
"=\"" << encodeText(namespaceURI,
true,
true) <<
'\"';
3863
3864
3865
3866
3868#define IMPL static_cast<QDomAttrPrivate *>(impl)
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3906
3907
3913
3914
3915
3916
3917
3918
3919QDomAttr::QDomAttr(
const QDomAttr &attr)
3924QDomAttr::QDomAttr(QDomAttrPrivate* n)
3930
3931
3932
3933
3934
3935
3936QDomAttr &QDomAttr::operator=(
const QDomAttr &other) =
default;
3939
3940
3941QString QDomAttr::name()
const
3945 return impl->nodeName();
3949
3950
3951
3952
3953
3954bool QDomAttr::specified()
const
3958 return IMPL->specified();
3962
3963
3964
3965
3966QDomElement QDomAttr::ownerElement()
const
3968 Q_ASSERT(impl->parent());
3969 if (!impl->parent()->isElement())
3970 return QDomElement();
3971 return QDomElement(
static_cast<QDomElementPrivate *>(impl->parent()));
3975
3976
3977
3978
3979
3980QString QDomAttr::value()
const
3984 return impl->nodeValue();
3988
3989
3990
3991
3992void QDomAttr::setValue(
const QString &value)
3996 impl->setNodeValue(value);
3997 IMPL->m_specified =
true;
4001
4002
4003
4004
4009
4010
4011
4012
4014QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
4015 const QString& tagname)
4016 : QDomNodePrivate(d, p)
4019 m_attr =
new QDomNamedNodeMapPrivate(
this);
4022QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
4023 const QString& nsURI,
const QString& qName)
4024 : QDomNodePrivate(d, p)
4026 qt_split_namespace(prefix, name, qName, !nsURI.isNull());
4027 namespaceURI = nsURI;
4028 createdWithDom1Interface =
false;
4029 m_attr =
new QDomNamedNodeMapPrivate(
this);
4032QDomElementPrivate::QDomElementPrivate(QDomElementPrivate* n,
bool deep) :
4033 QDomNodePrivate(n, deep)
4035 m_attr = n->m_attr->clone(
this);
4040QDomElementPrivate::~QDomElementPrivate()
4042 if (!m_attr->ref.deref())
4046QDomNodePrivate* QDomElementPrivate::cloneNode(
bool deep)
4048 QDomNodePrivate* p =
new QDomElementPrivate(
this, deep);
4054QString QDomElementPrivate::attribute(
const QString& name_,
const QString& defValue)
const
4056 QDomNodePrivate* n = m_attr->namedItem(name_);
4060 return n->nodeValue();
4063QString QDomElementPrivate::attributeNS(
const QString& nsURI,
const QString& localName,
const QString& defValue)
const
4065 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4069 return n->nodeValue();
4072void QDomElementPrivate::setAttribute(
const QString& aname,
const QString& newValue)
4074 QDomNodePrivate* n = m_attr->namedItem(aname);
4076 n =
new QDomAttrPrivate(ownerDocument(),
this, aname);
4077 n->setNodeValue(newValue);
4082 m_attr->setNamedItem(n);
4084 n->setNodeValue(newValue);
4088void QDomElementPrivate::setAttributeNS(
const QString& nsURI,
const QString& qName,
const QString& newValue)
4090 QString prefix, localName;
4091 qt_split_namespace(prefix, localName, qName,
true);
4092 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4094 n =
new QDomAttrPrivate(ownerDocument(),
this, nsURI, qName);
4095 n->setNodeValue(newValue);
4100 m_attr->setNamedItem(n);
4102 n->setNodeValue(newValue);
4107void QDomElementPrivate::removeAttribute(
const QString& aname)
4109 QDomNodePrivate* p = m_attr->removeNamedItem(aname);
4110 if (p && p->ref.loadRelaxed() == 0)
4114QDomAttrPrivate* QDomElementPrivate::attributeNode(
const QString& aname)
4116 return static_cast<QDomAttrPrivate *>(m_attr->namedItem(aname));
4119QDomAttrPrivate* QDomElementPrivate::attributeNodeNS(
const QString& nsURI,
const QString& localName)
4121 return static_cast<QDomAttrPrivate *>(m_attr->namedItemNS(nsURI, localName));
4124QDomAttrPrivate* QDomElementPrivate::setAttributeNode(QDomAttrPrivate* newAttr)
4126 QDomNodePrivate* n = m_attr->namedItem(newAttr->nodeName());
4129 m_attr->setNamedItem(newAttr);
4131 newAttr->setParent(
this);
4133 return static_cast<QDomAttrPrivate *>(n);
4136QDomAttrPrivate* QDomElementPrivate::setAttributeNodeNS(QDomAttrPrivate* newAttr)
4138 QDomNodePrivate* n =
nullptr;
4139 if (!newAttr->prefix.isNull())
4140 n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name);
4143 m_attr->setNamedItem(newAttr);
4145 return static_cast<QDomAttrPrivate *>(n);
4148QDomAttrPrivate* QDomElementPrivate::removeAttributeNode(QDomAttrPrivate* oldAttr)
4150 return static_cast<QDomAttrPrivate *>(m_attr->removeNamedItem(oldAttr->nodeName()));
4153bool QDomElementPrivate::hasAttribute(
const QString& aname)
4155 return m_attr->contains(aname);
4158bool QDomElementPrivate::hasAttributeNS(
const QString& nsURI,
const QString& localName)
4160 return m_attr->containsNS(nsURI, localName);
4163QString QDomElementPrivate::text()
4167 QDomNodePrivate* p = first;
4169 if (p->isText() || p->isCDATASection())
4170 t += p->nodeValue();
4171 else if (p->isElement())
4172 t +=
static_cast<QDomElementPrivate *>(p)->text();
4179void QDomElementPrivate::save(QTextStream& s,
int depth,
int indent)
const
4181 if (!(prev && prev->isText()))
4182 s << QString(indent < 1 ? 0 : depth * indent, u' ');
4184 QString qName(name);
4185 QString nsDecl(u""_s);
4186 if (!namespaceURI.isNull()) {
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197 if (prefix.isEmpty()) {
4198 nsDecl = u" xmlns"_s;
4200 qName = prefix + u':' + name;
4201 nsDecl = u" xmlns:"_s + prefix;
4203 nsDecl += u"=\""_s + encodeText(namespaceURI) + u'\"';
4205 s <<
'<' << qName << nsDecl;
4209 if (!m_attr->map.isEmpty()) {
4211
4212
4213
4214
4215
4216
4217
4218 struct SavedAttribute {
4221 QString encodedValue;
4225 QVarLengthArray<SavedAttribute, 8> attributesToSave;
4226 attributesToSave.reserve(m_attr->map.size());
4228 QDuplicateTracker<QString> outputtedPrefixes;
4229 for (
const auto &[key, value] : std::as_const(m_attr->map).asKeyValueRange()) {
4231 bool mayNeedXmlNS =
false;
4233 SavedAttribute attr;
4234 attr.name = value->name;
4235 attr.encodedValue = encodeText(value->value,
true,
true);
4236 if (!value->namespaceURI.isNull()) {
4237 attr.prefix = value->prefix;
4238 mayNeedXmlNS =
true;
4241 attributesToSave.push_back(std::move(attr));
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4260 && ((!value->ownerNode || value->ownerNode->prefix != value->prefix)
4261 && !outputtedPrefixes.hasSeen(value->prefix)))
4263 SavedAttribute nsAttr;
4264 nsAttr.prefix = QStringLiteral(
"xmlns");
4265 nsAttr.name = value->prefix;
4266 nsAttr.encodedValue = encodeText(value->namespaceURI,
true,
true);
4267 attributesToSave.push_back(std::move(nsAttr));
4272 const auto savedAttributeComparator = [](
const SavedAttribute &lhs,
const SavedAttribute &rhs)
4274 const int cmp = QString::compare(lhs.prefix, rhs.prefix);
4275 return (cmp < 0) || ((cmp == 0) && (lhs.name < rhs.name));
4278 std::sort(attributesToSave.begin(), attributesToSave.end(), savedAttributeComparator);
4281 for (
const auto &attr : attributesToSave) {
4283 if (!attr.prefix.isEmpty())
4284 s << attr.prefix <<
':';
4285 s << attr.name <<
"=\"" << attr.encodedValue <<
'\"';
4291 if (first->isText())
4305void QDomElementPrivate::afterSave(QTextStream &s,
int depth,
int indent)
const
4308 QString qName(name);
4310 if (!prefix.isEmpty())
4311 qName = prefix + u':' + name;
4313 if (!last->isText())
4314 s << QString(indent < 1 ? 0 : depth * indent, u' ');
4316 s <<
"</" << qName <<
'>';
4319 if (!(next && next->isText())) {
4327
4328
4329
4330
4332#define IMPL static_cast<QDomElementPrivate *>(impl)
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4387
4388
4389
4390QDomElement::QDomElement()
4396
4397
4398
4399
4400
4401
4402QDomElement::QDomElement(
const QDomElement &element)
4407QDomElement::QDomElement(QDomElementPrivate* n)
4413
4414
4415
4416
4417
4418
4419QDomElement &QDomElement::operator=(
const QDomElement &other) =
default;
4422
4423
4424
4425
4428
4429
4430
4431
4432void QDomElement::setTagName(
const QString& name)
4439
4440
4441
4442
4443
4444
4445
4446
4447QString QDomElement::tagName()
const
4451 return impl->nodeName();
4456
4457
4458
4459
4460QDomNamedNodeMap QDomElement::attributes()
const
4463 return QDomNamedNodeMap();
4464 return QDomNamedNodeMap(IMPL->attributes());
4468
4469
4470
4471
4472
4473QString QDomElement::attribute(
const QString& name,
const QString& defValue)
const
4477 return IMPL->attribute(name, defValue);
4481
4482
4483
4484
4485
4486
4487void QDomElement::setAttribute(
const QString& name,
const QString& value)
4491 IMPL->setAttribute(name, value);
4495
4496
4497
4498
4499
4502
4503
4504
4505
4506
4509
4510
4511
4512
4513void QDomElement::setAttribute(
const QString& name, qlonglong value)
4519 IMPL->setAttribute(name, x);
4523
4524
4525
4526
4527void QDomElement::setAttribute(
const QString& name, qulonglong value)
4533 IMPL->setAttribute(name, x);
4537
4538
4539
4540
4541void QDomElement::setAttribute(
const QString& name,
float value)
4546 x.setNum(value,
'g', 8);
4547 IMPL->setAttribute(name, x);
4551
4552
4553
4554
4555void QDomElement::setAttribute(
const QString& name,
double value)
4560 x.setNum(value,
'g', 17);
4561 IMPL->setAttribute(name, x);
4565
4566
4567
4568
4569void QDomElement::removeAttribute(
const QString& name)
4573 IMPL->removeAttribute(name);
4577
4578
4579
4580
4581
4582
4583QDomAttr QDomElement::attributeNode(
const QString& name)
4587 return QDomAttr(IMPL->attributeNode(name));
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600QDomAttr QDomElement::setAttributeNode(
const QDomAttr& newAttr)
4604 return QDomAttr(IMPL->setAttributeNode(
static_cast<QDomAttrPrivate *>(newAttr.impl)));
4608
4609
4610
4611
4612QDomAttr QDomElement::removeAttributeNode(
const QDomAttr& oldAttr)
4616 return QDomAttr(IMPL->removeAttributeNode(
static_cast<QDomAttrPrivate *>(oldAttr.impl)));
4620
4621
4622
4623
4624
4625
4626
4627
4628QDomNodeList QDomElement::elementsByTagName(
const QString& tagname)
const
4630 return QDomNodeList(
new QDomNodeListPrivate(impl, tagname));
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645bool QDomElement::hasAttribute(
const QString& name)
const
4649 return IMPL->hasAttribute(name);
4653
4654
4655
4656
4657
4658
4659QString QDomElement::attributeNS(
const QString& nsURI,
const QString& localName,
const QString& defValue)
const
4663 return IMPL->attributeNS(nsURI, localName, defValue);
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName,
const QString& value)
4682 IMPL->setAttributeNS(nsURI, qName, value);
4686
4687
4688
4689
4692
4693
4694
4695
4698
4699
4700void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName, qlonglong value)
4706 IMPL->setAttributeNS(nsURI, qName, x);
4710
4711
4712void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName, qulonglong value)
4718 IMPL->setAttributeNS(nsURI, qName, x);
4722
4723
4724void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName,
double value)
4729 x.setNum(value,
'g', 17);
4730 IMPL->setAttributeNS(nsURI, qName, x);
4734
4735
4736
4737
4738
4739void QDomElement::removeAttributeNS(
const QString& nsURI,
const QString& localName)
4743 QDomNodePrivate *n = IMPL->attributeNodeNS(nsURI, localName);
4746 IMPL->removeAttribute(n->nodeName());
4750
4751
4752
4753
4754
4755
4756
4757QDomAttr QDomElement::attributeNodeNS(
const QString& nsURI,
const QString& localName)
4761 return QDomAttr(IMPL->attributeNodeNS(nsURI, localName));
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774QDomAttr QDomElement::setAttributeNodeNS(
const QDomAttr& newAttr)
4778 return QDomAttr(IMPL->setAttributeNodeNS(
static_cast<QDomAttrPrivate *>(newAttr.impl)));
4782
4783
4784
4785
4786
4787
4788
4789
4790QDomNodeList QDomElement::elementsByTagNameNS(
const QString& nsURI,
const QString& localName)
const
4792 return QDomNodeList(
new QDomNodeListPrivate(impl, nsURI, localName));
4796
4797
4798
4799
4800bool QDomElement::hasAttributeNS(
const QString& nsURI,
const QString& localName)
const
4804 return IMPL->hasAttributeNS(nsURI, localName);
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821QString QDomElement::text()
const
4825 return IMPL->text();
4831
4832
4833
4834
4836QDomTextPrivate::QDomTextPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& val)
4837 : QDomCharacterDataPrivate(d, parent, val)
4842QDomTextPrivate::QDomTextPrivate(QDomTextPrivate* n,
bool deep)
4843 : QDomCharacterDataPrivate(n, deep)
4847QDomNodePrivate* QDomTextPrivate::cloneNode(
bool deep)
4849 QDomNodePrivate* p =
new QDomTextPrivate(
this, deep);
4855QDomTextPrivate* QDomTextPrivate::splitText(
int offset)
4858 qWarning(
"QDomText::splitText The node has no parent. So I cannot split");
4862 QDomTextPrivate* t =
new QDomTextPrivate(ownerDocument(),
nullptr, value.mid(offset));
4863 value.truncate(offset);
4865 parent()->insertAfter(t,
this);
4866 Q_ASSERT(t->ref.loadRelaxed() == 2);
4874void QDomTextPrivate::save(QTextStream& s,
int,
int)
const
4876 QDomTextPrivate *that =
const_cast<QDomTextPrivate*>(
this);
4877 s << encodeText(value, !(that->parent() && that->parent()->isElement()),
false,
true);
4881
4882
4883
4884
4886#define IMPL static_cast<QDomTextPrivate *>(impl)
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4907
4908
4909
4910
4912 : QDomCharacterData()
4917
4918
4919
4920
4921
4922
4923QDomText::QDomText(
const QDomText &text)
4924 : QDomCharacterData(text)
4928QDomText::QDomText(QDomTextPrivate* n)
4929 : QDomCharacterData(n)
4934
4935
4936
4937
4938
4939
4940QDomText &QDomText::operator=(
const QDomText &other) =
default;
4943
4944
4945
4946
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958QDomText QDomText::splitText(
int offset)
4962 return QDomText(IMPL->splitText(offset));
4968
4969
4970
4971
4973QDomCommentPrivate::QDomCommentPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& val)
4974 : QDomCharacterDataPrivate(d, parent, val)
4976 name = u"#comment"_s;
4979QDomCommentPrivate::QDomCommentPrivate(QDomCommentPrivate* n,
bool deep)
4980 : QDomCharacterDataPrivate(n, deep)
4985QDomNodePrivate* QDomCommentPrivate::cloneNode(
bool deep)
4987 QDomNodePrivate* p =
new QDomCommentPrivate(
this, deep);
4993void QDomCommentPrivate::save(QTextStream& s,
int depth,
int indent)
const
4996 if (!(prev && prev->isText()))
4997 s << QString(indent < 1 ? 0 : depth * indent, u' ');
4999 s <<
"<!--" << value;
5000 if (value.endsWith(u'-'))
5004 if (!(next && next->isText()))
5009
5010
5011
5012
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5036
5037
5038
5039QDomComment::QDomComment()
5040 : QDomCharacterData()
5045
5046
5047
5048
5049
5050
5051QDomComment::QDomComment(
const QDomComment &comment)
5052 : QDomCharacterData(comment)
5056QDomComment::QDomComment(QDomCommentPrivate* n)
5057 : QDomCharacterData(n)
5062
5063
5064
5065
5066
5067
5068QDomComment &QDomComment::operator=(
const QDomComment &other) =
default;
5071
5072
5073
5074
5077
5078
5079
5080
5082QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5084 : QDomTextPrivate(d, parent, val)
5086 name = u"#cdata-section"_s;
5089QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomCDATASectionPrivate* n,
bool deep)
5090 : QDomTextPrivate(n, deep)
5094QDomNodePrivate* QDomCDATASectionPrivate::cloneNode(
bool deep)
5096 QDomNodePrivate* p =
new QDomCDATASectionPrivate(
this, deep);
5102void QDomCDATASectionPrivate::save(QTextStream& s,
int,
int)
const
5106 s <<
"<![CDATA[" << value <<
"]]>";
5110
5111
5112
5113
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5141
5142
5143
5144QDomCDATASection::QDomCDATASection()
5150
5151
5152
5153
5154
5155
5156QDomCDATASection::QDomCDATASection(
const QDomCDATASection &cdataSection)
5157 : QDomText(cdataSection)
5161QDomCDATASection::QDomCDATASection(QDomCDATASectionPrivate* n)
5167
5168
5169
5170
5171
5172
5173QDomCDATASection &QDomCDATASection::operator=(
const QDomCDATASection &other) =
default;
5176
5177
5178
5179
5182
5183
5184
5185
5187QDomNotationPrivate::QDomNotationPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5188 const QString& aname,
5189 const QString& pub,
const QString& sys)
5190 : QDomNodePrivate(d, parent)
5197QDomNotationPrivate::QDomNotationPrivate(QDomNotationPrivate* n,
bool deep)
5198 : QDomNodePrivate(n, deep)
5204QDomNodePrivate* QDomNotationPrivate::cloneNode(
bool deep)
5206 QDomNodePrivate* p =
new QDomNotationPrivate(
this, deep);
5212void QDomNotationPrivate::save(QTextStream& s,
int,
int)
const
5214 s <<
"<!NOTATION " << name <<
' ';
5215 if (!m_pub.isNull()) {
5216 s <<
"PUBLIC " << quotedValue(m_pub);
5217 if (!m_sys.isNull())
5218 s <<
' ' << quotedValue(m_sys);
5220 s <<
"SYSTEM " << quotedValue(m_sys);
5222 s <<
'>' << Qt::endl;
5226
5227
5228
5229
5231#define IMPL static_cast<QDomNotationPrivate *>(impl)
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5263
5264
5265QDomNotation::QDomNotation()
5271
5272
5273
5274
5275
5276
5277QDomNotation::QDomNotation(
const QDomNotation ¬ation)
5278 : QDomNode(notation)
5282QDomNotation::QDomNotation(QDomNotationPrivate* n)
5288
5289
5290
5291
5292
5293
5294QDomNotation &QDomNotation::operator=(
const QDomNotation &other) =
default;
5297
5298
5299
5300
5303
5304
5305QString QDomNotation::publicId()
const
5313
5314
5315QString QDomNotation::systemId()
const
5325
5326
5327
5328
5330QDomEntityPrivate::QDomEntityPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5331 const QString& aname,
5332 const QString& pub,
const QString& sys,
const QString& notation)
5333 : QDomNodePrivate(d, parent)
5338 m_notationName = notation;
5341QDomEntityPrivate::QDomEntityPrivate(QDomEntityPrivate* n,
bool deep)
5342 : QDomNodePrivate(n, deep)
5346 m_notationName = n->m_notationName;
5349QDomNodePrivate* QDomEntityPrivate::cloneNode(
bool deep)
5351 QDomNodePrivate* p =
new QDomEntityPrivate(
this, deep);
5358
5359
5360static QByteArray encodeEntity(
const QByteArray& str)
5362 QByteArray tmp(str);
5363 int len = tmp.size();
5365 const char* d = tmp.constData();
5368 tmp.replace(i, 1,
"<");
5369 d = tmp.constData();
5373 else if (d[i] ==
'"') {
5374 tmp.replace(i, 1,
""");
5375 d = tmp.constData();
5378 }
else if (d[i] ==
'&' && i + 1 < len && d[i+1] ==
'#') {
5381 tmp.replace(i, 1,
"&");
5382 d = tmp.constData();
5393void QDomEntityPrivate::save(QTextStream& s,
int,
int)
const
5395 QString _name = name;
5396 if (_name.startsWith(u'%'))
5397 _name = u"% "_s + _name.mid(1);
5399 if (m_sys.isNull() && m_pub.isNull()) {
5400 s <<
"<!ENTITY " << _name <<
" \"" << encodeEntity(value.toUtf8()) <<
"\">" << Qt::endl;
5402 s <<
"<!ENTITY " << _name <<
' ';
5403 if (m_pub.isNull()) {
5404 s <<
"SYSTEM " << quotedValue(m_sys);
5406 s <<
"PUBLIC " << quotedValue(m_pub) <<
' ' << quotedValue(m_sys);
5408 if (! m_notationName.isNull()) {
5409 s <<
" NDATA " << m_notationName;
5411 s <<
'>' << Qt::endl;
5416
5417
5418
5419
5421#define IMPL static_cast<QDomEntityPrivate *>(impl)
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5456
5457
5458QDomEntity::QDomEntity()
5465
5466
5467
5468
5469
5470
5471QDomEntity::QDomEntity(
const QDomEntity &entity)
5476QDomEntity::QDomEntity(QDomEntityPrivate* n)
5482
5483
5484
5485
5486
5487
5488QDomEntity &QDomEntity::operator=(
const QDomEntity &other) =
default;
5491
5492
5493
5494
5497
5498
5499
5500QString QDomEntity::publicId()
const
5508
5509
5510
5511QString QDomEntity::systemId()
const
5519
5520
5521
5522
5523QString QDomEntity::notationName()
const
5527 return IMPL->m_notationName;
5533
5534
5535
5536
5538QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& aname)
5539 : QDomNodePrivate(d, parent)
5544QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomNodePrivate* n,
bool deep)
5545 : QDomNodePrivate(n, deep)
5549QDomNodePrivate* QDomEntityReferencePrivate::cloneNode(
bool deep)
5551 QDomNodePrivate* p =
new QDomEntityReferencePrivate(
this, deep);
5557void QDomEntityReferencePrivate::save(QTextStream& s,
int,
int)
const
5559 s <<
'&' << name <<
';';
5563
5564
5565
5566
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5604
5605
5606
5607
5608QDomEntityReference::QDomEntityReference()
5614
5615
5616
5617
5618
5619
5620QDomEntityReference::QDomEntityReference(
const QDomEntityReference &entityReference)
5621 : QDomNode(entityReference)
5625QDomEntityReference::QDomEntityReference(QDomEntityReferencePrivate* n)
5631
5632
5633
5634
5635
5636
5637QDomEntityReference &QDomEntityReference::operator=(
const QDomEntityReference &other) =
default;
5640
5641
5642
5643
5646
5647
5648
5649
5651QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomDocumentPrivate* d,
5652 QDomNodePrivate* parent,
const QString& target,
const QString& data)
5653 : QDomNodePrivate(d, parent)
5659QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomProcessingInstructionPrivate* n,
bool deep)
5660 : QDomNodePrivate(n, deep)
5665QDomNodePrivate* QDomProcessingInstructionPrivate::cloneNode(
bool deep)
5667 QDomNodePrivate* p =
new QDomProcessingInstructionPrivate(
this, deep);
5673void QDomProcessingInstructionPrivate::save(QTextStream& s,
int,
int)
const
5675 s <<
"<?" << name <<
' ' << value <<
"?>" << Qt::endl;
5679
5680
5681
5682
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5718
5719
5720
5721
5722QDomProcessingInstruction::QDomProcessingInstruction()
5728
5729
5730
5731
5732
5733
5734QDomProcessingInstruction::QDomProcessingInstruction(
const QDomProcessingInstruction &processingInstruction)
5735 : QDomNode(processingInstruction)
5739QDomProcessingInstruction::QDomProcessingInstruction(QDomProcessingInstructionPrivate* n)
5745
5746
5747
5748
5749
5750
5751QDomProcessingInstruction &
5752QDomProcessingInstruction::operator=(
const QDomProcessingInstruction &other) =
default;
5755
5756
5757
5758
5761
5762
5763
5764
5765QString QDomProcessingInstruction::target()
const
5769 return impl->nodeName();
5773
5774
5775
5776
5777QString QDomProcessingInstruction::data()
const
5781 return impl->nodeValue();
5785
5786
5787
5788
5789void QDomProcessingInstruction::setData(
const QString &data)
5792 impl->setNodeValue(data);
5796
5797
5798
5799
5801QDomDocumentPrivate::QDomDocumentPrivate()
5802 : QDomNodePrivate(
nullptr),
5803 impl(
new QDomImplementationPrivate),
5806 type =
new QDomDocumentTypePrivate(
this,
this);
5809 name = u"#document"_s;
5812QDomDocumentPrivate::QDomDocumentPrivate(
const QString& aname)
5813 : QDomNodePrivate(
nullptr),
5814 impl(
new QDomImplementationPrivate),
5817 type =
new QDomDocumentTypePrivate(
this,
this);
5821 name = u"#document"_s;
5824QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt)
5825 : QDomNodePrivate(
nullptr),
5826 impl(
new QDomImplementationPrivate),
5829 if (dt !=
nullptr) {
5832 type =
new QDomDocumentTypePrivate(
this,
this);
5836 name = u"#document"_s;
5839QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentPrivate* n,
bool deep)
5840 : QDomNodePrivate(n, deep),
5841 impl(n->impl->clone()),
5844 type =
static_cast<QDomDocumentTypePrivate*>(n->type->cloneNode());
5845 type->setParent(
this);
5848QDomDocumentPrivate::~QDomDocumentPrivate()
5852void QDomDocumentPrivate::clear()
5856 QDomNodePrivate::clear();
5859QDomDocument::ParseResult QDomDocumentPrivate::setContent(QXmlStreamReader *reader,
5860 QDomDocument::ParseOptions options)
5863 impl =
new QDomImplementationPrivate;
5864 type =
new QDomDocumentTypePrivate(
this,
this);
5868 const auto error = u"Failed to set content, XML reader is not initialized"_s;
5869 qWarning(
"%s", qPrintable(error));
5873 QDomParser domParser(
this, reader, options);
5875 if (!domParser.parse())
5876 return domParser.result();
5880QDomNodePrivate* QDomDocumentPrivate::cloneNode(
bool deep)
5882 QDomNodePrivate *p =
new QDomDocumentPrivate(
this, deep);
5888QDomElementPrivate* QDomDocumentPrivate::documentElement()
5890 QDomNodePrivate *p = first;
5891 while (p && !p->isElement())
5894 return static_cast<QDomElementPrivate *>(p);
5897QDomElementPrivate* QDomDocumentPrivate::createElement(
const QString &tagName)
5900 QString fixedName = fixedXmlName(tagName, &ok);
5904 QDomElementPrivate *e =
new QDomElementPrivate(
this,
nullptr, fixedName);
5909QDomElementPrivate* QDomDocumentPrivate::createElementNS(
const QString &nsURI,
const QString &qName)
5912 QString fixedName = fixedXmlName(qName, &ok,
true);
5916 QDomElementPrivate *e =
new QDomElementPrivate(
this,
nullptr, nsURI, fixedName);
5921QDomDocumentFragmentPrivate* QDomDocumentPrivate::createDocumentFragment()
5923 QDomDocumentFragmentPrivate *f =
new QDomDocumentFragmentPrivate(
this,
nullptr);
5928QDomTextPrivate* QDomDocumentPrivate::createTextNode(
const QString &data)
5931 QString fixedData = fixedCharData(data, &ok);
5935 QDomTextPrivate *t =
new QDomTextPrivate(
this,
nullptr, fixedData);
5940QDomCommentPrivate* QDomDocumentPrivate::createComment(
const QString &data)
5943 QString fixedData = fixedComment(data, &ok);
5947 QDomCommentPrivate *c =
new QDomCommentPrivate(
this,
nullptr, fixedData);
5952QDomCDATASectionPrivate* QDomDocumentPrivate::createCDATASection(
const QString &data)
5955 QString fixedData = fixedCDataSection(data, &ok);
5959 QDomCDATASectionPrivate *c =
new QDomCDATASectionPrivate(
this,
nullptr, fixedData);
5964QDomProcessingInstructionPrivate* QDomDocumentPrivate::createProcessingInstruction(
const QString &target,
5965 const QString &data)
5968 QString fixedData = fixedPIData(data, &ok);
5972 QString fixedTarget = fixedXmlName(target, &ok);
5976 QDomProcessingInstructionPrivate *p =
new QDomProcessingInstructionPrivate(
this,
nullptr, fixedTarget, fixedData);
5980QDomAttrPrivate* QDomDocumentPrivate::createAttribute(
const QString &aname)
5983 QString fixedName = fixedXmlName(aname, &ok);
5987 QDomAttrPrivate *a =
new QDomAttrPrivate(
this,
nullptr, fixedName);
5992QDomAttrPrivate* QDomDocumentPrivate::createAttributeNS(
const QString &nsURI,
const QString &qName)
5995 QString fixedName = fixedXmlName(qName, &ok,
true);
5999 QDomAttrPrivate *a =
new QDomAttrPrivate(
this,
nullptr, nsURI, fixedName);
6004QDomEntityReferencePrivate* QDomDocumentPrivate::createEntityReference(
const QString &aname)
6007 QString fixedName = fixedXmlName(aname, &ok);
6011 QDomEntityReferencePrivate *e =
new QDomEntityReferencePrivate(
this,
nullptr, fixedName);
6016QDomNodePrivate* QDomDocumentPrivate::importNode(QDomNodePrivate *importedNode,
bool deep)
6018 QDomNodePrivate *node =
nullptr;
6019 switch (importedNode->nodeType()) {
6020 case QDomNode::AttributeNode:
6021 node =
new QDomAttrPrivate(
static_cast<QDomAttrPrivate *>(importedNode),
true);
6023 case QDomNode::DocumentFragmentNode:
6024 node =
new QDomDocumentFragmentPrivate(
6025 static_cast<QDomDocumentFragmentPrivate *>(importedNode), deep);
6027 case QDomNode::ElementNode:
6028 node =
new QDomElementPrivate(
static_cast<QDomElementPrivate *>(importedNode), deep);
6030 case QDomNode::EntityNode:
6031 node =
new QDomEntityPrivate(
static_cast<QDomEntityPrivate *>(importedNode), deep);
6033 case QDomNode::EntityReferenceNode:
6034 node =
new QDomEntityReferencePrivate(
6035 static_cast<QDomEntityReferencePrivate *>(importedNode),
false);
6037 case QDomNode::NotationNode:
6038 node =
new QDomNotationPrivate(
static_cast<QDomNotationPrivate *>(importedNode), deep);
6040 case QDomNode::ProcessingInstructionNode:
6041 node =
new QDomProcessingInstructionPrivate(
6042 static_cast<QDomProcessingInstructionPrivate *>(importedNode), deep);
6044 case QDomNode::TextNode:
6045 node =
new QDomTextPrivate(
static_cast<QDomTextPrivate *>(importedNode), deep);
6047 case QDomNode::CDATASectionNode:
6048 node =
new QDomCDATASectionPrivate(
static_cast<QDomCDATASectionPrivate *>(importedNode),
6051 case QDomNode::CommentNode:
6052 node =
new QDomCommentPrivate(
static_cast<QDomCommentPrivate *>(importedNode), deep);
6058 node->setOwnerDocument(
this);
6066void QDomDocumentPrivate::saveDocument(QTextStream& s,
const int indent, QDomNode::EncodingPolicy encUsed)
const
6068 const QDomNodePrivate* n = first;
6070 if (encUsed == QDomNode::EncodingFromDocument) {
6071#if QT_CONFIG(regularexpression)
6072 const QDomNodePrivate* n = first;
6074 if (n && n->isProcessingInstruction() && n->nodeName() ==
"xml"_L1) {
6076 QString data = n->nodeValue();
6077 QRegularExpression encoding(QString::fromLatin1(
"encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))"));
6078 auto match = encoding.match(data);
6079 QString enc = match.captured(3);
6081 enc = match.captured(5);
6082 if (!enc.isEmpty()) {
6083 auto encoding = QStringConverter::encodingForName(enc.toUtf8().constData());
6085 qWarning() <<
"QDomDocument::save(): Unsupported encoding" << enc <<
"specified.";
6087 s.setEncoding(encoding.value());
6094 if (!doc && !(n->isProcessingInstruction() && n->nodeName() ==
"xml"_L1)) {
6096 type->save(s, 0, indent);
6099 n->saveSubTree(n, s, 0, indent);
6106 const QByteArray codecName = QStringConverter::nameForEncoding(s.encoding());
6108 s <<
"<?xml version=\"1.0\" encoding=\""
6113 const QDomNodePrivate* startNode = n;
6117 if (n->isProcessingInstruction() && n->nodeName() ==
"xml"_L1) {
6118 startNode = n->next;
6127 startNode->saveSubTree(startNode, s, 0, indent);
6128 startNode = startNode->next;
6134
6135
6136
6137
6139#define IMPL static_cast<QDomDocumentPrivate *>(impl)
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6220
6221
6222QDomDocument::QDomDocument()
6228
6229
6230
6231QDomDocument::QDomDocument(
const QString& name)
6234 impl =
new QDomDocumentPrivate(name);
6238
6239
6240
6241
6242QDomDocument::QDomDocument(
const QDomDocumentType& doctype)
6244 impl =
new QDomDocumentPrivate(
static_cast<QDomDocumentTypePrivate *>(doctype.impl));
6248
6249
6250
6251
6252
6253
6254QDomDocument::QDomDocument(
const QDomDocument &document)
6255 : QDomNode(document)
6259QDomDocument::QDomDocument(QDomDocumentPrivate *pimpl)
6265
6266
6267
6268
6269
6270
6271QDomDocument &QDomDocument::operator=(
const QDomDocument &other) =
default;
6274
6275
6276QDomDocument::~QDomDocument()
6280#if QT_DEPRECATED_SINCE(6
, 8
)
6282QT_WARNING_DISABLE_DEPRECATED
6284
6285
6286
6287
6288
6289
6290
6291
6292bool QDomDocument::setContent(
const QString& text,
bool namespaceProcessing,
6293 QString *errorMsg,
int *errorLine,
int *errorColumn)
6295 QXmlStreamReader reader(text);
6296 reader.setNamespaceProcessing(namespaceProcessing);
6297 return setContent(&reader, namespaceProcessing, errorMsg, errorLine, errorColumn);
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352bool QDomDocument::setContent(
const QByteArray &data,
bool namespaceProcessing,
6353 QString *errorMsg,
int *errorLine,
int *errorColumn)
6355 QXmlStreamReader reader(data);
6356 reader.setNamespaceProcessing(namespaceProcessing);
6357 return setContent(&reader, namespaceProcessing, errorMsg, errorLine, errorColumn);
6360static inline QDomDocument::ParseOptions toParseOptions(
bool namespaceProcessing)
6362 return namespaceProcessing ? QDomDocument::ParseOption::UseNamespaceProcessing
6363 : QDomDocument::ParseOption::Default;
6366static inline void unpackParseResult(
const QDomDocument::ParseResult &parseResult,
6367 QString *errorMsg,
int *errorLine,
int *errorColumn)
6371 *errorMsg = parseResult.errorMessage;
6373 *errorLine =
static_cast<
int>(parseResult.errorLine);
6375 *errorColumn =
static_cast<
int>(parseResult.errorColumn);
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391bool QDomDocument::setContent(QIODevice* dev,
bool namespaceProcessing,
6392 QString *errorMsg,
int *errorLine,
int *errorColumn)
6394 ParseResult result = setContent(dev, toParseOptions(namespaceProcessing));
6395 unpackParseResult(result, errorMsg, errorLine, errorColumn);
6396 return bool(result);
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410bool QDomDocument::setContent(
const QString& text, QString *errorMsg,
int *errorLine,
int *errorColumn)
6412 return setContent(text,
false, errorMsg, errorLine, errorColumn);
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425bool QDomDocument::setContent(
const QByteArray& buffer, QString *errorMsg,
int *errorLine,
int *errorColumn )
6427 return setContent(buffer,
false, errorMsg, errorLine, errorColumn);
6431
6432
6433
6434
6435
6436
6437
6438
6439bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg,
int *errorLine,
int *errorColumn )
6441 return setContent(dev,
false, errorMsg, errorLine, errorColumn);
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464bool QDomDocument::setContent(QXmlStreamReader *reader,
bool namespaceProcessing,
6465 QString *errorMsg,
int *errorLine,
int *errorColumn)
6467 ParseResult result = setContent(reader, toParseOptions(namespaceProcessing));
6468 unpackParseResult(result, errorMsg, errorLine, errorColumn);
6469 return bool(result);
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6505
6506
6507
6508
6509
6510
6511
6514
6515
6516
6517
6518
6519
6520
6523
6524
6525
6526
6527
6528
6529
6532
6533
6534
6535
6536
6537
6538
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585QDomDocument::ParseResult QDomDocument::setContentImpl(
const QByteArray &data, ParseOptions options)
6587 QXmlStreamReader reader(data);
6588 reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
6589 return setContent(&reader, options);
6592QDomDocument::ParseResult QDomDocument::setContent(QAnyStringView data, ParseOptions options)
6594 QXmlStreamReader reader(data);
6595 reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
6596 return setContent(&reader, options);
6599QDomDocument::ParseResult QDomDocument::setContent(QIODevice *device, ParseOptions options)
6601#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
6602 if (!device->isOpen()) {
6603 qWarning(
"QDomDocument called with unopened QIODevice. "
6604 "This will not be supported in future Qt versions.");
6605 if (!device->open(QIODevice::ReadOnly)) {
6606 const auto error = u"QDomDocument::setContent: Failed to open device."_s;
6607 qWarning(
"%s", qPrintable(error));
6613 QXmlStreamReader reader(device);
6614 reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
6615 return setContent(&reader, options);
6618QDomDocument::ParseResult QDomDocument::setContent(QXmlStreamReader *reader, ParseOptions options)
6621 impl =
new QDomDocumentPrivate();
6622 return IMPL->setContent(reader, options);
6626
6627
6628
6629
6630
6631
6632
6633QString QDomDocument::toString(
int indent)
const
6636 QTextStream s(&str, QIODevice::WriteOnly);
6642
6643
6644
6645
6646
6647
6648
6649
6650QByteArray QDomDocument::toByteArray(
int indent)
const
6654 return toString(indent).toUtf8();
6659
6660
6661QDomDocumentType QDomDocument::doctype()
const
6664 return QDomDocumentType();
6665 return QDomDocumentType(IMPL->doctype());
6669
6670
6671QDomImplementation QDomDocument::implementation()
const
6674 return QDomImplementation();
6675 return QDomImplementation(IMPL->implementation());
6679
6680
6681QDomElement QDomDocument::documentElement()
const
6684 return QDomElement();
6685 return QDomElement(IMPL->documentElement());
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698QDomElement QDomDocument::createElement(
const QString& tagName)
6701 impl =
new QDomDocumentPrivate();
6702 return QDomElement(IMPL->createElement(tagName));
6706
6707
6708
6709
6710QDomDocumentFragment QDomDocument::createDocumentFragment()
6713 impl =
new QDomDocumentPrivate();
6714 return QDomDocumentFragment(IMPL->createDocumentFragment());
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727QDomText QDomDocument::createTextNode(
const QString& value)
6730 impl =
new QDomDocumentPrivate();
6731 return QDomText(IMPL->createTextNode(value));
6735
6736
6737
6738
6739
6740
6741
6742
6743QDomComment QDomDocument::createComment(
const QString& value)
6746 impl =
new QDomDocumentPrivate();
6747 return QDomComment(IMPL->createComment(value));
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760QDomCDATASection QDomDocument::createCDATASection(
const QString& value)
6763 impl =
new QDomDocumentPrivate();
6764 return QDomCDATASection(IMPL->createCDATASection(value));
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779QDomProcessingInstruction QDomDocument::createProcessingInstruction(
const QString& target,
6780 const QString& data)
6783 impl =
new QDomDocumentPrivate();
6784 return QDomProcessingInstruction(IMPL->createProcessingInstruction(target, data));
6789
6790
6791
6792
6793
6794
6795
6796
6797QDomAttr QDomDocument::createAttribute(
const QString& name)
6800 impl =
new QDomDocumentPrivate();
6801 return QDomAttr(IMPL->createAttribute(name));
6805
6806
6807
6808
6809
6810
6811
6812
6813QDomEntityReference QDomDocument::createEntityReference(
const QString& name)
6816 impl =
new QDomDocumentPrivate();
6817 return QDomEntityReference(IMPL->createEntityReference(name));
6821
6822
6823
6824
6825
6826
6827
6828QDomNodeList QDomDocument::elementsByTagName(
const QString& tagname)
const
6830 return QDomNodeList(
new QDomNodeListPrivate(impl, tagname));
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902QDomNode QDomDocument::importNode(
const QDomNode& importedNode,
bool deep)
6904 if (importedNode.isNull())
6907 impl =
new QDomDocumentPrivate();
6908 return QDomNode(IMPL->importNode(importedNode.impl, deep));
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923QDomElement QDomDocument::createElementNS(
const QString& nsURI,
const QString& qName)
6926 impl =
new QDomDocumentPrivate();
6927 return QDomElement(IMPL->createElementNS(nsURI, qName));
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942QDomAttr QDomDocument::createAttributeNS(
const QString& nsURI,
const QString& qName)
6945 impl =
new QDomDocumentPrivate();
6946 return QDomAttr(IMPL->createAttributeNS(nsURI, qName));
6950
6951
6952
6953
6954
6955
6956
6957QDomNodeList QDomDocument::elementsByTagNameNS(
const QString& nsURI,
const QString& localName)
6959 return QDomNodeList(
new QDomNodeListPrivate(impl, nsURI, localName));
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972QDomElement QDomDocument::elementById(
const QString& )
6974 qWarning(
"elementById() is not implemented and will always return a null node.");
6975 return QDomElement();
6979
6980
6981
6982
6987
6988
6989
6990
6993
6994
6995
6996
6997
6998QDomAttr QDomNode::toAttr()
const
7000 if (impl && impl->isAttr())
7001 return QDomAttr(
static_cast<QDomAttrPrivate *>(impl));
7006
7007
7008
7009
7010
7011QDomCDATASection QDomNode::toCDATASection()
const
7013 if (impl && impl->isCDATASection())
7014 return QDomCDATASection(
static_cast<QDomCDATASectionPrivate *>(impl));
7015 return QDomCDATASection();
7019
7020
7021
7022
7023
7024QDomDocumentFragment QDomNode::toDocumentFragment()
const
7026 if (impl && impl->isDocumentFragment())
7027 return QDomDocumentFragment(
static_cast<QDomDocumentFragmentPrivate *>(impl));
7028 return QDomDocumentFragment();
7032
7033
7034
7035
7036
7037QDomDocument QDomNode::toDocument()
const
7039 if (impl && impl->isDocument())
7040 return QDomDocument(
static_cast<QDomDocumentPrivate *>(impl));
7041 return QDomDocument();
7045
7046
7047
7048
7049
7050QDomDocumentType QDomNode::toDocumentType()
const
7052 if (impl && impl->isDocumentType())
7053 return QDomDocumentType(
static_cast<QDomDocumentTypePrivate *>(impl));
7054 return QDomDocumentType();
7058
7059
7060
7061
7062
7063QDomElement QDomNode::toElement()
const
7065 if (impl && impl->isElement())
7066 return QDomElement(
static_cast<QDomElementPrivate *>(impl));
7067 return QDomElement();
7071
7072
7073
7074
7075
7076QDomEntityReference QDomNode::toEntityReference()
const
7078 if (impl && impl->isEntityReference())
7079 return QDomEntityReference(
static_cast<QDomEntityReferencePrivate *>(impl));
7080 return QDomEntityReference();
7084
7085
7086
7087
7088
7089QDomText QDomNode::toText()
const
7091 if (impl && impl->isText())
7092 return QDomText(
static_cast<QDomTextPrivate *>(impl));
7097
7098
7099
7100
7101
7102QDomEntity QDomNode::toEntity()
const
7104 if (impl && impl->isEntity())
7105 return QDomEntity(
static_cast<QDomEntityPrivate *>(impl));
7106 return QDomEntity();
7110
7111
7112
7113
7114
7115QDomNotation QDomNode::toNotation()
const
7117 if (impl && impl->isNotation())
7118 return QDomNotation(
static_cast<QDomNotationPrivate *>(impl));
7119 return QDomNotation();
7123
7124
7125
7126
7127
7128QDomProcessingInstruction QDomNode::toProcessingInstruction()
const
7130 if (impl && impl->isProcessingInstruction())
7131 return QDomProcessingInstruction(
static_cast<QDomProcessingInstructionPrivate *>(impl));
7132 return QDomProcessingInstruction();
7136
7137
7138
7139
7140
7141QDomCharacterData QDomNode::toCharacterData()
const
7143 if (impl && impl->isCharacterData())
7144 return QDomCharacterData(
static_cast<QDomCharacterDataPrivate *>(impl));
7145 return QDomCharacterData();
7149
7150
7151
7152
7153
7154QDomComment QDomNode::toComment()
const
7156 if (impl && impl->isComment())
7157 return QDomComment(
static_cast<QDomCommentPrivate *>(impl));
7158 return QDomComment();
7162
7163
7164
7165