5#include <qplatformdefs.h>
7#include "private/qxmlutils_p.h"
12#include "qdomhelpers_p.h"
17#if QT_CONFIG(regularexpression)
18#include <qregularexpression.h>
20#include <qtextstream.h>
22#include <qshareddata.h>
24#include <qxmlstream.h>
25#include <private/qduplicatetracker_p.h>
26#include <private/qstringiterator_p.h>
27#include <qvarlengtharray.h>
35using namespace Qt::StringLiterals;
38
39
40
41
42
43
44
45
46
47
50
51
52
53
54
55
58
59
60
61
62
63
64
65
66
67
68
72
73
74static void qt_split_namespace(QString& prefix, QString& name,
const QString& qName,
bool hasURI)
76 qsizetype i = qName.indexOf(u':');
84 prefix = qName.left(i);
85 name = qName.mid(i + 1);
90
91
92
93
94QDomImplementation::InvalidDataPolicy QDomImplementationPrivate::invalidDataPolicy
95 = QDomImplementation::AcceptInvalidChars;
99static QString fixedXmlName(
const QString &_name,
bool *ok,
bool namespaces =
false)
101 QString name, prefix;
103 qt_split_namespace(prefix, name, _name,
true);
107 if (name.isEmpty()) {
112 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
118 bool firstChar =
true;
119 for (
int i = 0; i < name.size(); ++i) {
120 QChar c = name.at(i);
122 if (QXmlUtils::isLetter(c) || c.unicode() ==
'_' || c.unicode() ==
':') {
125 }
else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
130 if (QXmlUtils::isNameChar(c))
132 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
139 if (result.isEmpty()) {
145 if (namespaces && !prefix.isEmpty())
146 return prefix + u':' + result;
153static QString fixedCharData(
const QString &data,
bool *ok)
155 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
161 QStringIterator it(data);
162 while (it.hasNext()) {
163 const char32_t c = it.next(QChar::Null);
164 if (QXmlUtils::isChar(c)) {
165 result.append(QChar::fromUcs4(c));
166 }
else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
179static QString fixedComment(
const QString &data,
bool *ok)
181 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
186 QString fixedData = fixedCharData(data, ok);
191 qsizetype idx = fixedData.indexOf(
"--"_L1);
194 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
198 fixedData.remove(idx, 2);
208static QString fixedCDataSection(
const QString &data,
bool *ok)
210 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
215 QString fixedData = fixedCharData(data, ok);
220 qsizetype idx = fixedData.indexOf(
"]]>"_L1);
223 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
227 fixedData.remove(idx, 3);
236static QString fixedPIData(
const QString &data,
bool *ok)
238 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
243 QString fixedData = fixedCharData(data, ok);
248 qsizetype idx = fixedData.indexOf(
"?>"_L1);
251 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
255 fixedData.remove(idx, 2);
265static QString fixedPubidLiteral(
const QString &data,
bool *ok)
267 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
274 if (QXmlUtils::isPublicID(data))
276 else if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
281 if (result.indexOf(u'\'') != -1 && result.indexOf(u'"') != -1) {
282 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
286 result.remove(u'\'');
297static QString fixedSystemLiteral(
const QString &data,
bool *ok)
299 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::AcceptInvalidChars) {
304 QString result = data;
306 if (result.indexOf(u'\'') != -1 && result.indexOf(u'"') != -1) {
307 if (QDomImplementationPrivate::invalidDataPolicy == QDomImplementation::ReturnNullNode) {
311 result.remove(u'\'');
320
321
322
323
325QDomImplementationPrivate* QDomImplementationPrivate::clone()
327 return new QDomImplementationPrivate;
331
332
333
334
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
367
370
371
372QDomImplementation::QDomImplementation()
378
379
380QDomImplementation::QDomImplementation(
const QDomImplementation &implementation)
381 : impl(implementation.impl)
387QDomImplementation::QDomImplementation(QDomImplementationPrivate *pimpl)
396
397
398QDomImplementation& QDomImplementation::operator=(
const QDomImplementation &other)
401 other.impl->ref.ref();
402 if (impl && !impl->ref.deref())
409
410
411
412bool QDomImplementation::operator==(
const QDomImplementation &other)
const
414 return impl == other.impl;
418
419
420
421bool QDomImplementation::operator!=(
const QDomImplementation &other)
const
423 return !operator==(other);
427
428
429QDomImplementation::~QDomImplementation()
431 if (impl && !impl->ref.deref())
436
437
438
439
440
441
442
443
444
445bool QDomImplementation::hasFeature(
const QString& feature,
const QString& version)
const
447 if (feature ==
"XML"_L1) {
448 if (version.isEmpty() || version ==
"1.0"_L1)
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
486
487QDomDocumentType QDomImplementation::createDocumentType(
const QString& qName,
const QString& publicId,
const QString& systemId)
490 QString fixedName = fixedXmlName(qName, &ok,
true);
492 return QDomDocumentType();
494 QString fixedPublicId = fixedPubidLiteral(publicId, &ok);
496 return QDomDocumentType();
498 QString fixedSystemId = fixedSystemLiteral(systemId, &ok);
500 return QDomDocumentType();
502 QDomDocumentTypePrivate *dt =
new QDomDocumentTypePrivate(
nullptr);
503 dt->name = fixedName;
504 if (systemId.isNull()) {
505 dt->publicId.clear();
506 dt->systemId.clear();
508 dt->publicId = fixedPublicId;
509 dt->systemId = fixedSystemId;
512 return QDomDocumentType(dt);
516
517
518
519
520QDomDocument QDomImplementation::createDocument(
const QString& nsURI,
const QString& qName,
const QDomDocumentType& doctype)
522 QDomDocument doc(doctype);
523 QDomElement root = doc.createElementNS(nsURI, qName);
525 return QDomDocument();
526 doc.appendChild(root);
531
532
533
534bool QDomImplementation::isNull()
536 return (impl ==
nullptr);
540
541
542
543
544
545
546
547
548
549
550
551
552
555
556
557
558
559
560
561
562
563
564
565
568
569
570
571
572
573
574
575
577QDomImplementation::InvalidDataPolicy QDomImplementation::invalidDataPolicy()
579 return QDomImplementationPrivate::invalidDataPolicy;
583
584
585
586
587
588
589
590
591
592
593
594
595
597void QDomImplementation::setInvalidDataPolicy(InvalidDataPolicy policy)
599 QDomImplementationPrivate::invalidDataPolicy = policy;
603
604
605
606
608QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl) : ref(1)
612 node_impl->ref.ref();
616QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl,
const QString &name) :
621 node_impl->ref.ref();
626QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl,
const QString &_nsURI,
const QString &localName) :
631 node_impl->ref.ref();
637QDomNodeListPrivate::~QDomNodeListPrivate()
639 if (node_impl && !node_impl->ref.deref())
643bool QDomNodeListPrivate::operator==(
const QDomNodeListPrivate &other)
const noexcept
645 return (node_impl == other.node_impl) && (tagname == other.tagname);
648void QDomNodeListPrivate::createList()
const
654 const QDomDocumentPrivate *
const doc = node_impl->ownerDocument();
655 if (doc && timestamp != doc->nodeListTime)
656 timestamp = doc->nodeListTime;
657 forEachNode([&](QDomNodePrivate *p){ list.append(p); });
661
662
663
664
665bool QDomNodeListPrivate::checkNode(QDomNodePrivate *p)
const
667 return p && p->isElement() && (nsURI.isNull()
668 ? p->nodeName() == tagname
669 : p->name == tagname && p->namespaceURI == nsURI);
673
674
675
676
677
678
679
680
681QDomNodePrivate *QDomNodeListPrivate::findNextInOrder(QDomNodePrivate *p)
const
686 if (tagname.isNull()) {
689 else if (p && p->next)
693 if (p == node_impl) {
698 while (p && p != node_impl) {
701 }
else if (p->next) {
705 while (p && p != node_impl && !p->next)
707 if (p && p != node_impl)
717
718
719
720
721
722QDomNodePrivate *QDomNodeListPrivate::findPrevInOrder(QDomNodePrivate *p)
const
727 if (tagname.isNull() && p == node_impl)
729 if (tagname.isNull())
734 if (p == node_impl) {
756void QDomNodeListPrivate::forEachNode(qxp::function_ref<
void(QDomNodePrivate*)> yield)
const
761 QDomNodePrivate *current = findNextInOrder(node_impl);
762 while (current && current != node_impl) {
764 current = findNextInOrder(current);
768bool QDomNodeListPrivate::maybeCreateList()
const
773 const QDomDocumentPrivate *
const doc = node_impl->ownerDocument();
774 if (!doc || timestamp != doc->nodeListTime)
780QDomNodePrivate *QDomNodeListPrivate::item(
int index)
782 if (!maybeCreateList() || index >= list.size() || index < 0)
785 return list.at(index);
788int QDomNodeListPrivate::length()
const
790 if (!maybeCreateList())
796int QDomNodeListPrivate::noexceptLength()
const noexcept
799 forEachNode([&](QDomNodePrivate*){ ++count; });
804
805
806
807
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
835
836
837QDomNodeList::QDomNodeList()
842QDomNodeList::QDomNodeList(QDomNodeListPrivate *pimpl)
848
849
850QDomNodeList::QDomNodeList(
const QDomNodeList &nodeList)
851 : impl(nodeList.impl)
858
859
860QDomNodeList& QDomNodeList::operator=(
const QDomNodeList &other)
863 other.impl->ref.ref();
864 if (impl && !impl->ref.deref())
871
872
873
874
875
876bool comparesEqual(
const QDomNodeList &lhs,
const QDomNodeList &rhs)
noexcept
878 if (lhs.impl == rhs.impl)
880 if (!lhs.impl || !rhs.impl)
882 return *lhs.impl == *rhs.impl;
886
887
888
889
890
893
894
895QDomNodeList::~QDomNodeList()
897 if (impl && !impl->ref.deref())
902
903
904
905
906
907
908
909
910QDomNode QDomNodeList::item(
int index)
const
915 return QDomNode(impl->item(index));
919
920
921int QDomNodeList::length()
const
925 return impl->length();
929
930
931int QDomNodeList::noexceptLength()
const noexcept
935 return impl->noexceptLength();
939
940
941
942
943
946
947
948
949
952
953
954
955
958
959
960
961
962
963
964
965
966
969
970
971
972
973
974
975
976
977
978
981
982
983
984
985
986
987
988
989
990
991
992
993
994
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1016QDomNodeList::It::It(
const QDomNodeListPrivate *lp,
bool start)
noexcept
1019 if (!lp || !lp->node_impl)
1022 current = lp->findNextInOrder(lp->node_impl);
1024 current = lp->node_impl;
1027QDomNodePrivate *QDomNodeList::It::findNextInOrder(
const QDomNodeListPrivate *parent, QDomNodePrivate *current)
1029 return parent->findNextInOrder(current);
1032QDomNodePrivate *QDomNodeList::It::findPrevInOrder(
const QDomNodeListPrivate *parent, QDomNodePrivate *current)
1034 return parent->findPrevInOrder(current);
1038
1039
1040
1041
1043inline void QDomNodePrivate::setOwnerDocument(QDomDocumentPrivate *doc)
1049QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) : ref(1)
1054 setOwnerDocument(doc);
1059 createdWithDom1Interface =
true;
1064QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n,
bool deep) : ref(1)
1066 setOwnerDocument(n->ownerDocument());
1075 namespaceURI = n->namespaceURI;
1076 createdWithDom1Interface = n->createdWithDom1Interface;
1083 for (QDomNodePrivate* x = n->first; x; x = x->next)
1084 appendChild(x->cloneNode(
true));
1087QDomNodePrivate::~QDomNodePrivate()
1089 QDomNodePrivate* p = first;
1094 if (!p->ref.deref())
1104void QDomNodePrivate::clear()
1106 QDomNodePrivate* p = first;
1111 if (!p->ref.deref())
1119QDomNodePrivate* QDomNodePrivate::namedItem(
const QString &n)
1121 QDomNodePrivate* p = first;
1123 if (p->nodeName() == n)
1131QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
1138 if (newChild == refChild)
1142 if (refChild && refChild->parent() !=
this)
1146 QDomDocumentPrivate *
const doc = ownerDocument();
1148 doc->nodeListTime++;
1152 if (newChild->isDocumentFragment()) {
1154 if (newChild->first ==
nullptr)
1158 QDomNodePrivate* n = newChild->first;
1165 if (!refChild || refChild->prev ==
nullptr) {
1167 first->prev = newChild->last;
1168 newChild->last->next = first;
1170 last = newChild->last;
1171 first = newChild->first;
1174 newChild->last->next = refChild;
1175 newChild->first->prev = refChild->prev;
1176 refChild->prev->next = newChild->first;
1177 refChild->prev = newChild->last;
1184 newChild->first =
nullptr;
1185 newChild->last =
nullptr;
1191 newChild->ref.ref();
1193 if (newChild->parent())
1194 newChild->parent()->removeChild(newChild);
1196 newChild->setParent(
this);
1200 first->prev = newChild;
1201 newChild->next = first;
1208 if (refChild->prev ==
nullptr) {
1210 first->prev = newChild;
1211 newChild->next = first;
1218 newChild->next = refChild;
1219 newChild->prev = refChild->prev;
1220 refChild->prev->next = newChild;
1221 refChild->prev = newChild;
1226QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
1233 if (newChild == refChild)
1237 if (refChild && refChild->parent() !=
this)
1241 QDomDocumentPrivate *
const doc = ownerDocument();
1243 doc->nodeListTime++;
1247 if (newChild->isDocumentFragment()) {
1249 if (newChild->first ==
nullptr)
1253 QDomNodePrivate* n = newChild->first;
1260 if (!refChild || refChild->next ==
nullptr) {
1262 last->next = newChild->first;
1263 newChild->first->prev = last;
1265 first = newChild->first;
1266 last = newChild->last;
1268 newChild->first->prev = refChild;
1269 newChild->last->next = refChild->next;
1270 refChild->next->prev = newChild->last;
1271 refChild->next = newChild->first;
1278 newChild->first =
nullptr;
1279 newChild->last =
nullptr;
1284 if (newChild->parent())
1285 newChild->parent()->removeChild(newChild);
1289 newChild->ref.ref();
1291 newChild->setParent(
this);
1296 last->next = newChild;
1297 newChild->prev = last;
1304 if (refChild->next ==
nullptr) {
1306 last->next = newChild;
1307 newChild->prev = last;
1314 newChild->prev = refChild;
1315 newChild->next = refChild->next;
1316 refChild->next->prev = newChild;
1317 refChild->next = newChild;
1322QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild)
1324 if (!newChild || !oldChild)
1326 if (oldChild->parent() !=
this)
1328 if (newChild == oldChild)
1332 QDomDocumentPrivate *
const doc = ownerDocument();
1334 doc->nodeListTime++;
1338 if (newChild->isDocumentFragment()) {
1340 if (newChild->first ==
nullptr)
1344 QDomNodePrivate* n = newChild->first;
1352 oldChild->next->prev = newChild->last;
1354 oldChild->prev->next = newChild->first;
1356 newChild->last->next = oldChild->next;
1357 newChild->first->prev = oldChild->prev;
1359 if (first == oldChild)
1360 first = newChild->first;
1361 if (last == oldChild)
1362 last = newChild->last;
1364 oldChild->setNoParent();
1365 oldChild->next =
nullptr;
1366 oldChild->prev =
nullptr;
1372 newChild->first =
nullptr;
1373 newChild->last =
nullptr;
1376 oldChild->ref.deref();
1383 newChild->ref.ref();
1386 if (newChild->parent())
1387 newChild->parent()->removeChild(newChild);
1389 newChild->setParent(
this);
1392 oldChild->next->prev = newChild;
1394 oldChild->prev->next = newChild;
1396 newChild->next = oldChild->next;
1397 newChild->prev = oldChild->prev;
1399 if (first == oldChild)
1401 if (last == oldChild)
1404 oldChild->setNoParent();
1405 oldChild->next =
nullptr;
1406 oldChild->prev =
nullptr;
1409 oldChild->ref.deref();
1414QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild)
1417 if (oldChild->parent() !=
this)
1421 QDomDocumentPrivate *
const doc = ownerDocument();
1423 doc->nodeListTime++;
1427 if (oldChild->next ==
nullptr && oldChild->prev ==
nullptr && first != oldChild)
1431 oldChild->next->prev = oldChild->prev;
1433 oldChild->prev->next = oldChild->next;
1435 if (last == oldChild)
1436 last = oldChild->prev;
1437 if (first == oldChild)
1438 first = oldChild->next;
1440 oldChild->setNoParent();
1441 oldChild->next =
nullptr;
1442 oldChild->prev =
nullptr;
1445 oldChild->ref.deref();
1450QDomNodePrivate* QDomNodePrivate::appendChild(QDomNodePrivate* newChild)
1453 return insertAfter(newChild,
nullptr);
1456QDomDocumentPrivate* QDomNodePrivate::ownerDocument()
1458 QDomNodePrivate* p =
this;
1459 while (p && !p->isDocument()) {
1461 return static_cast<QDomDocumentPrivate *>(p->ownerNode);
1465 return static_cast<QDomDocumentPrivate *>(p);
1468QDomNodePrivate* QDomNodePrivate::cloneNode(
bool deep)
1470 QDomNodePrivate* p =
new QDomNodePrivate(
this, deep);
1476static void qNormalizeNode(QDomNodePrivate* n)
1478 QDomNodePrivate* p = n->first;
1479 QDomTextPrivate* t =
nullptr;
1484 QDomNodePrivate* tmp = p->next;
1485 t->appendData(p->nodeValue());
1489 t =
static_cast<QDomTextPrivate *>(p);
1498void QDomNodePrivate::normalize()
1502 qNormalizeNode(
this);
1505void QDomNodePrivate::saveSubTree(
const QDomNodePrivate *n, QTextStream &s,
1506 int depth,
int indent)
const
1511 const QDomNodePrivate *root = n->first;
1512 n->save(s, depth, indent);
1514 const int branchDepth = depth + 1;
1517 root->save(s, layerDepth + branchDepth, indent);
1524 root->afterSave(s, layerDepth + branchDepth, indent);
1525 const QDomNodePrivate *prev = root;
1528 while (!root && (layerDepth > 0)) {
1529 root = prev->parent();
1531 root->afterSave(s, layerDepth + branchDepth, indent);
1536 Q_ASSERT(layerDepth == 0);
1538 n->afterSave(s, depth, indent);
1541void QDomNodePrivate::setLocation(
int lineNumber,
int columnNumber)
1543 this->lineNumber = lineNumber;
1544 this->columnNumber = columnNumber;
1548
1549
1550
1551
1553#define IMPL static_cast<QDomNodePrivate *>(impl)
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
1637
1640
1641
1648
1649
1650
1651
1652
1653
1654QDomNode::QDomNode(
const QDomNode &node)
1662
1663
1664QDomNode::QDomNode(QDomNodePrivate *pimpl)
1672
1673
1674
1675
1676
1677
1678QDomNode& QDomNode::operator=(
const QDomNode &other)
1681 other.impl->ref.ref();
1682 if (impl && !impl->ref.deref())
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708bool QDomNode::operator==(
const QDomNode &other)
const
1710 return impl == other.impl;
1714
1715
1716
1717bool QDomNode::operator!=(
const QDomNode &other)
const
1719 return !operator==(other);
1723
1724
1725QDomNode::~QDomNode()
1727 if (impl && !impl->ref.deref())
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
1759
1760QString QDomNode::nodeName()
const
1765 if (!IMPL->prefix.isEmpty())
1766 return IMPL->prefix + u':' + IMPL->name;
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788QString QDomNode::nodeValue()
const
1796
1797
1798
1799
1800void QDomNode::setNodeValue(
const QString& value)
1803 IMPL->setNodeValue(value);
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1827
1828
1829
1830
1831
1832
1833
1834QDomNode::NodeType QDomNode::nodeType()
const
1837 return QDomNode::BaseNode;
1838 return IMPL->nodeType();
1842
1843
1844
1845QDomNode QDomNode::parentNode()
const
1849 return QDomNode(IMPL->parent());
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870QDomNodeList QDomNode::childNodes()
const
1873 return QDomNodeList();
1874 return QDomNodeList(
new QDomNodeListPrivate(impl));
1878
1879
1880
1881
1882
1883
1884QDomNode QDomNode::firstChild()
const
1888 return QDomNode(IMPL->first);
1892
1893
1894
1895
1896
1897
1898QDomNode QDomNode::lastChild()
const
1902 return QDomNode(IMPL->last);
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918QDomNode QDomNode::previousSibling()
const
1922 return QDomNode(IMPL->prev);
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938QDomNode QDomNode::nextSibling()
const
1942 return QDomNode(IMPL->next);
1948
1949
1950
1951
1952
1953
1954QDomNamedNodeMap QDomNode::attributes()
const
1956 if (!impl || !impl->isElement())
1957 return QDomNamedNodeMap();
1959 return QDomNamedNodeMap(
static_cast<QDomElementPrivate *>(impl)->attributes());
1963
1964
1965QDomDocument QDomNode::ownerDocument()
const
1968 return QDomDocument();
1969 return QDomDocument(IMPL->ownerDocument());
1973
1974
1975
1976
1977
1978
1979
1980QDomNode QDomNode::cloneNode(
bool deep)
const
1984 return QDomNode(IMPL->cloneNode(deep));
1988
1989
1990
1991
1992
1993void QDomNode::normalize()
2001
2002
2003
2004
2005
2006
2007bool QDomNode::isSupported(
const QString& feature,
const QString& version)
const
2009 QDomImplementation i;
2010 return i.hasFeature(feature, version);
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025QString QDomNode::namespaceURI()
const
2029 return IMPL->namespaceURI;
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054QString QDomNode::prefix()
const
2058 return IMPL->prefix;
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075void QDomNode::setPrefix(
const QString& pre)
2077 if (!impl || IMPL->prefix.isNull())
2079 if (isAttr() || isElement())
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095QString QDomNode::localName()
const
2097 if (!impl || IMPL->createdWithDom1Interface)
2103
2104
2105
2106
2107bool QDomNode::hasAttributes()
const
2109 if (!impl || !impl->isElement())
2111 return static_cast<QDomElementPrivate *>(impl)->hasAttributes();
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135QDomNode QDomNode::insertBefore(
const QDomNode& newChild,
const QDomNode& refChild)
2139 return QDomNode(IMPL->insertBefore(newChild.impl, refChild.impl));
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163QDomNode QDomNode::insertAfter(
const QDomNode& newChild,
const QDomNode& refChild)
2167 return QDomNode(IMPL->insertAfter(newChild.impl, refChild.impl));
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185QDomNode QDomNode::replaceChild(
const QDomNode& newChild,
const QDomNode& oldChild)
2187 if (!impl || !newChild.impl || !oldChild.impl)
2189 return QDomNode(IMPL->replaceChild(newChild.impl, oldChild.impl));
2193
2194
2195
2196
2197
2198
2199
2200QDomNode QDomNode::removeChild(
const QDomNode& oldChild)
2205 if (oldChild.isNull())
2208 return QDomNode(IMPL->removeChild(oldChild.impl));
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235QDomNode QDomNode::appendChild(
const QDomNode& newChild)
2238 qWarning(
"Calling appendChild() on a null node does nothing.");
2241 return QDomNode(IMPL->appendChild(newChild.impl));
2245
2246
2247
2248bool QDomNode::hasChildNodes()
const
2252 return IMPL->first !=
nullptr;
2256
2257
2258
2259bool QDomNode::isNull()
const
2261 return (impl ==
nullptr);
2265
2266
2267
2268
2269
2270void QDomNode::clear()
2272 if (impl && !impl->ref.deref())
2278
2279
2280
2281
2282
2283
2284
2285
2286QDomNode QDomNode::namedItem(
const QString& name)
const
2290 return QDomNode(impl->namedItem(name));
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318void QDomNode::save(QTextStream& stream,
int indent, EncodingPolicy encodingPolicy)
const
2324 static_cast<
const QDomDocumentPrivate *>(impl)->saveDocument(stream, indent, encodingPolicy);
2326 IMPL->saveSubTree(IMPL, stream, 1, indent);
2330
2331
2332
2333
2334
2335QTextStream& operator<<(QTextStream& str,
const QDomNode& node)
2343
2344
2345
2346
2347
2348
2349
2350
2351bool QDomNode::isAttr()
const
2354 return impl->isAttr();
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368bool QDomNode::isCDATASection()
const
2371 return impl->isCDATASection();
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385bool QDomNode::isDocumentFragment()
const
2388 return impl->isDocumentFragment();
2393
2394
2395
2396
2397
2398
2399
2400bool QDomNode::isDocument()
const
2403 return impl->isDocument();
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417bool QDomNode::isDocumentType()
const
2420 return impl->isDocumentType();
2425
2426
2427
2428
2429
2430
2431
2432bool QDomNode::isElement()
const
2435 return impl->isElement();
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449bool QDomNode::isEntityReference()
const
2452 return impl->isEntityReference();
2457
2458
2459
2460
2461
2462
2463
2464bool QDomNode::isText()
const
2467 return impl->isText();
2472
2473
2474
2475
2476
2477
2478
2479bool QDomNode::isEntity()
const
2482 return impl->isEntity();
2487
2488
2489
2490
2491
2492
2493
2494bool QDomNode::isNotation()
const
2497 return impl->isNotation();
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511bool QDomNode::isProcessingInstruction()
const
2514 return impl->isProcessingInstruction();
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528bool QDomNode::isCharacterData()
const
2531 return impl->isCharacterData();
2536
2537
2538
2539
2540
2541
2542
2543bool QDomNode::isComment()
const
2546 return impl->isComment();
2553
2554
2555
2556
2557
2558
2559
2560
2562QDomElement QDomNode::firstChildElement(
const QString &tagName,
const QString &namespaceURI)
const
2564 for (QDomNode child = firstChild(); !child.isNull(); child = child.nextSibling()) {
2565 if (child.isElement() && (namespaceURI.isEmpty() || child.namespaceURI() == namespaceURI)) {
2566 QDomElement elt = child.toElement();
2567 if (tagName.isEmpty() || elt.tagName() == tagName)
2571 return QDomElement();
2575
2576
2577
2578
2579
2580
2581
2582
2584QDomElement QDomNode::lastChildElement(
const QString &tagName,
const QString &namespaceURI)
const
2586 for (QDomNode child = lastChild(); !child.isNull(); child = child.previousSibling()) {
2587 if (child.isElement() && (namespaceURI.isEmpty() || child.namespaceURI() == namespaceURI)) {
2588 QDomElement elt = child.toElement();
2589 if (tagName.isEmpty() || elt.tagName() == tagName)
2593 return QDomElement();
2597
2598
2599
2600
2601
2602
2603
2604
2605
2607QDomElement QDomNode::nextSiblingElement(
const QString &tagName,
const QString &namespaceURI)
const
2609 for (QDomNode sib = nextSibling(); !sib.isNull(); sib = sib.nextSibling()) {
2610 if (sib.isElement() && (namespaceURI.isEmpty() || sib.namespaceURI() == namespaceURI)) {
2611 QDomElement elt = sib.toElement();
2612 if (tagName.isEmpty() || elt.tagName() == tagName)
2616 return QDomElement();
2620
2621
2622
2623
2624
2625
2626
2627
2628
2630QDomElement QDomNode::previousSiblingElement(
const QString &tagName,
const QString &namespaceURI)
const
2632 for (QDomNode sib = previousSibling(); !sib.isNull(); sib = sib.previousSibling()) {
2633 if (sib.isElement() && (namespaceURI.isEmpty() || sib.namespaceURI() == namespaceURI)) {
2634 QDomElement elt = sib.toElement();
2635 if (tagName.isEmpty() || elt.tagName() == tagName)
2639 return QDomElement();
2643
2644
2645
2646
2647
2648
2649
2650
2651int QDomNode::lineNumber()
const
2653 return impl ? impl->lineNumber : -1;
2657
2658
2659
2660
2661
2662
2663
2664
2665int QDomNode::columnNumber()
const
2667 return impl ? impl->columnNumber : -1;
2672
2673
2674
2675
2677QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate(QDomNodePrivate *pimpl)
2681 , appendToParent(
false)
2685QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate()
2690QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate *pimpl)
2692 std::unique_ptr<QDomNamedNodeMapPrivate> m(
new QDomNamedNodeMapPrivate(pimpl));
2693 m->readonly = readonly;
2694 m->appendToParent = appendToParent;
2696 auto it = map.constBegin();
2697 for (; it != map.constEnd(); ++it) {
2698 QDomNodePrivate *new_node = it.value()->cloneNode();
2699 new_node->setParent(pimpl);
2700 m->setNamedItem(new_node);
2708void QDomNamedNodeMapPrivate::clearMap()
2711 if (!appendToParent) {
2712 auto it = map.constBegin();
2713 for (; it != map.constEnd(); ++it)
2714 if (!it.value()->ref.deref())
2720QDomNodePrivate* QDomNamedNodeMapPrivate::namedItem(
const QString& name)
const
2722 auto it = map.find(name);
2723 return it == map.end() ?
nullptr : it.value();
2726QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(
const QString& nsURI,
const QString& localName)
const
2728 auto it = map.constBegin();
2730 for (; it != map.constEnd(); ++it) {
2732 if (!n->prefix.isNull()) {
2734 if (n->namespaceURI == nsURI && n->name == localName)
2741QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg)
2743 if (readonly || !arg)
2747 return parent->appendChild(arg);
2749 QDomNodePrivate *n = map.value(arg->nodeName());
2752 map.insert(arg->nodeName(), arg);
2756QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg)
2758 if (readonly || !arg)
2762 return parent->appendChild(arg);
2764 if (!arg->prefix.isNull()) {
2766 QDomNodePrivate *n = namedItemNS(arg->namespaceURI, arg->name);
2769 map.insert(arg->nodeName(), arg);
2773 return setNamedItem(arg);
2777QDomNodePrivate* QDomNamedNodeMapPrivate::removeNamedItem(
const QString& name)
2782 QDomNodePrivate* p = namedItem(name);
2786 return parent->removeChild(p);
2788 map.remove(p->nodeName());
2794QDomNodePrivate* QDomNamedNodeMapPrivate::item(
int index)
const
2796 if (index >= length() || index < 0)
2798 return std::next(map.begin(), index).value();
2801int QDomNamedNodeMapPrivate::length()
const
2806bool QDomNamedNodeMapPrivate::contains(
const QString& name)
const
2808 return map.contains(name);
2811bool QDomNamedNodeMapPrivate::containsNS(
const QString& nsURI,
const QString & localName)
const
2813 return namedItemNS(nsURI, localName) !=
nullptr;
2817
2818
2819
2820
2822#define IMPL static_cast<QDomNamedNodeMapPrivate *>(impl)
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
2860
2863
2864
2865QDomNamedNodeMap::QDomNamedNodeMap()
2871
2872
2873QDomNamedNodeMap::QDomNamedNodeMap(
const QDomNamedNodeMap &namedNodeMap)
2874 : impl(namedNodeMap.impl)
2880QDomNamedNodeMap::QDomNamedNodeMap(QDomNamedNodeMapPrivate *pimpl)
2888
2889
2890QDomNamedNodeMap& QDomNamedNodeMap::operator=(
const QDomNamedNodeMap &other)
2893 other.impl->ref.ref();
2894 if (impl && !impl->ref.deref())
2901
2902
2903
2904bool QDomNamedNodeMap::operator==(
const QDomNamedNodeMap &other)
const
2906 return impl == other.impl;
2910
2911
2912
2913bool QDomNamedNodeMap::operator!=(
const QDomNamedNodeMap &other)
const
2915 return !operator==(other);
2919
2920
2921QDomNamedNodeMap::~QDomNamedNodeMap()
2923 if (impl && !impl->ref.deref())
2928
2929
2930
2931
2932
2933
2934
2935
2936QDomNode QDomNamedNodeMap::namedItem(
const QString& name)
const
2940 return QDomNode(IMPL->namedItem(name));
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953QDomNode QDomNamedNodeMap::setNamedItem(
const QDomNode& newNode)
2957 return QDomNode(IMPL->setNamedItem(
static_cast<QDomNodePrivate *>(newNode.impl)));
2961
2962
2963
2964
2965
2966
2967
2968
2969QDomNode QDomNamedNodeMap::removeNamedItem(
const QString& name)
2973 return QDomNode(IMPL->removeNamedItem(name));
2977
2978
2979
2980
2981
2982
2983
2984QDomNode QDomNamedNodeMap::item(
int index)
const
2988 return QDomNode(IMPL->item(index));
2992
2993
2994
2995
2996
2997
2998
2999
3000QDomNode QDomNamedNodeMap::namedItemNS(
const QString& nsURI,
const QString& localName)
const
3004 return QDomNode(IMPL->namedItemNS(nsURI, localName));
3008
3009
3010
3011
3012
3013
3014
3015QDomNode QDomNamedNodeMap::setNamedItemNS(
const QDomNode& newNode)
3019 return QDomNode(IMPL->setNamedItemNS(
static_cast<QDomNodePrivate *>(newNode.impl)));
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033QDomNode QDomNamedNodeMap::removeNamedItemNS(
const QString& nsURI,
const QString& localName)
3037 QDomNodePrivate *n = IMPL->namedItemNS(nsURI, localName);
3040 return QDomNode(IMPL->removeNamedItem(n->name));
3044
3045
3046
3047
3048int QDomNamedNodeMap::length()
const
3052 return IMPL->length();
3056
3057
3058
3059
3060
3063
3064
3065
3066
3069
3070
3071
3072
3075
3076
3077
3078
3079
3080
3081
3082bool QDomNamedNodeMap::contains(
const QString& name)
const
3086 return IMPL->contains(name);
3092
3093
3094
3095
3097QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent)
3098 : QDomNodePrivate(doc, parent)
3103QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentTypePrivate* n,
bool deep)
3104 : QDomNodePrivate(n, deep)
3108 QDomNodePrivate* p = first;
3112 entities->map.insert(p->nodeName(), p);
3113 if (p->isNotation())
3115 notations->map.insert(p->nodeName(), p);
3120QDomDocumentTypePrivate::~QDomDocumentTypePrivate()
3122 if (!entities->ref.deref())
3124 if (!notations->ref.deref())
3128void QDomDocumentTypePrivate::init()
3130 entities =
new QDomNamedNodeMapPrivate(
this);
3132 notations =
new QDomNamedNodeMapPrivate(
this);
3135 internalSubset.clear();
3137 entities->setAppendToParent(
true);
3138 notations->setAppendToParent(
true);
3145QDomNodePrivate* QDomDocumentTypePrivate::cloneNode(
bool deep)
3147 QDomNodePrivate* p =
new QDomDocumentTypePrivate(
this, deep);
3153QDomNodePrivate* QDomDocumentTypePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
3156 QDomNodePrivate* p = QDomNodePrivate::insertBefore(newChild, refChild);
3158 if (p && p->isEntity())
3159 entities->map.insert(p->nodeName(), p);
3160 else if (p && p->isNotation())
3161 notations->map.insert(p->nodeName(), p);
3166QDomNodePrivate* QDomDocumentTypePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
3169 QDomNodePrivate* p = QDomNodePrivate::insertAfter(newChild, refChild);
3171 if (p && p->isEntity())
3172 entities->map.insert(p->nodeName(), p);
3173 else if (p && p->isNotation())
3174 notations->map.insert(p->nodeName(), p);
3179QDomNodePrivate* QDomDocumentTypePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild)
3182 QDomNodePrivate* p = QDomNodePrivate::replaceChild(newChild, oldChild);
3185 if (oldChild && oldChild->isEntity())
3186 entities->map.remove(oldChild->nodeName());
3187 else if (oldChild && oldChild->isNotation())
3188 notations->map.remove(oldChild->nodeName());
3191 entities->map.insert(p->nodeName(), p);
3192 else if (p->isNotation())
3193 notations->map.insert(p->nodeName(), p);
3199QDomNodePrivate* QDomDocumentTypePrivate::removeChild(QDomNodePrivate* oldChild)
3202 QDomNodePrivate* p = QDomNodePrivate::removeChild( oldChild);
3204 if (p && p->isEntity())
3205 entities->map.remove(p->nodeName());
3206 else if (p && p->isNotation())
3207 notations->map.remove(p ->nodeName());
3212QDomNodePrivate* QDomDocumentTypePrivate::appendChild(QDomNodePrivate* newChild)
3214 return insertAfter(newChild,
nullptr);
3217static QString quotedValue(
const QString &data)
3219 QChar quote = data.indexOf(u'\'') == -1 ? u'\'' : u'"';
3220 return quote + data + quote;
3223void QDomDocumentTypePrivate::save(QTextStream& s,
int,
int indent)
const
3228 s <<
"<!DOCTYPE " << name;
3230 if (!publicId.isNull()) {
3231 s <<
" PUBLIC " << quotedValue(publicId);
3232 if (!systemId.isNull()) {
3233 s <<
' ' << quotedValue(systemId);
3235 }
else if (!systemId.isNull()) {
3236 s <<
" SYSTEM " << quotedValue(systemId);
3239 if (entities->length()>0 || notations->length()>0) {
3240 s <<
" [" << Qt::endl;
3242 auto it2 = notations->map.constBegin();
3243 for (; it2 != notations->map.constEnd(); ++it2)
3244 it2.value()->saveSubTree(it2.value(), s, 0, indent);
3246 auto it = entities->map.constBegin();
3247 for (; it != entities->map.constEnd(); ++it)
3248 it.value()->saveSubTree(it.value(), s, 0, indent);
3253 s <<
'>' << Qt::endl;
3257
3258
3259
3260
3262#define IMPL static_cast<QDomDocumentTypePrivate *>(impl)
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3284
3285
3286QDomDocumentType::QDomDocumentType() : QDomNode()
3291
3292
3293
3294
3295
3296
3297QDomDocumentType::QDomDocumentType(
const QDomDocumentType &documentType)
3298 : QDomNode(documentType)
3302QDomDocumentType::QDomDocumentType(QDomDocumentTypePrivate *pimpl)
3308
3309
3310
3311
3312
3313
3314QDomDocumentType &QDomDocumentType::operator=(
const QDomDocumentType &other) =
default;
3316
3317
3318
3319
3320
3321QString QDomDocumentType::name()
const
3325 return IMPL->nodeName();
3329
3330
3331QDomNamedNodeMap QDomDocumentType::entities()
const
3334 return QDomNamedNodeMap();
3335 return QDomNamedNodeMap(IMPL->entities);
3339
3340
3341QDomNamedNodeMap QDomDocumentType::notations()
const
3344 return QDomNamedNodeMap();
3345 return QDomNamedNodeMap(IMPL->notations);
3349
3350
3351
3352
3353
3354QString QDomDocumentType::publicId()
const
3358 return IMPL->publicId;
3362
3363
3364
3365
3366
3367QString QDomDocumentType::systemId()
const
3371 return IMPL->systemId;
3375
3376
3377
3378
3379
3380QString QDomDocumentType::internalSubset()
const
3384 return IMPL->internalSubset;
3388
3389
3390
3391
3394
3395
3396
3397
3398
3399
3404
3405
3406
3407
3409QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent)
3410 : QDomNodePrivate(doc, parent)
3412 name = u"#document-fragment"_s;
3415QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomNodePrivate* n,
bool deep)
3416 : QDomNodePrivate(n, deep)
3420QDomNodePrivate* QDomDocumentFragmentPrivate::cloneNode(
bool deep)
3422 QDomNodePrivate* p =
new QDomDocumentFragmentPrivate(
this, deep);
3429
3430
3431
3432
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3460
3461
3462QDomDocumentFragment::QDomDocumentFragment()
3466QDomDocumentFragment::QDomDocumentFragment(QDomDocumentFragmentPrivate* n)
3472
3473
3474
3475
3476
3477
3478QDomDocumentFragment::QDomDocumentFragment(
const QDomDocumentFragment &documentFragment)
3479 : QDomNode(documentFragment)
3484
3485
3486
3487
3488
3489
3490QDomDocumentFragment &QDomDocumentFragment::operator=(
const QDomDocumentFragment &other) =
default;
3493
3494
3495
3496
3497
3498
3501
3502
3503
3504
3506QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
3507 const QString& data)
3508 : QDomNodePrivate(d, p)
3511 name = u"#character-data"_s;
3514QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomCharacterDataPrivate* n,
bool deep)
3515 : QDomNodePrivate(n, deep)
3519QDomNodePrivate* QDomCharacterDataPrivate::cloneNode(
bool deep)
3521 QDomNodePrivate* p =
new QDomCharacterDataPrivate(
this, deep);
3527int QDomCharacterDataPrivate::dataLength()
const
3529 return value.size();
3532QString QDomCharacterDataPrivate::substringData(
unsigned long offset,
unsigned long n)
const
3534 return value.mid(offset, n);
3537void QDomCharacterDataPrivate::insertData(
unsigned long offset,
const QString& arg)
3539 value.insert(offset, arg);
3542void QDomCharacterDataPrivate::deleteData(
unsigned long offset,
unsigned long n)
3544 value.remove(offset, n);
3547void QDomCharacterDataPrivate::replaceData(
unsigned long offset,
unsigned long n,
const QString& arg)
3549 value.replace(offset, n, arg);
3552void QDomCharacterDataPrivate::appendData(
const QString& arg)
3558
3559
3560
3561
3563#define IMPL static_cast<QDomCharacterDataPrivate *>(impl)
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3591
3592
3593QDomCharacterData::QDomCharacterData()
3598
3599
3600
3601
3602
3603
3604QDomCharacterData::QDomCharacterData(
const QDomCharacterData &characterData)
3605 : QDomNode(characterData)
3609QDomCharacterData::QDomCharacterData(QDomCharacterDataPrivate* n)
3615
3616
3617
3618
3619
3620
3621QDomCharacterData &QDomCharacterData::operator=(
const QDomCharacterData &other) =
default;
3624
3625
3626
3627
3628
3629QString QDomCharacterData::data()
const
3633 return impl->nodeValue();
3637
3638
3639void QDomCharacterData::setData(
const QString &data)
3642 impl->setNodeValue(data);
3646
3647
3648int QDomCharacterData::length()
const
3651 return IMPL->dataLength();
3656
3657
3658QString QDomCharacterData::substringData(
unsigned long offset,
unsigned long count)
3662 return IMPL->substringData(offset, count);
3666
3667
3668void QDomCharacterData::appendData(
const QString& arg)
3671 IMPL->appendData(arg);
3675
3676
3677void QDomCharacterData::insertData(
unsigned long offset,
const QString& arg)
3680 IMPL->insertData(offset, arg);
3684
3685
3686void QDomCharacterData::deleteData(
unsigned long offset,
unsigned long count)
3689 IMPL->deleteData(offset, count);
3693
3694
3695
3696void QDomCharacterData::replaceData(
unsigned long offset,
unsigned long count,
const QString& arg)
3699 IMPL->replaceData(offset, count, arg);
3703
3704
3705
3706
3707QDomNode::NodeType QDomCharacterData::nodeType()
const
3710 return CharacterDataNode;
3711 return QDomNode::nodeType();
3717
3718
3719
3720
3722QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& name_)
3723 : QDomNodePrivate(d, parent)
3726 m_specified =
false;
3729QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
const QString& nsURI,
const QString& qName)
3730 : QDomNodePrivate(d, p)
3732 qt_split_namespace(prefix, name, qName, !nsURI.isNull());
3733 namespaceURI = nsURI;
3734 createdWithDom1Interface =
false;
3735 m_specified =
false;
3738QDomAttrPrivate::QDomAttrPrivate(QDomAttrPrivate* n,
bool deep)
3739 : QDomNodePrivate(n, deep)
3741 m_specified = n->specified();
3744void QDomAttrPrivate::setNodeValue(
const QString& v)
3747 QDomTextPrivate *t =
new QDomTextPrivate(
nullptr,
this, v);
3751 auto removed = removeChild(first);
3752 if (removed && !removed->ref.loadRelaxed())
3758QDomNodePrivate* QDomAttrPrivate::cloneNode(
bool deep)
3760 QDomNodePrivate* p =
new QDomAttrPrivate(
this, deep);
3766bool QDomAttrPrivate::specified()
const
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781static QString encodeText(
const QString &str,
3782 const bool encodeQuotes =
true,
3783 const bool performAVN =
false,
3784 const bool encodeEOLs =
false)
3787 qsizetype start = 0;
3788 auto appendToOutput = [&](qsizetype cur,
const auto &replacement)
3791 retval.reserve(str.size() + replacement.size());
3792 retval.append(QStringView(str).first(cur).sliced(start));
3796 retval.append(replacement);
3799 const qsizetype len = str.size();
3800 for (qsizetype cur = 0; cur < len; ++cur) {
3801 switch (str[cur].unicode()) {
3803 appendToOutput(cur,
"<"_L1);
3807 appendToOutput(cur,
"""_L1);
3810 appendToOutput(cur,
"&"_L1);
3813 if (cur >= 2 && str[cur - 1] == u']' && str[cur - 2] == u']')
3814 appendToOutput(cur,
">"_L1);
3817 if (performAVN || encodeEOLs)
3818 appendToOutput(cur,
"
"_L1);
3822 appendToOutput(cur,
"
"_L1);
3826 appendToOutput(cur,
"	"_L1);
3833 retval.append(QStringView(str).first(len).sliced(start));
3839void QDomAttrPrivate::save(QTextStream& s,
int,
int)
const
3841 if (namespaceURI.isNull()) {
3842 s << name <<
"=\"" << encodeText(value,
true,
true) <<
'\"';
3844 s << prefix <<
':' << name <<
"=\"" << encodeText(value,
true,
true) <<
'\"';
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3857 ownerNode->prefix != prefix) {
3858 s <<
" xmlns:" << prefix <<
"=\"" << encodeText(namespaceURI,
true,
true) <<
'\"';
3864
3865
3866
3867
3869#define IMPL static_cast<QDomAttrPrivate *>(impl)
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
3903
3907
3908
3914
3915
3916
3917
3918
3919
3920QDomAttr::QDomAttr(
const QDomAttr &attr)
3925QDomAttr::QDomAttr(QDomAttrPrivate* n)
3931
3932
3933
3934
3935
3936
3937QDomAttr &QDomAttr::operator=(
const QDomAttr &other) =
default;
3940
3941
3942QString QDomAttr::name()
const
3946 return impl->nodeName();
3950
3951
3952
3953
3954
3955bool QDomAttr::specified()
const
3959 return IMPL->specified();
3963
3964
3965
3966
3967QDomElement QDomAttr::ownerElement()
const
3969 Q_ASSERT(impl->parent());
3970 if (!impl->parent()->isElement())
3971 return QDomElement();
3972 return QDomElement(
static_cast<QDomElementPrivate *>(impl->parent()));
3976
3977
3978
3979
3980
3981QString QDomAttr::value()
const
3985 return impl->nodeValue();
3989
3990
3991
3992
3993void QDomAttr::setValue(
const QString &value)
3997 impl->setNodeValue(value);
3998 IMPL->m_specified =
true;
4002
4003
4004
4005
4010
4011
4012
4013
4015QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
4016 const QString& tagname)
4017 : QDomNodePrivate(d, p)
4020 m_attr =
new QDomNamedNodeMapPrivate(
this);
4023QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
4024 const QString& nsURI,
const QString& qName)
4025 : QDomNodePrivate(d, p)
4027 qt_split_namespace(prefix, name, qName, !nsURI.isNull());
4028 namespaceURI = nsURI;
4029 createdWithDom1Interface =
false;
4030 m_attr =
new QDomNamedNodeMapPrivate(
this);
4033QDomElementPrivate::QDomElementPrivate(QDomElementPrivate* n,
bool deep) :
4034 QDomNodePrivate(n, deep)
4036 m_attr = n->m_attr->clone(
this);
4041QDomElementPrivate::~QDomElementPrivate()
4043 if (!m_attr->ref.deref())
4047QDomNodePrivate* QDomElementPrivate::cloneNode(
bool deep)
4049 QDomNodePrivate* p =
new QDomElementPrivate(
this, deep);
4055QString QDomElementPrivate::attribute(
const QString& name_,
const QString& defValue)
const
4057 QDomNodePrivate* n = m_attr->namedItem(name_);
4061 return n->nodeValue();
4064QString QDomElementPrivate::attributeNS(
const QString& nsURI,
const QString& localName,
const QString& defValue)
const
4066 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4070 return n->nodeValue();
4073void QDomElementPrivate::setAttribute(
const QString& aname,
const QString& newValue)
4075 QDomNodePrivate* n = m_attr->namedItem(aname);
4077 n =
new QDomAttrPrivate(ownerDocument(),
this, aname);
4078 n->setNodeValue(newValue);
4083 m_attr->setNamedItem(n);
4085 n->setNodeValue(newValue);
4089void QDomElementPrivate::setAttributeNS(
const QString& nsURI,
const QString& qName,
const QString& newValue)
4091 QString prefix, localName;
4092 qt_split_namespace(prefix, localName, qName,
true);
4093 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4095 n =
new QDomAttrPrivate(ownerDocument(),
this, nsURI, qName);
4096 n->setNodeValue(newValue);
4101 m_attr->setNamedItem(n);
4103 n->setNodeValue(newValue);
4108void QDomElementPrivate::removeAttribute(
const QString& aname)
4110 QDomNodePrivate* p = m_attr->removeNamedItem(aname);
4111 if (p && p->ref.loadRelaxed() == 0)
4115QDomAttrPrivate* QDomElementPrivate::attributeNode(
const QString& aname)
4117 return static_cast<QDomAttrPrivate *>(m_attr->namedItem(aname));
4120QDomAttrPrivate* QDomElementPrivate::attributeNodeNS(
const QString& nsURI,
const QString& localName)
4122 return static_cast<QDomAttrPrivate *>(m_attr->namedItemNS(nsURI, localName));
4125QDomAttrPrivate* QDomElementPrivate::setAttributeNode(QDomAttrPrivate* newAttr)
4130 QDomNodePrivate* foundAttr = m_attr->namedItem(newAttr->nodeName());
4132 m_attr->removeNamedItem(newAttr->nodeName());
4135 m_attr->setNamedItem(newAttr);
4136 newAttr->setParent(
this);
4138 return static_cast<QDomAttrPrivate *>(foundAttr);
4141QDomAttrPrivate* QDomElementPrivate::setAttributeNodeNS(QDomAttrPrivate* newAttr)
4143 QDomNodePrivate* n =
nullptr;
4144 if (!newAttr->prefix.isNull())
4145 n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name);
4148 m_attr->setNamedItem(newAttr);
4150 return static_cast<QDomAttrPrivate *>(n);
4153QDomAttrPrivate* QDomElementPrivate::removeAttributeNode(QDomAttrPrivate* oldAttr)
4155 return static_cast<QDomAttrPrivate *>(m_attr->removeNamedItem(oldAttr->nodeName()));
4158bool QDomElementPrivate::hasAttribute(
const QString& aname)
4160 return m_attr->contains(aname);
4163bool QDomElementPrivate::hasAttributeNS(
const QString& nsURI,
const QString& localName)
4165 return m_attr->containsNS(nsURI, localName);
4168QString QDomElementPrivate::text()
4172 QDomNodePrivate* p = first;
4174 if (p->isText() || p->isCDATASection())
4175 t += p->nodeValue();
4176 else if (p->isElement())
4177 t +=
static_cast<QDomElementPrivate *>(p)->text();
4184void QDomElementPrivate::save(QTextStream& s,
int depth,
int indent)
const
4186 if (!(prev && prev->isText()))
4187 s << QString(indent < 1 ? 0 : depth * indent, u' ');
4189 QString qName(name);
4190 QString nsDecl(u""_s);
4191 if (!namespaceURI.isNull()) {
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202 if (prefix.isEmpty()) {
4203 nsDecl = u" xmlns"_s;
4205 qName = prefix + u':' + name;
4206 nsDecl = u" xmlns:"_s + prefix;
4208 nsDecl += u"=\""_s + encodeText(namespaceURI) + u'\"';
4210 s <<
'<' << qName << nsDecl;
4214 if (!m_attr->map.isEmpty()) {
4216
4217
4218
4219
4220
4221
4222
4223 struct SavedAttribute {
4226 QString encodedValue;
4230 QVarLengthArray<SavedAttribute, 8> attributesToSave;
4231 attributesToSave.reserve(m_attr->map.size());
4233 QDuplicateTracker<QString> outputtedPrefixes;
4234 for (
const auto &[key, value] : std::as_const(m_attr->map).asKeyValueRange()) {
4236 bool mayNeedXmlNS =
false;
4238 SavedAttribute attr;
4239 attr.name = value->name;
4240 attr.encodedValue = encodeText(value->value,
true,
true);
4241 if (!value->namespaceURI.isNull()) {
4242 attr.prefix = value->prefix;
4243 mayNeedXmlNS =
true;
4246 attributesToSave.push_back(std::move(attr));
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4265 && ((!value->ownerNode || value->ownerNode->prefix != value->prefix)
4266 && !outputtedPrefixes.hasSeen(value->prefix)))
4268 SavedAttribute nsAttr;
4269 nsAttr.prefix = QStringLiteral(
"xmlns");
4270 nsAttr.name = value->prefix;
4271 nsAttr.encodedValue = encodeText(value->namespaceURI,
true,
true);
4272 attributesToSave.push_back(std::move(nsAttr));
4277 const auto savedAttributeComparator = [](
const SavedAttribute &lhs,
const SavedAttribute &rhs)
4279 const int cmp = QString::compare(lhs.prefix, rhs.prefix);
4280 return (cmp < 0) || ((cmp == 0) && (lhs.name < rhs.name));
4283 std::sort(attributesToSave.begin(), attributesToSave.end(), savedAttributeComparator);
4286 for (
const auto &attr : attributesToSave) {
4288 if (!attr.prefix.isEmpty())
4289 s << attr.prefix <<
':';
4290 s << attr.name <<
"=\"" << attr.encodedValue <<
'\"';
4296 if (first->isText())
4310void QDomElementPrivate::afterSave(QTextStream &s,
int depth,
int indent)
const
4313 QString qName(name);
4315 if (!prefix.isEmpty())
4316 qName = prefix + u':' + name;
4318 if (!last->isText())
4319 s << QString(indent < 1 ? 0 : depth * indent, u' ');
4321 s <<
"</" << qName <<
'>';
4324 if (!(next && next->isText())) {
4332
4333
4334
4335
4337#define IMPL static_cast<QDomElementPrivate *>(impl)
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
4385
4386
4387
4388
4389
4392
4393
4394
4395QDomElement::QDomElement()
4401
4402
4403
4404
4405
4406
4407QDomElement::QDomElement(
const QDomElement &element)
4412QDomElement::QDomElement(QDomElementPrivate* n)
4418
4419
4420
4421
4422
4423
4424QDomElement &QDomElement::operator=(
const QDomElement &other) =
default;
4427
4428
4429
4430
4433
4434
4435
4436
4437void QDomElement::setTagName(
const QString& name)
4444
4445
4446
4447
4448
4449
4450
4451
4452QString QDomElement::tagName()
const
4456 return impl->nodeName();
4461
4462
4463
4464
4465QDomNamedNodeMap QDomElement::attributes()
const
4468 return QDomNamedNodeMap();
4469 return QDomNamedNodeMap(IMPL->attributes());
4473
4474
4475
4476
4477
4478QString QDomElement::attribute(
const QString& name,
const QString& defValue)
const
4482 return IMPL->attribute(name, defValue);
4486
4487
4488
4489
4490
4491
4492void QDomElement::setAttribute(
const QString& name,
const QString& value)
4496 IMPL->setAttribute(name, value);
4500
4501
4502
4503
4504
4507
4508
4509
4510
4511
4514
4515
4516
4517
4518void QDomElement::setAttribute(
const QString& name, qlonglong value)
4524 IMPL->setAttribute(name, x);
4528
4529
4530
4531
4532void QDomElement::setAttribute(
const QString& name, qulonglong value)
4538 IMPL->setAttribute(name, x);
4542
4543
4544
4545
4546void QDomElement::setAttribute(
const QString& name,
float value)
4551 x.setNum(value,
'g', 8);
4552 IMPL->setAttribute(name, x);
4556
4557
4558
4559
4560void QDomElement::setAttribute(
const QString& name,
double value)
4565 x.setNum(value,
'g', 17);
4566 IMPL->setAttribute(name, x);
4570
4571
4572
4573
4574void QDomElement::removeAttribute(
const QString& name)
4578 IMPL->removeAttribute(name);
4582
4583
4584
4585
4586
4587
4588QDomAttr QDomElement::attributeNode(
const QString& name)
4592 return QDomAttr(IMPL->attributeNode(name));
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605QDomAttr QDomElement::setAttributeNode(
const QDomAttr& newAttr)
4609 return QDomAttr(IMPL->setAttributeNode(
static_cast<QDomAttrPrivate *>(newAttr.impl)));
4613
4614
4615
4616
4617QDomAttr QDomElement::removeAttributeNode(
const QDomAttr& oldAttr)
4621 return QDomAttr(IMPL->removeAttributeNode(
static_cast<QDomAttrPrivate *>(oldAttr.impl)));
4625
4626
4627
4628
4629
4630
4631
4632
4633QDomNodeList QDomElement::elementsByTagName(
const QString& tagname)
const
4635 return QDomNodeList(
new QDomNodeListPrivate(impl, tagname));
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650bool QDomElement::hasAttribute(
const QString& name)
const
4654 return IMPL->hasAttribute(name);
4658
4659
4660
4661
4662
4663
4664QString QDomElement::attributeNS(
const QString& nsURI,
const QString& localName,
const QString& defValue)
const
4668 return IMPL->attributeNS(nsURI, localName, defValue);
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName,
const QString& value)
4687 IMPL->setAttributeNS(nsURI, qName, value);
4691
4692
4693
4694
4697
4698
4699
4700
4703
4704
4705void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName, qlonglong value)
4711 IMPL->setAttributeNS(nsURI, qName, x);
4715
4716
4717void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName, qulonglong value)
4723 IMPL->setAttributeNS(nsURI, qName, x);
4727
4728
4729void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName,
double value)
4734 x.setNum(value,
'g', 17);
4735 IMPL->setAttributeNS(nsURI, qName, x);
4739
4740
4741
4742
4743
4744void QDomElement::removeAttributeNS(
const QString& nsURI,
const QString& localName)
4748 QDomNodePrivate *n = IMPL->attributeNodeNS(nsURI, localName);
4751 IMPL->removeAttribute(n->nodeName());
4755
4756
4757
4758
4759
4760
4761
4762QDomAttr QDomElement::attributeNodeNS(
const QString& nsURI,
const QString& localName)
4766 return QDomAttr(IMPL->attributeNodeNS(nsURI, localName));
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779QDomAttr QDomElement::setAttributeNodeNS(
const QDomAttr& newAttr)
4783 return QDomAttr(IMPL->setAttributeNodeNS(
static_cast<QDomAttrPrivate *>(newAttr.impl)));
4787
4788
4789
4790
4791
4792
4793
4794
4795QDomNodeList QDomElement::elementsByTagNameNS(
const QString& nsURI,
const QString& localName)
const
4797 return QDomNodeList(
new QDomNodeListPrivate(impl, nsURI, localName));
4801
4802
4803
4804
4805bool QDomElement::hasAttributeNS(
const QString& nsURI,
const QString& localName)
const
4809 return IMPL->hasAttributeNS(nsURI, localName);
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826QString QDomElement::text()
const
4830 return IMPL->text();
4836
4837
4838
4839
4841QDomTextPrivate::QDomTextPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& val)
4842 : QDomCharacterDataPrivate(d, parent, val)
4847QDomTextPrivate::QDomTextPrivate(QDomTextPrivate* n,
bool deep)
4848 : QDomCharacterDataPrivate(n, deep)
4852QDomNodePrivate* QDomTextPrivate::cloneNode(
bool deep)
4854 QDomNodePrivate* p =
new QDomTextPrivate(
this, deep);
4860QDomTextPrivate* QDomTextPrivate::splitText(
int offset)
4863 qWarning(
"QDomText::splitText The node has no parent. So I cannot split");
4867 QDomTextPrivate* t =
new QDomTextPrivate(ownerDocument(),
nullptr, value.mid(offset));
4868 value.truncate(offset);
4870 parent()->insertAfter(t,
this);
4871 Q_ASSERT(t->ref.loadRelaxed() == 2);
4879void QDomTextPrivate::save(QTextStream& s,
int,
int)
const
4881 QDomTextPrivate *that =
const_cast<QDomTextPrivate*>(
this);
4882 s << encodeText(value, !(that->parent() && that->parent()->isElement()),
false,
true);
4886
4887
4888
4889
4891#define IMPL static_cast<QDomTextPrivate *>(impl)
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4912
4913
4914
4915
4917 : QDomCharacterData()
4922
4923
4924
4925
4926
4927
4928QDomText::QDomText(
const QDomText &text)
4929 : QDomCharacterData(text)
4933QDomText::QDomText(QDomTextPrivate* n)
4934 : QDomCharacterData(n)
4939
4940
4941
4942
4943
4944
4945QDomText &QDomText::operator=(
const QDomText &other) =
default;
4948
4949
4950
4951
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963QDomText QDomText::splitText(
int offset)
4967 return QDomText(IMPL->splitText(offset));
4973
4974
4975
4976
4978QDomCommentPrivate::QDomCommentPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& val)
4979 : QDomCharacterDataPrivate(d, parent, val)
4981 name = u"#comment"_s;
4984QDomCommentPrivate::QDomCommentPrivate(QDomCommentPrivate* n,
bool deep)
4985 : QDomCharacterDataPrivate(n, deep)
4990QDomNodePrivate* QDomCommentPrivate::cloneNode(
bool deep)
4992 QDomNodePrivate* p =
new QDomCommentPrivate(
this, deep);
4998void QDomCommentPrivate::save(QTextStream& s,
int depth,
int indent)
const
5001 if (!(prev && prev->isText()))
5002 s << QString(indent < 1 ? 0 : depth * indent, u' ');
5004 s <<
"<!--" << value;
5005 if (value.endsWith(u'-'))
5009 if (!(next && next->isText()))
5014
5015
5016
5017
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5041
5042
5043
5044QDomComment::QDomComment()
5045 : QDomCharacterData()
5050
5051
5052
5053
5054
5055
5056QDomComment::QDomComment(
const QDomComment &comment)
5057 : QDomCharacterData(comment)
5061QDomComment::QDomComment(QDomCommentPrivate* n)
5062 : QDomCharacterData(n)
5067
5068
5069
5070
5071
5072
5073QDomComment &QDomComment::operator=(
const QDomComment &other) =
default;
5076
5077
5078
5079
5082
5083
5084
5085
5087QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5089 : QDomTextPrivate(d, parent, val)
5091 name = u"#cdata-section"_s;
5094QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomCDATASectionPrivate* n,
bool deep)
5095 : QDomTextPrivate(n, deep)
5099QDomNodePrivate* QDomCDATASectionPrivate::cloneNode(
bool deep)
5101 QDomNodePrivate* p =
new QDomCDATASectionPrivate(
this, deep);
5107void QDomCDATASectionPrivate::save(QTextStream& s,
int,
int)
const
5111 s <<
"<![CDATA[" << value <<
"]]>";
5115
5116
5117
5118
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5146
5147
5148
5149QDomCDATASection::QDomCDATASection()
5155
5156
5157
5158
5159
5160
5161QDomCDATASection::QDomCDATASection(
const QDomCDATASection &cdataSection)
5162 : QDomText(cdataSection)
5166QDomCDATASection::QDomCDATASection(QDomCDATASectionPrivate* n)
5172
5173
5174
5175
5176
5177
5178QDomCDATASection &QDomCDATASection::operator=(
const QDomCDATASection &other) =
default;
5181
5182
5183
5184
5187
5188
5189
5190
5192QDomNotationPrivate::QDomNotationPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5193 const QString& aname,
5194 const QString& pub,
const QString& sys)
5195 : QDomNodePrivate(d, parent)
5202QDomNotationPrivate::QDomNotationPrivate(QDomNotationPrivate* n,
bool deep)
5203 : QDomNodePrivate(n, deep)
5209QDomNodePrivate* QDomNotationPrivate::cloneNode(
bool deep)
5211 QDomNodePrivate* p =
new QDomNotationPrivate(
this, deep);
5217void QDomNotationPrivate::save(QTextStream& s,
int,
int)
const
5219 s <<
"<!NOTATION " << name <<
' ';
5220 if (!m_pub.isNull()) {
5221 s <<
"PUBLIC " << quotedValue(m_pub);
5222 if (!m_sys.isNull())
5223 s <<
' ' << quotedValue(m_sys);
5225 s <<
"SYSTEM " << quotedValue(m_sys);
5227 s <<
'>' << Qt::endl;
5231
5232
5233
5234
5236#define IMPL static_cast<QDomNotationPrivate *>(impl)
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5268
5269
5270QDomNotation::QDomNotation()
5276
5277
5278
5279
5280
5281
5282QDomNotation::QDomNotation(
const QDomNotation ¬ation)
5283 : QDomNode(notation)
5287QDomNotation::QDomNotation(QDomNotationPrivate* n)
5293
5294
5295
5296
5297
5298
5299QDomNotation &QDomNotation::operator=(
const QDomNotation &other) =
default;
5302
5303
5304
5305
5308
5309
5310QString QDomNotation::publicId()
const
5318
5319
5320QString QDomNotation::systemId()
const
5330
5331
5332
5333
5335QDomEntityPrivate::QDomEntityPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5336 const QString& aname,
5337 const QString& pub,
const QString& sys,
const QString& notation)
5338 : QDomNodePrivate(d, parent)
5343 m_notationName = notation;
5346QDomEntityPrivate::QDomEntityPrivate(QDomEntityPrivate* n,
bool deep)
5347 : QDomNodePrivate(n, deep)
5351 m_notationName = n->m_notationName;
5354QDomNodePrivate* QDomEntityPrivate::cloneNode(
bool deep)
5356 QDomNodePrivate* p =
new QDomEntityPrivate(
this, deep);
5363
5364
5365static QByteArray encodeEntity(
const QByteArray& str)
5367 QByteArray tmp(str);
5368 int len = tmp.size();
5370 const char* d = tmp.constData();
5373 tmp.replace(i, 1,
"<");
5374 d = tmp.constData();
5378 else if (d[i] ==
'"') {
5379 tmp.replace(i, 1,
""");
5380 d = tmp.constData();
5383 }
else if (d[i] ==
'&' && i + 1 < len && d[i+1] ==
'#') {
5386 tmp.replace(i, 1,
"&");
5387 d = tmp.constData();
5398void QDomEntityPrivate::save(QTextStream& s,
int,
int)
const
5400 QString _name = name;
5401 if (_name.startsWith(u'%'))
5402 _name = u"% "_s + _name.mid(1);
5404 if (m_sys.isNull() && m_pub.isNull()) {
5405 s <<
"<!ENTITY " << _name <<
" \"" << encodeEntity(value.toUtf8()) <<
"\">" << Qt::endl;
5407 s <<
"<!ENTITY " << _name <<
' ';
5408 if (m_pub.isNull()) {
5409 s <<
"SYSTEM " << quotedValue(m_sys);
5411 s <<
"PUBLIC " << quotedValue(m_pub) <<
' ' << quotedValue(m_sys);
5413 if (! m_notationName.isNull()) {
5414 s <<
" NDATA " << m_notationName;
5416 s <<
'>' << Qt::endl;
5421
5422
5423
5424
5426#define IMPL static_cast<QDomEntityPrivate *>(impl)
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5461
5462
5463QDomEntity::QDomEntity()
5470
5471
5472
5473
5474
5475
5476QDomEntity::QDomEntity(
const QDomEntity &entity)
5481QDomEntity::QDomEntity(QDomEntityPrivate* n)
5487
5488
5489
5490
5491
5492
5493QDomEntity &QDomEntity::operator=(
const QDomEntity &other) =
default;
5496
5497
5498
5499
5502
5503
5504
5505QString QDomEntity::publicId()
const
5513
5514
5515
5516QString QDomEntity::systemId()
const
5524
5525
5526
5527
5528QString QDomEntity::notationName()
const
5532 return IMPL->m_notationName;
5538
5539
5540
5541
5543QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& aname)
5544 : QDomNodePrivate(d, parent)
5549QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomNodePrivate* n,
bool deep)
5550 : QDomNodePrivate(n, deep)
5554QDomNodePrivate* QDomEntityReferencePrivate::cloneNode(
bool deep)
5556 QDomNodePrivate* p =
new QDomEntityReferencePrivate(
this, deep);
5562void QDomEntityReferencePrivate::save(QTextStream& s,
int,
int)
const
5564 s <<
'&' << name <<
';';
5568
5569
5570
5571
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
5602
5603
5604
5605
5606
5609
5610
5611
5612
5613QDomEntityReference::QDomEntityReference()
5619
5620
5621
5622
5623
5624
5625QDomEntityReference::QDomEntityReference(
const QDomEntityReference &entityReference)
5626 : QDomNode(entityReference)
5630QDomEntityReference::QDomEntityReference(QDomEntityReferencePrivate* n)
5636
5637
5638
5639
5640
5641
5642QDomEntityReference &QDomEntityReference::operator=(
const QDomEntityReference &other) =
default;
5645
5646
5647
5648
5651
5652
5653
5654
5656QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomDocumentPrivate* d,
5657 QDomNodePrivate* parent,
const QString& target,
const QString& data)
5658 : QDomNodePrivate(d, parent)
5664QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomProcessingInstructionPrivate* n,
bool deep)
5665 : QDomNodePrivate(n, deep)
5670QDomNodePrivate* QDomProcessingInstructionPrivate::cloneNode(
bool deep)
5672 QDomNodePrivate* p =
new QDomProcessingInstructionPrivate(
this, deep);
5678void QDomProcessingInstructionPrivate::save(QTextStream& s,
int,
int)
const
5680 s <<
"<?" << name <<
' ' << value <<
"?>" << Qt::endl;
5684
5685
5686
5687
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
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5731
5732
5733
5734
5735QDomProcessingInstruction::QDomProcessingInstruction()
5741
5742
5743
5744
5745
5746
5747QDomProcessingInstruction::QDomProcessingInstruction(
const QDomProcessingInstruction &processingInstruction)
5748 : QDomNode(processingInstruction)
5752QDomProcessingInstruction::QDomProcessingInstruction(QDomProcessingInstructionPrivate* n)
5758
5759
5760
5761
5762
5763
5764QDomProcessingInstruction &
5765QDomProcessingInstruction::operator=(
const QDomProcessingInstruction &other) =
default;
5768
5769
5770
5771
5774
5775
5776
5777
5778QString QDomProcessingInstruction::target()
const
5782 return impl->nodeName();
5786
5787
5788
5789
5790QString QDomProcessingInstruction::data()
const
5794 return impl->nodeValue();
5798
5799
5800
5801
5802void QDomProcessingInstruction::setData(
const QString &data)
5805 impl->setNodeValue(data);
5809
5810
5811
5812
5814QDomDocumentPrivate::QDomDocumentPrivate()
5815 : QDomNodePrivate(
nullptr),
5816 impl(
new QDomImplementationPrivate),
5819 type =
new QDomDocumentTypePrivate(
this,
this);
5822 name = u"#document"_s;
5825QDomDocumentPrivate::QDomDocumentPrivate(
const QString& aname)
5826 : QDomNodePrivate(
nullptr),
5827 impl(
new QDomImplementationPrivate),
5830 type =
new QDomDocumentTypePrivate(
this,
this);
5834 name = u"#document"_s;
5837QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt)
5838 : QDomNodePrivate(
nullptr),
5839 impl(
new QDomImplementationPrivate),
5842 if (dt !=
nullptr) {
5845 type =
new QDomDocumentTypePrivate(
this,
this);
5849 name = u"#document"_s;
5852QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentPrivate* n,
bool deep)
5853 : QDomNodePrivate(n, deep),
5854 impl(n->impl->clone()),
5857 type =
static_cast<QDomDocumentTypePrivate*>(n->type->cloneNode());
5858 type->setParent(
this);
5861QDomDocumentPrivate::~QDomDocumentPrivate()
5865void QDomDocumentPrivate::clear()
5869 QDomNodePrivate::clear();
5872QDomDocument::ParseResult QDomDocumentPrivate::setContent(QXmlStreamReader *reader,
5873 QDomDocument::ParseOptions options)
5876 impl =
new QDomImplementationPrivate;
5877 type =
new QDomDocumentTypePrivate(
this,
this);
5881 const auto error = u"Failed to set content, XML reader is not initialized"_s;
5882 qWarning(
"%s", qPrintable(error));
5886 QDomParser domParser(
this, reader, options);
5888 if (!domParser.parse())
5889 return domParser.result();
5893QDomNodePrivate* QDomDocumentPrivate::cloneNode(
bool deep)
5895 QDomNodePrivate *p =
new QDomDocumentPrivate(
this, deep);
5901QDomElementPrivate* QDomDocumentPrivate::documentElement()
5903 QDomNodePrivate *p = first;
5904 while (p && !p->isElement())
5907 return static_cast<QDomElementPrivate *>(p);
5910QDomElementPrivate* QDomDocumentPrivate::createElement(
const QString &tagName)
5913 QString fixedName = fixedXmlName(tagName, &ok);
5917 QDomElementPrivate *e =
new QDomElementPrivate(
this,
nullptr, fixedName);
5922QDomElementPrivate* QDomDocumentPrivate::createElementNS(
const QString &nsURI,
const QString &qName)
5925 QString fixedName = fixedXmlName(qName, &ok,
true);
5929 QDomElementPrivate *e =
new QDomElementPrivate(
this,
nullptr, nsURI, fixedName);
5934QDomDocumentFragmentPrivate* QDomDocumentPrivate::createDocumentFragment()
5936 QDomDocumentFragmentPrivate *f =
new QDomDocumentFragmentPrivate(
this,
nullptr);
5941QDomTextPrivate* QDomDocumentPrivate::createTextNode(
const QString &data)
5944 QString fixedData = fixedCharData(data, &ok);
5948 QDomTextPrivate *t =
new QDomTextPrivate(
this,
nullptr, fixedData);
5953QDomCommentPrivate* QDomDocumentPrivate::createComment(
const QString &data)
5956 QString fixedData = fixedComment(data, &ok);
5960 QDomCommentPrivate *c =
new QDomCommentPrivate(
this,
nullptr, fixedData);
5965QDomCDATASectionPrivate* QDomDocumentPrivate::createCDATASection(
const QString &data)
5968 QString fixedData = fixedCDataSection(data, &ok);
5972 QDomCDATASectionPrivate *c =
new QDomCDATASectionPrivate(
this,
nullptr, fixedData);
5977QDomProcessingInstructionPrivate* QDomDocumentPrivate::createProcessingInstruction(
const QString &target,
5978 const QString &data)
5981 QString fixedData = fixedPIData(data, &ok);
5985 QString fixedTarget = fixedXmlName(target, &ok);
5989 QDomProcessingInstructionPrivate *p =
new QDomProcessingInstructionPrivate(
this,
nullptr, fixedTarget, fixedData);
5993QDomAttrPrivate* QDomDocumentPrivate::createAttribute(
const QString &aname)
5996 QString fixedName = fixedXmlName(aname, &ok);
6000 QDomAttrPrivate *a =
new QDomAttrPrivate(
this,
nullptr, fixedName);
6005QDomAttrPrivate* QDomDocumentPrivate::createAttributeNS(
const QString &nsURI,
const QString &qName)
6008 QString fixedName = fixedXmlName(qName, &ok,
true);
6012 QDomAttrPrivate *a =
new QDomAttrPrivate(
this,
nullptr, nsURI, fixedName);
6017QDomEntityReferencePrivate* QDomDocumentPrivate::createEntityReference(
const QString &aname)
6020 QString fixedName = fixedXmlName(aname, &ok);
6024 QDomEntityReferencePrivate *e =
new QDomEntityReferencePrivate(
this,
nullptr, fixedName);
6029QDomNodePrivate* QDomDocumentPrivate::importNode(QDomNodePrivate *importedNode,
bool deep)
6031 QDomNodePrivate *node =
nullptr;
6032 switch (importedNode->nodeType()) {
6033 case QDomNode::AttributeNode:
6034 node =
new QDomAttrPrivate(
static_cast<QDomAttrPrivate *>(importedNode),
true);
6036 case QDomNode::DocumentFragmentNode:
6037 node =
new QDomDocumentFragmentPrivate(
6038 static_cast<QDomDocumentFragmentPrivate *>(importedNode), deep);
6040 case QDomNode::ElementNode:
6041 node =
new QDomElementPrivate(
static_cast<QDomElementPrivate *>(importedNode), deep);
6043 case QDomNode::EntityNode:
6044 node =
new QDomEntityPrivate(
static_cast<QDomEntityPrivate *>(importedNode), deep);
6046 case QDomNode::EntityReferenceNode:
6047 node =
new QDomEntityReferencePrivate(
6048 static_cast<QDomEntityReferencePrivate *>(importedNode),
false);
6050 case QDomNode::NotationNode:
6051 node =
new QDomNotationPrivate(
static_cast<QDomNotationPrivate *>(importedNode), deep);
6053 case QDomNode::ProcessingInstructionNode:
6054 node =
new QDomProcessingInstructionPrivate(
6055 static_cast<QDomProcessingInstructionPrivate *>(importedNode), deep);
6057 case QDomNode::TextNode:
6058 node =
new QDomTextPrivate(
static_cast<QDomTextPrivate *>(importedNode), deep);
6060 case QDomNode::CDATASectionNode:
6061 node =
new QDomCDATASectionPrivate(
static_cast<QDomCDATASectionPrivate *>(importedNode),
6064 case QDomNode::CommentNode:
6065 node =
new QDomCommentPrivate(
static_cast<QDomCommentPrivate *>(importedNode), deep);
6071 node->setOwnerDocument(
this);
6079void QDomDocumentPrivate::saveDocument(QTextStream& s,
const int indent, QDomNode::EncodingPolicy encUsed)
const
6081 const QDomNodePrivate* n = first;
6083 if (encUsed == QDomNode::EncodingFromDocument) {
6084#if QT_CONFIG(regularexpression)
6085 const QDomNodePrivate* n = first;
6087 if (n && n->isProcessingInstruction() && n->nodeName() ==
"xml"_L1) {
6089 QString data = n->nodeValue();
6090 QRegularExpression encoding(QString::fromLatin1(
"encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))"));
6091 auto match = encoding.match(data);
6092 QString enc = match.captured(3);
6094 enc = match.captured(5);
6095 if (!enc.isEmpty()) {
6096 auto encoding = QStringConverter::encodingForName(enc.toUtf8().constData());
6098 qWarning() <<
"QDomDocument::save(): Unsupported encoding" << enc <<
"specified.";
6100 s.setEncoding(encoding.value());
6107 if (!doc && !(n->isProcessingInstruction() && n->nodeName() ==
"xml"_L1)) {
6109 type->save(s, 0, indent);
6112 n->saveSubTree(n, s, 0, indent);
6119 const QByteArray codecName = QStringConverter::nameForEncoding(s.encoding());
6121 s <<
"<?xml version=\"1.0\" encoding=\""
6126 const QDomNodePrivate* startNode = n;
6130 if (n->isProcessingInstruction() && n->nodeName() ==
"xml"_L1) {
6131 startNode = n->next;
6140 startNode->saveSubTree(startNode, s, 0, indent);
6141 startNode = startNode->next;
6147
6148
6149
6150
6152#define IMPL static_cast<QDomDocumentPrivate *>(impl)
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
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6233
6234
6235QDomDocument::QDomDocument()
6241
6242
6243
6244QDomDocument::QDomDocument(
const QString& name)
6247 impl =
new QDomDocumentPrivate(name);
6251
6252
6253
6254
6255QDomDocument::QDomDocument(
const QDomDocumentType& doctype)
6257 impl =
new QDomDocumentPrivate(
static_cast<QDomDocumentTypePrivate *>(doctype.impl));
6261
6262
6263
6264
6265
6266
6267QDomDocument::QDomDocument(
const QDomDocument &document)
6268 : QDomNode(document)
6272QDomDocument::QDomDocument(QDomDocumentPrivate *pimpl)
6278
6279
6280
6281
6282
6283
6284QDomDocument &QDomDocument::operator=(
const QDomDocument &other) =
default;
6287
6288
6289QDomDocument::~QDomDocument()
6293#if QT_DEPRECATED_SINCE(6
, 8
)
6295QT_WARNING_DISABLE_DEPRECATED
6297
6298
6299
6300
6301
6302
6303
6304
6305bool QDomDocument::setContent(
const QString& text,
bool namespaceProcessing,
6306 QString *errorMsg,
int *errorLine,
int *errorColumn)
6308 QXmlStreamReader reader(text);
6309 reader.setNamespaceProcessing(namespaceProcessing);
6310 return setContent(&reader, namespaceProcessing, errorMsg, errorLine, errorColumn);
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
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365bool QDomDocument::setContent(
const QByteArray &data,
bool namespaceProcessing,
6366 QString *errorMsg,
int *errorLine,
int *errorColumn)
6368 QXmlStreamReader reader(data);
6369 reader.setNamespaceProcessing(namespaceProcessing);
6370 return setContent(&reader, namespaceProcessing, errorMsg, errorLine, errorColumn);
6373static inline QDomDocument::ParseOptions toParseOptions(
bool namespaceProcessing)
6375 return namespaceProcessing ? QDomDocument::ParseOption::UseNamespaceProcessing
6376 : QDomDocument::ParseOption::Default;
6379static inline void unpackParseResult(
const QDomDocument::ParseResult &parseResult,
6380 QString *errorMsg,
int *errorLine,
int *errorColumn)
6384 *errorMsg = parseResult.errorMessage;
6386 *errorLine =
static_cast<
int>(parseResult.errorLine);
6388 *errorColumn =
static_cast<
int>(parseResult.errorColumn);
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404bool QDomDocument::setContent(QIODevice* dev,
bool namespaceProcessing,
6405 QString *errorMsg,
int *errorLine,
int *errorColumn)
6407 ParseResult result = setContent(dev, toParseOptions(namespaceProcessing));
6408 unpackParseResult(result, errorMsg, errorLine, errorColumn);
6409 return bool(result);
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423bool QDomDocument::setContent(
const QString& text, QString *errorMsg,
int *errorLine,
int *errorColumn)
6425 return setContent(text,
false, errorMsg, errorLine, errorColumn);
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438bool QDomDocument::setContent(
const QByteArray& buffer, QString *errorMsg,
int *errorLine,
int *errorColumn )
6440 return setContent(buffer,
false, errorMsg, errorLine, errorColumn);
6444
6445
6446
6447
6448
6449
6450
6451
6452bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg,
int *errorLine,
int *errorColumn )
6454 return setContent(dev,
false, errorMsg, errorLine, errorColumn);
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477bool QDomDocument::setContent(QXmlStreamReader *reader,
bool namespaceProcessing,
6478 QString *errorMsg,
int *errorLine,
int *errorColumn)
6480 ParseResult result = setContent(reader, toParseOptions(namespaceProcessing));
6481 unpackParseResult(result, errorMsg, errorLine, errorColumn);
6482 return bool(result);
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6518
6519
6520
6521
6522
6523
6524
6527
6528
6529
6530
6531
6532
6533
6536
6537
6538
6539
6540
6541
6542
6545
6546
6547
6548
6549
6550
6551
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
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598QDomDocument::ParseResult QDomDocument::setContentImpl(
const QByteArray &data, ParseOptions options)
6600 QXmlStreamReader reader(data);
6601 reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
6602 return setContent(&reader, options);
6605QDomDocument::ParseResult QDomDocument::setContent(QAnyStringView data, ParseOptions options)
6607 QXmlStreamReader reader(data);
6608 reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
6609 return setContent(&reader, options);
6612QDomDocument::ParseResult QDomDocument::setContent(QIODevice *device, ParseOptions options)
6614#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
6615 if (!device->isOpen()) {
6616 qWarning(
"QDomDocument called with unopened QIODevice. "
6617 "This will not be supported in future Qt versions.");
6618 if (!device->open(QIODevice::ReadOnly)) {
6619 const auto error = u"QDomDocument::setContent: Failed to open device."_s;
6620 qWarning(
"%s", qPrintable(error));
6626 QXmlStreamReader reader(device);
6627 reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
6628 return setContent(&reader, options);
6631QDomDocument::ParseResult QDomDocument::setContent(QXmlStreamReader *reader, ParseOptions options)
6634 impl =
new QDomDocumentPrivate();
6635 return IMPL->setContent(reader, options);
6639
6640
6641
6642
6643
6644
6645
6646QString QDomDocument::toString(
int indent)
const
6649 QTextStream s(&str, QIODevice::WriteOnly);
6655
6656
6657
6658
6659
6660
6661
6662
6663QByteArray QDomDocument::toByteArray(
int indent)
const
6667 return toString(indent).toUtf8();
6672
6673
6674QDomDocumentType QDomDocument::doctype()
const
6677 return QDomDocumentType();
6678 return QDomDocumentType(IMPL->doctype());
6682
6683
6684QDomImplementation QDomDocument::implementation()
const
6687 return QDomImplementation();
6688 return QDomImplementation(IMPL->implementation());
6692
6693
6694QDomElement QDomDocument::documentElement()
const
6697 return QDomElement();
6698 return QDomElement(IMPL->documentElement());
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711QDomElement QDomDocument::createElement(
const QString& tagName)
6714 impl =
new QDomDocumentPrivate();
6715 return QDomElement(IMPL->createElement(tagName));
6719
6720
6721
6722
6723QDomDocumentFragment QDomDocument::createDocumentFragment()
6726 impl =
new QDomDocumentPrivate();
6727 return QDomDocumentFragment(IMPL->createDocumentFragment());
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740QDomText QDomDocument::createTextNode(
const QString& value)
6743 impl =
new QDomDocumentPrivate();
6744 return QDomText(IMPL->createTextNode(value));
6748
6749
6750
6751
6752
6753
6754
6755
6756QDomComment QDomDocument::createComment(
const QString& value)
6759 impl =
new QDomDocumentPrivate();
6760 return QDomComment(IMPL->createComment(value));
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773QDomCDATASection QDomDocument::createCDATASection(
const QString& value)
6776 impl =
new QDomDocumentPrivate();
6777 return QDomCDATASection(IMPL->createCDATASection(value));
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792QDomProcessingInstruction QDomDocument::createProcessingInstruction(
const QString& target,
6793 const QString& data)
6796 impl =
new QDomDocumentPrivate();
6797 return QDomProcessingInstruction(IMPL->createProcessingInstruction(target, data));
6802
6803
6804
6805
6806
6807
6808
6809
6810QDomAttr QDomDocument::createAttribute(
const QString& name)
6813 impl =
new QDomDocumentPrivate();
6814 return QDomAttr(IMPL->createAttribute(name));
6818
6819
6820
6821
6822
6823
6824
6825
6826QDomEntityReference QDomDocument::createEntityReference(
const QString& name)
6829 impl =
new QDomDocumentPrivate();
6830 return QDomEntityReference(IMPL->createEntityReference(name));
6834
6835
6836
6837
6838
6839
6840
6841QDomNodeList QDomDocument::elementsByTagName(
const QString& tagname)
const
6843 return QDomNodeList(
new QDomNodeListPrivate(impl, tagname));
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
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915QDomNode QDomDocument::importNode(
const QDomNode& importedNode,
bool deep)
6917 if (importedNode.isNull())
6920 impl =
new QDomDocumentPrivate();
6921 return QDomNode(IMPL->importNode(importedNode.impl, deep));
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936QDomElement QDomDocument::createElementNS(
const QString& nsURI,
const QString& qName)
6939 impl =
new QDomDocumentPrivate();
6940 return QDomElement(IMPL->createElementNS(nsURI, qName));
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955QDomAttr QDomDocument::createAttributeNS(
const QString& nsURI,
const QString& qName)
6958 impl =
new QDomDocumentPrivate();
6959 return QDomAttr(IMPL->createAttributeNS(nsURI, qName));
6963
6964
6965
6966
6967
6968
6969
6970QDomNodeList QDomDocument::elementsByTagNameNS(
const QString& nsURI,
const QString& localName)
6972 return QDomNodeList(
new QDomNodeListPrivate(impl, nsURI, localName));
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985QDomElement QDomDocument::elementById(
const QString& )
6987 qWarning(
"elementById() is not implemented and will always return a null node.");
6988 return QDomElement();
6992
6993
6994
6995
7000
7001
7002
7003
7006
7007
7008
7009
7010
7011QDomAttr QDomNode::toAttr()
const
7013 if (impl && impl->isAttr())
7014 return QDomAttr(
static_cast<QDomAttrPrivate *>(impl));
7019
7020
7021
7022
7023
7024QDomCDATASection QDomNode::toCDATASection()
const
7026 if (impl && impl->isCDATASection())
7027 return QDomCDATASection(
static_cast<QDomCDATASectionPrivate *>(impl));
7028 return QDomCDATASection();
7032
7033
7034
7035
7036
7037QDomDocumentFragment QDomNode::toDocumentFragment()
const
7039 if (impl && impl->isDocumentFragment())
7040 return QDomDocumentFragment(
static_cast<QDomDocumentFragmentPrivate *>(impl));
7041 return QDomDocumentFragment();
7045
7046
7047
7048
7049
7050QDomDocument QDomNode::toDocument()
const
7052 if (impl && impl->isDocument())
7053 return QDomDocument(
static_cast<QDomDocumentPrivate *>(impl));
7054 return QDomDocument();
7058
7059
7060
7061
7062
7063QDomDocumentType QDomNode::toDocumentType()
const
7065 if (impl && impl->isDocumentType())
7066 return QDomDocumentType(
static_cast<QDomDocumentTypePrivate *>(impl));
7067 return QDomDocumentType();
7071
7072
7073
7074
7075
7076QDomElement QDomNode::toElement()
const
7078 if (impl && impl->isElement())
7079 return QDomElement(
static_cast<QDomElementPrivate *>(impl));
7080 return QDomElement();
7084
7085
7086
7087
7088
7089QDomEntityReference QDomNode::toEntityReference()
const
7091 if (impl && impl->isEntityReference())
7092 return QDomEntityReference(
static_cast<QDomEntityReferencePrivate *>(impl));
7093 return QDomEntityReference();
7097
7098
7099
7100
7101
7102QDomText QDomNode::toText()
const
7104 if (impl && impl->isText())
7105 return QDomText(
static_cast<QDomTextPrivate *>(impl));
7110
7111
7112
7113
7114
7115QDomEntity QDomNode::toEntity()
const
7117 if (impl && impl->isEntity())
7118 return QDomEntity(
static_cast<QDomEntityPrivate *>(impl));
7119 return QDomEntity();
7123
7124
7125
7126
7127
7128QDomNotation QDomNode::toNotation()
const
7130 if (impl && impl->isNotation())
7131 return QDomNotation(
static_cast<QDomNotationPrivate *>(impl));
7132 return QDomNotation();
7136
7137
7138
7139
7140
7141QDomProcessingInstruction QDomNode::toProcessingInstruction()
const
7143 if (impl && impl->isProcessingInstruction())
7144 return QDomProcessingInstruction(
static_cast<QDomProcessingInstructionPrivate *>(impl));
7145 return QDomProcessingInstruction();
7149
7150
7151
7152
7153
7154QDomCharacterData QDomNode::toCharacterData()
const
7156 if (impl && impl->isCharacterData())
7157 return QDomCharacterData(
static_cast<QDomCharacterDataPrivate *>(impl));
7158 return QDomCharacterData();
7162
7163
7164
7165
7166
7167QDomComment QDomNode::toComment()
const
7169 if (impl && impl->isComment())
7170 return QDomComment(
static_cast<QDomCommentPrivate *>(impl));
7171 return QDomComment();
7175
7176
7177
7178