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::ReturnNullNode;
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 = std::move(fixedPublicId);
509 dt->systemId = std::move(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
553
556
557
558
559
560
561
562
563
564
565
566
569
570
571
572
573
574
575
576
578QDomImplementation::InvalidDataPolicy QDomImplementation::invalidDataPolicy()
580 return QDomImplementationPrivate::invalidDataPolicy;
584
585
586
587
588
589
590
591
592
593
594
595
596
598void QDomImplementation::setInvalidDataPolicy(InvalidDataPolicy policy)
600 QDomImplementationPrivate::invalidDataPolicy = policy;
604
605
606
607
609QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl) : ref(1)
613 node_impl->ref.ref();
617QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl,
const QString &name) :
622 node_impl->ref.ref();
627QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl,
const QString &_nsURI,
const QString &localName) :
632 node_impl->ref.ref();
638QDomNodeListPrivate::~QDomNodeListPrivate()
640 if (node_impl && !node_impl->ref.deref())
644bool QDomNodeListPrivate::operator==(
const QDomNodeListPrivate &other)
const noexcept
646 return (node_impl == other.node_impl) && (tagname == other.tagname);
649void QDomNodeListPrivate::createList()
const
655 const QDomDocumentPrivate *
const doc = node_impl->ownerDocument();
656 if (doc && timestamp != doc->nodeListTime)
657 timestamp = doc->nodeListTime;
658 forEachNode([&](QDomNodePrivate *p){ list.append(p); });
662
663
664
665
666bool QDomNodeListPrivate::checkNode(QDomNodePrivate *p)
const
668 return p && p->isElement() && (nsURI.isNull()
669 ? p->nodeName() == tagname
670 : p->name == tagname && p->namespaceURI == nsURI);
674
675
676
677
678
679
680
681
682QDomNodePrivate *QDomNodeListPrivate::findNextInOrder(QDomNodePrivate *p)
const
687 if (tagname.isNull()) {
690 else if (p && p->next)
694 if (p == node_impl) {
699 while (p && p != node_impl) {
702 }
else if (p->next) {
706 while (p && p != node_impl && !p->next)
708 if (p && p != node_impl)
718
719
720
721
722
723QDomNodePrivate *QDomNodeListPrivate::findPrevInOrder(QDomNodePrivate *p)
const
728 if (tagname.isNull() && p == node_impl)
730 if (tagname.isNull())
735 if (p == node_impl) {
757void QDomNodeListPrivate::forEachNode(qxp::function_ref<
void(QDomNodePrivate*)> yield)
const
762 QDomNodePrivate *current = findNextInOrder(node_impl);
763 while (current && current != node_impl) {
765 current = findNextInOrder(current);
769bool QDomNodeListPrivate::maybeCreateList()
const
774 const QDomDocumentPrivate *
const doc = node_impl->ownerDocument();
775 if (!doc || timestamp != doc->nodeListTime)
781QDomNodePrivate *QDomNodeListPrivate::item(
int index)
783 if (!maybeCreateList() || index >= list.size() || index < 0)
786 return list.at(index);
789int QDomNodeListPrivate::length()
const
791 if (!maybeCreateList())
797int QDomNodeListPrivate::noexceptLength()
const noexcept
800 forEachNode([&](QDomNodePrivate*){ ++count; });
805
806
807
808
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
836
837
838QDomNodeList::QDomNodeList()
843QDomNodeList::QDomNodeList(QDomNodeListPrivate *pimpl)
849
850
851QDomNodeList::QDomNodeList(
const QDomNodeList &nodeList)
852 : impl(nodeList.impl)
859
860
861QDomNodeList& QDomNodeList::operator=(
const QDomNodeList &other)
864 other.impl->ref.ref();
865 if (impl && !impl->ref.deref())
872
873
874
875
876
877bool comparesEqual(
const QDomNodeList &lhs,
const QDomNodeList &rhs)
noexcept
879 if (lhs.impl == rhs.impl)
881 if (!lhs.impl || !rhs.impl)
883 return *lhs.impl == *rhs.impl;
887
888
889
890
891
894
895
896QDomNodeList::~QDomNodeList()
898 if (impl && !impl->ref.deref())
903
904
905
906
907
908
909
910
911QDomNode QDomNodeList::item(
int index)
const
916 return QDomNode(impl->item(index));
920
921
922int QDomNodeList::length()
const
926 return impl->length();
930
931
932int QDomNodeList::noexceptLength()
const noexcept
936 return impl->noexceptLength();
940
941
942
943
944
947
948
949
950
953
954
955
956
959
960
961
962
963
964
965
966
967
970
971
972
973
974
975
976
977
978
979
982
983
984
985
986
987
988
989
990
991
992
993
994
995
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1017QDomNodeList::It::It(
const QDomNodeListPrivate *lp,
bool start)
noexcept
1020 if (!lp || !lp->node_impl)
1023 current = lp->findNextInOrder(lp->node_impl);
1025 current = lp->node_impl;
1028QDomNodePrivate *QDomNodeList::It::findNextInOrder(
const QDomNodeListPrivate *parent, QDomNodePrivate *current)
1030 return parent->findNextInOrder(current);
1033QDomNodePrivate *QDomNodeList::It::findPrevInOrder(
const QDomNodeListPrivate *parent, QDomNodePrivate *current)
1035 return parent->findPrevInOrder(current);
1039
1040
1041
1042
1044inline void QDomNodePrivate::setOwnerDocument(QDomDocumentPrivate *doc)
1050QDomNodePrivate::QDomNodePrivate(QDomDocumentPrivate *doc, QDomNodePrivate *par) : ref(1)
1055 setOwnerDocument(doc);
1060 createdWithDom1Interface =
true;
1065QDomNodePrivate::QDomNodePrivate(QDomNodePrivate *n,
bool deep) : ref(1)
1067 setOwnerDocument(n->ownerDocument());
1076 namespaceURI = n->namespaceURI;
1077 createdWithDom1Interface = n->createdWithDom1Interface;
1084 for (QDomNodePrivate* x = n->first; x; x = x->next)
1085 appendChild(x->cloneNode(
true));
1088QDomNodePrivate::~QDomNodePrivate()
1090 QDomNodePrivate *p =
this;
1094 if (QDomNodePrivate *c = p->first) {
1103 delete std::exchange(p, p->parent());
1108void QDomNodePrivate::clear()
1110 QDomNodePrivate* p = first;
1115 if (!p->ref.deref())
1123QDomNodePrivate* QDomNodePrivate::namedItem(
const QString &n)
1125 QDomNodePrivate* p = first;
1127 if (p->nodeName() == n)
1135QDomNodePrivate* QDomNodePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
1142 if (newChild == refChild)
1146 if (refChild && refChild->parent() !=
this)
1150 QDomDocumentPrivate *
const doc = ownerDocument();
1152 doc->nodeListTime++;
1156 if (newChild->isDocumentFragment()) {
1158 if (newChild->first ==
nullptr)
1162 QDomNodePrivate* n = newChild->first;
1169 if (!refChild || refChild->prev ==
nullptr) {
1171 first->prev = newChild->last;
1172 newChild->last->next = first;
1174 last = newChild->last;
1175 first = newChild->first;
1178 newChild->last->next = refChild;
1179 newChild->first->prev = refChild->prev;
1180 refChild->prev->next = newChild->first;
1181 refChild->prev = newChild->last;
1188 newChild->first =
nullptr;
1189 newChild->last =
nullptr;
1195 newChild->ref.ref();
1197 if (newChild->parent())
1198 newChild->parent()->removeChild(newChild);
1200 newChild->setParent(
this);
1204 first->prev = newChild;
1205 newChild->next = first;
1212 if (refChild->prev ==
nullptr) {
1214 first->prev = newChild;
1215 newChild->next = first;
1222 newChild->next = refChild;
1223 newChild->prev = refChild->prev;
1224 refChild->prev->next = newChild;
1225 refChild->prev = newChild;
1230QDomNodePrivate* QDomNodePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
1237 if (newChild == refChild)
1241 if (refChild && refChild->parent() !=
this)
1245 QDomDocumentPrivate *
const doc = ownerDocument();
1247 doc->nodeListTime++;
1251 if (newChild->isDocumentFragment()) {
1253 if (newChild->first ==
nullptr)
1257 QDomNodePrivate* n = newChild->first;
1264 if (!refChild || refChild->next ==
nullptr) {
1266 last->next = newChild->first;
1267 newChild->first->prev = last;
1269 first = newChild->first;
1270 last = newChild->last;
1272 newChild->first->prev = refChild;
1273 newChild->last->next = refChild->next;
1274 refChild->next->prev = newChild->last;
1275 refChild->next = newChild->first;
1282 newChild->first =
nullptr;
1283 newChild->last =
nullptr;
1288 if (newChild->parent())
1289 newChild->parent()->removeChild(newChild);
1293 newChild->ref.ref();
1295 newChild->setParent(
this);
1300 last->next = newChild;
1301 newChild->prev = last;
1308 if (refChild->next ==
nullptr) {
1310 last->next = newChild;
1311 newChild->prev = last;
1318 newChild->prev = refChild;
1319 newChild->next = refChild->next;
1320 refChild->next->prev = newChild;
1321 refChild->next = newChild;
1326QDomNodePrivate* QDomNodePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild)
1328 if (!newChild || !oldChild)
1330 if (oldChild->parent() !=
this)
1332 if (newChild == oldChild)
1336 QDomDocumentPrivate *
const doc = ownerDocument();
1338 doc->nodeListTime++;
1342 if (newChild->isDocumentFragment()) {
1344 if (newChild->first ==
nullptr)
1348 QDomNodePrivate* n = newChild->first;
1356 oldChild->next->prev = newChild->last;
1358 oldChild->prev->next = newChild->first;
1360 newChild->last->next = oldChild->next;
1361 newChild->first->prev = oldChild->prev;
1363 if (first == oldChild)
1364 first = newChild->first;
1365 if (last == oldChild)
1366 last = newChild->last;
1368 oldChild->setNoParent();
1369 oldChild->next =
nullptr;
1370 oldChild->prev =
nullptr;
1376 newChild->first =
nullptr;
1377 newChild->last =
nullptr;
1380 oldChild->ref.deref();
1387 newChild->ref.ref();
1390 if (newChild->parent())
1391 newChild->parent()->removeChild(newChild);
1393 newChild->setParent(
this);
1396 oldChild->next->prev = newChild;
1398 oldChild->prev->next = newChild;
1400 newChild->next = oldChild->next;
1401 newChild->prev = oldChild->prev;
1403 if (first == oldChild)
1405 if (last == oldChild)
1408 oldChild->setNoParent();
1409 oldChild->next =
nullptr;
1410 oldChild->prev =
nullptr;
1413 oldChild->ref.deref();
1418QDomNodePrivate* QDomNodePrivate::removeChild(QDomNodePrivate* oldChild)
1421 if (oldChild->parent() !=
this)
1425 QDomDocumentPrivate *
const doc = ownerDocument();
1427 doc->nodeListTime++;
1431 if (oldChild->next ==
nullptr && oldChild->prev ==
nullptr && first != oldChild)
1435 oldChild->next->prev = oldChild->prev;
1437 oldChild->prev->next = oldChild->next;
1439 if (last == oldChild)
1440 last = oldChild->prev;
1441 if (first == oldChild)
1442 first = oldChild->next;
1444 oldChild->setNoParent();
1445 oldChild->next =
nullptr;
1446 oldChild->prev =
nullptr;
1449 oldChild->ref.deref();
1454QDomNodePrivate* QDomNodePrivate::appendChild(QDomNodePrivate* newChild)
1457 return insertAfter(newChild,
nullptr);
1460QDomDocumentPrivate* QDomNodePrivate::ownerDocument()
1462 QDomNodePrivate* p =
this;
1463 while (p && !p->isDocument()) {
1465 return static_cast<QDomDocumentPrivate *>(p->ownerNode);
1469 return static_cast<QDomDocumentPrivate *>(p);
1472QDomNodePrivate* QDomNodePrivate::cloneNode(
bool deep)
1474 QDomNodePrivate* p =
new QDomNodePrivate(
this, deep);
1480static void qNormalizeNode(QDomNodePrivate* n)
1482 QDomNodePrivate* p = n->first;
1483 QDomTextPrivate* t =
nullptr;
1488 QDomNodePrivate* tmp = p->next;
1489 t->appendData(p->nodeValue());
1493 t =
static_cast<QDomTextPrivate *>(p);
1502void QDomNodePrivate::normalize()
1506 qNormalizeNode(
this);
1509void QDomNodePrivate::saveSubTree(
const QDomNodePrivate *n, QTextStream &s,
1510 int depth,
int indent)
const
1515 const QDomNodePrivate *root = n->first;
1516 n->save(s, depth, indent);
1518 const int branchDepth = depth + 1;
1521 root->save(s, layerDepth + branchDepth, indent);
1528 root->afterSave(s, layerDepth + branchDepth, indent);
1529 const QDomNodePrivate *prev = root;
1532 while (!root && (layerDepth > 0)) {
1533 root = prev->parent();
1535 root->afterSave(s, layerDepth + branchDepth, indent);
1540 Q_ASSERT(layerDepth == 0);
1542 n->afterSave(s, depth, indent);
1545void QDomNodePrivate::setLocation(
int lineNumber,
int columnNumber)
1547 this->lineNumber = lineNumber;
1548 this->columnNumber = columnNumber;
1552
1553
1554
1555
1557#define IMPL static_cast<QDomNodePrivate *>(impl)
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
1638
1639
1640
1641
1644
1645
1652
1653
1654
1655
1656
1657
1658QDomNode::QDomNode(
const QDomNode &node)
1666
1667
1668QDomNode::QDomNode(QDomNodePrivate *pimpl)
1676
1677
1678
1679
1680
1681
1682QDomNode& QDomNode::operator=(
const QDomNode &other)
1685 other.impl->ref.ref();
1686 if (impl && !impl->ref.deref())
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712bool QDomNode::operator==(
const QDomNode &other)
const
1714 return impl == other.impl;
1718
1719
1720
1721bool QDomNode::operator!=(
const QDomNode &other)
const
1723 return !operator==(other);
1727
1728
1729QDomNode::~QDomNode()
1731 if (impl && !impl->ref.deref())
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764QString QDomNode::nodeName()
const
1769 if (!IMPL->prefix.isEmpty())
1770 return IMPL->prefix + u':' + IMPL->name;
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792QString QDomNode::nodeValue()
const
1800
1801
1802
1803
1804void QDomNode::setNodeValue(
const QString& value)
1807 IMPL->setNodeValue(value);
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1831
1832
1833
1834
1835
1836
1837
1838QDomNode::NodeType QDomNode::nodeType()
const
1841 return QDomNode::BaseNode;
1842 return IMPL->nodeType();
1846
1847
1848
1849QDomNode QDomNode::parentNode()
const
1853 return QDomNode(IMPL->parent());
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874QDomNodeList QDomNode::childNodes()
const
1877 return QDomNodeList();
1878 return QDomNodeList(
new QDomNodeListPrivate(impl));
1882
1883
1884
1885
1886
1887
1888QDomNode QDomNode::firstChild()
const
1892 return QDomNode(IMPL->first);
1896
1897
1898
1899
1900
1901
1902QDomNode QDomNode::lastChild()
const
1906 return QDomNode(IMPL->last);
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922QDomNode QDomNode::previousSibling()
const
1926 return QDomNode(IMPL->prev);
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942QDomNode QDomNode::nextSibling()
const
1946 return QDomNode(IMPL->next);
1952
1953
1954
1955
1956
1957
1958QDomNamedNodeMap QDomNode::attributes()
const
1960 if (!impl || !impl->isElement())
1961 return QDomNamedNodeMap();
1963 return QDomNamedNodeMap(
static_cast<QDomElementPrivate *>(impl)->attributes());
1967
1968
1969QDomDocument QDomNode::ownerDocument()
const
1972 return QDomDocument();
1973 return QDomDocument(IMPL->ownerDocument());
1977
1978
1979
1980
1981
1982
1983
1984QDomNode QDomNode::cloneNode(
bool deep)
const
1988 return QDomNode(IMPL->cloneNode(deep));
1992
1993
1994
1995
1996
1997void QDomNode::normalize()
2005
2006
2007
2008
2009
2010
2011bool QDomNode::isSupported(
const QString& feature,
const QString& version)
const
2013 QDomImplementation i;
2014 return i.hasFeature(feature, version);
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029QString QDomNode::namespaceURI()
const
2033 return IMPL->namespaceURI;
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058QString QDomNode::prefix()
const
2062 return IMPL->prefix;
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079void QDomNode::setPrefix(
const QString& pre)
2081 if (!impl || IMPL->prefix.isNull())
2083 if (isAttr() || isElement())
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099QString QDomNode::localName()
const
2101 if (!impl || IMPL->createdWithDom1Interface)
2107
2108
2109
2110
2111bool QDomNode::hasAttributes()
const
2113 if (!impl || !impl->isElement())
2115 return static_cast<QDomElementPrivate *>(impl)->hasAttributes();
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139QDomNode QDomNode::insertBefore(
const QDomNode& newChild,
const QDomNode& refChild)
2143 return QDomNode(IMPL->insertBefore(newChild.impl, refChild.impl));
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167QDomNode QDomNode::insertAfter(
const QDomNode& newChild,
const QDomNode& refChild)
2171 return QDomNode(IMPL->insertAfter(newChild.impl, refChild.impl));
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189QDomNode QDomNode::replaceChild(
const QDomNode& newChild,
const QDomNode& oldChild)
2191 if (!impl || !newChild.impl || !oldChild.impl)
2193 return QDomNode(IMPL->replaceChild(newChild.impl, oldChild.impl));
2197
2198
2199
2200
2201
2202
2203
2204QDomNode QDomNode::removeChild(
const QDomNode& oldChild)
2209 if (oldChild.isNull())
2212 return QDomNode(IMPL->removeChild(oldChild.impl));
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239QDomNode QDomNode::appendChild(
const QDomNode& newChild)
2242 qWarning(
"Calling appendChild() on a null node does nothing.");
2245 return QDomNode(IMPL->appendChild(newChild.impl));
2249
2250
2251
2252bool QDomNode::hasChildNodes()
const
2256 return IMPL->first !=
nullptr;
2260
2261
2262
2263bool QDomNode::isNull()
const
2265 return (impl ==
nullptr);
2269
2270
2271
2272
2273
2274void QDomNode::clear()
2276 if (impl && !impl->ref.deref())
2282
2283
2284
2285
2286
2287
2288
2289
2290QDomNode QDomNode::namedItem(
const QString& name)
const
2294 return QDomNode(impl->namedItem(name));
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322void QDomNode::save(QTextStream& stream,
int indent, EncodingPolicy encodingPolicy)
const
2328 static_cast<
const QDomDocumentPrivate *>(impl)->saveDocument(stream, indent, encodingPolicy);
2330 IMPL->saveSubTree(IMPL, stream, 1, indent);
2334
2335
2336
2337
2338
2339QTextStream& operator<<(QTextStream& str,
const QDomNode& node)
2347
2348
2349
2350
2351
2352
2353
2354
2355bool QDomNode::isAttr()
const
2358 return impl->isAttr();
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372bool QDomNode::isCDATASection()
const
2375 return impl->isCDATASection();
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389bool QDomNode::isDocumentFragment()
const
2392 return impl->isDocumentFragment();
2397
2398
2399
2400
2401
2402
2403
2404bool QDomNode::isDocument()
const
2407 return impl->isDocument();
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421bool QDomNode::isDocumentType()
const
2424 return impl->isDocumentType();
2429
2430
2431
2432
2433
2434
2435
2436bool QDomNode::isElement()
const
2439 return impl->isElement();
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453bool QDomNode::isEntityReference()
const
2456 return impl->isEntityReference();
2461
2462
2463
2464
2465
2466
2467
2468bool QDomNode::isText()
const
2471 return impl->isText();
2476
2477
2478
2479
2480
2481
2482
2483bool QDomNode::isEntity()
const
2486 return impl->isEntity();
2491
2492
2493
2494
2495
2496
2497
2498bool QDomNode::isNotation()
const
2501 return impl->isNotation();
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515bool QDomNode::isProcessingInstruction()
const
2518 return impl->isProcessingInstruction();
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532bool QDomNode::isCharacterData()
const
2535 return impl->isCharacterData();
2540
2541
2542
2543
2544
2545
2546
2547bool QDomNode::isComment()
const
2550 return impl->isComment();
2557
2558
2559
2560
2561
2562
2563
2564
2566QDomElement QDomNode::firstChildElement(
const QString &tagName,
const QString &namespaceURI)
const
2568 for (QDomNode child = firstChild(); !child.isNull(); child = child.nextSibling()) {
2569 if (child.isElement() && (namespaceURI.isEmpty() || child.namespaceURI() == namespaceURI)) {
2570 QDomElement elt = child.toElement();
2571 if (tagName.isEmpty() || elt.tagName() == tagName)
2575 return QDomElement();
2579
2580
2581
2582
2583
2584
2585
2586
2588QDomElement QDomNode::lastChildElement(
const QString &tagName,
const QString &namespaceURI)
const
2590 for (QDomNode child = lastChild(); !child.isNull(); child = child.previousSibling()) {
2591 if (child.isElement() && (namespaceURI.isEmpty() || child.namespaceURI() == namespaceURI)) {
2592 QDomElement elt = child.toElement();
2593 if (tagName.isEmpty() || elt.tagName() == tagName)
2597 return QDomElement();
2601
2602
2603
2604
2605
2606
2607
2608
2609
2611QDomElement QDomNode::nextSiblingElement(
const QString &tagName,
const QString &namespaceURI)
const
2613 for (QDomNode sib = nextSibling(); !sib.isNull(); sib = sib.nextSibling()) {
2614 if (sib.isElement() && (namespaceURI.isEmpty() || sib.namespaceURI() == namespaceURI)) {
2615 QDomElement elt = sib.toElement();
2616 if (tagName.isEmpty() || elt.tagName() == tagName)
2620 return QDomElement();
2624
2625
2626
2627
2628
2629
2630
2631
2632
2634QDomElement QDomNode::previousSiblingElement(
const QString &tagName,
const QString &namespaceURI)
const
2636 for (QDomNode sib = previousSibling(); !sib.isNull(); sib = sib.previousSibling()) {
2637 if (sib.isElement() && (namespaceURI.isEmpty() || sib.namespaceURI() == namespaceURI)) {
2638 QDomElement elt = sib.toElement();
2639 if (tagName.isEmpty() || elt.tagName() == tagName)
2643 return QDomElement();
2647
2648
2649
2650
2651
2652
2653
2654
2655int QDomNode::lineNumber()
const
2657 return impl ? impl->lineNumber : -1;
2661
2662
2663
2664
2665
2666
2667
2668
2669int QDomNode::columnNumber()
const
2671 return impl ? impl->columnNumber : -1;
2676
2677
2678
2679
2681QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate(QDomNodePrivate *pimpl)
2685 , appendToParent(
false)
2689QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate()
2694QDomNamedNodeMapPrivate* QDomNamedNodeMapPrivate::clone(QDomNodePrivate *pimpl)
2696 std::unique_ptr<QDomNamedNodeMapPrivate> m(
new QDomNamedNodeMapPrivate(pimpl));
2697 m->readonly = readonly;
2698 m->appendToParent = appendToParent;
2700 auto it = map.constBegin();
2701 for (; it != map.constEnd(); ++it) {
2702 QDomNodePrivate *new_node = it.value()->cloneNode();
2703 new_node->setParent(pimpl);
2704 m->setNamedItem(new_node);
2712void QDomNamedNodeMapPrivate::clearMap()
2715 if (!appendToParent) {
2716 auto it = map.constBegin();
2717 for (; it != map.constEnd(); ++it)
2718 if (!it.value()->ref.deref())
2724QDomNodePrivate* QDomNamedNodeMapPrivate::namedItem(
const QString& name)
const
2726 auto it = map.find(name);
2727 return it == map.end() ?
nullptr : it.value();
2730QDomNodePrivate* QDomNamedNodeMapPrivate::namedItemNS(
const QString& nsURI,
const QString& localName)
const
2732 auto it = map.constBegin();
2734 for (; it != map.constEnd(); ++it) {
2736 if (!n->prefix.isNull()) {
2738 if (n->namespaceURI == nsURI && n->name == localName)
2745QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItem(QDomNodePrivate* arg)
2747 if (readonly || !arg)
2751 return parent->appendChild(arg);
2753 QDomNodePrivate *n = map.value(arg->nodeName());
2756 map.insert(arg->nodeName(), arg);
2760QDomNodePrivate* QDomNamedNodeMapPrivate::setNamedItemNS(QDomNodePrivate* arg)
2762 if (readonly || !arg)
2766 return parent->appendChild(arg);
2768 if (!arg->prefix.isNull()) {
2770 QDomNodePrivate *n = namedItemNS(arg->namespaceURI, arg->name);
2773 map.insert(arg->nodeName(), arg);
2777 return setNamedItem(arg);
2781QDomNodePrivate* QDomNamedNodeMapPrivate::removeNamedItem(
const QString& name)
2786 QDomNodePrivate* p = namedItem(name);
2790 return parent->removeChild(p);
2792 map.remove(p->nodeName());
2798QDomNodePrivate* QDomNamedNodeMapPrivate::item(
int index)
const
2800 if (index >= length() || index < 0)
2802 return std::next(map.begin(), index).value();
2805int QDomNamedNodeMapPrivate::length()
const
2810bool QDomNamedNodeMapPrivate::contains(
const QString& name)
const
2812 return map.contains(name);
2815bool QDomNamedNodeMapPrivate::containsNS(
const QString& nsURI,
const QString & localName)
const
2817 return namedItemNS(nsURI, localName) !=
nullptr;
2821
2822
2823
2824
2826#define IMPL static_cast<QDomNamedNodeMapPrivate *>(impl)
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
2861
2862
2863
2864
2867
2868
2869QDomNamedNodeMap::QDomNamedNodeMap()
2875
2876
2877QDomNamedNodeMap::QDomNamedNodeMap(
const QDomNamedNodeMap &namedNodeMap)
2878 : impl(namedNodeMap.impl)
2884QDomNamedNodeMap::QDomNamedNodeMap(QDomNamedNodeMapPrivate *pimpl)
2892
2893
2894QDomNamedNodeMap& QDomNamedNodeMap::operator=(
const QDomNamedNodeMap &other)
2897 other.impl->ref.ref();
2898 if (impl && !impl->ref.deref())
2905
2906
2907
2908bool QDomNamedNodeMap::operator==(
const QDomNamedNodeMap &other)
const
2910 return impl == other.impl;
2914
2915
2916
2917bool QDomNamedNodeMap::operator!=(
const QDomNamedNodeMap &other)
const
2919 return !operator==(other);
2923
2924
2925QDomNamedNodeMap::~QDomNamedNodeMap()
2927 if (impl && !impl->ref.deref())
2932
2933
2934
2935
2936
2937
2938
2939
2940QDomNode QDomNamedNodeMap::namedItem(
const QString& name)
const
2944 return QDomNode(IMPL->namedItem(name));
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957QDomNode QDomNamedNodeMap::setNamedItem(
const QDomNode& newNode)
2961 return QDomNode(IMPL->setNamedItem(
static_cast<QDomNodePrivate *>(newNode.impl)));
2965
2966
2967
2968
2969
2970
2971
2972
2973QDomNode QDomNamedNodeMap::removeNamedItem(
const QString& name)
2977 return QDomNode(IMPL->removeNamedItem(name));
2981
2982
2983
2984
2985
2986
2987
2988QDomNode QDomNamedNodeMap::item(
int index)
const
2992 return QDomNode(IMPL->item(index));
2996
2997
2998
2999
3000
3001
3002
3003
3004QDomNode QDomNamedNodeMap::namedItemNS(
const QString& nsURI,
const QString& localName)
const
3008 return QDomNode(IMPL->namedItemNS(nsURI, localName));
3012
3013
3014
3015
3016
3017
3018
3019QDomNode QDomNamedNodeMap::setNamedItemNS(
const QDomNode& newNode)
3023 return QDomNode(IMPL->setNamedItemNS(
static_cast<QDomNodePrivate *>(newNode.impl)));
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037QDomNode QDomNamedNodeMap::removeNamedItemNS(
const QString& nsURI,
const QString& localName)
3041 QDomNodePrivate *n = IMPL->namedItemNS(nsURI, localName);
3044 return QDomNode(IMPL->removeNamedItem(n->name));
3048
3049
3050
3051
3052int QDomNamedNodeMap::length()
const
3056 return IMPL->length();
3060
3061
3062
3063
3064
3067
3068
3069
3070
3073
3074
3075
3076
3079
3080
3081
3082
3083
3084
3085
3086bool QDomNamedNodeMap::contains(
const QString& name)
const
3090 return IMPL->contains(name);
3096
3097
3098
3099
3101QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent)
3102 : QDomNodePrivate(doc, parent)
3107QDomDocumentTypePrivate::QDomDocumentTypePrivate(QDomDocumentTypePrivate* n,
bool deep)
3108 : QDomNodePrivate(n, deep)
3112 QDomNodePrivate* p = first;
3116 entities->map.insert(p->nodeName(), p);
3117 if (p->isNotation())
3119 notations->map.insert(p->nodeName(), p);
3124QDomDocumentTypePrivate::~QDomDocumentTypePrivate()
3126 if (!entities->ref.deref())
3128 if (!notations->ref.deref())
3132void QDomDocumentTypePrivate::init()
3134 entities =
new QDomNamedNodeMapPrivate(
this);
3136 notations =
new QDomNamedNodeMapPrivate(
this);
3139 internalSubset.clear();
3141 entities->setAppendToParent(
true);
3142 notations->setAppendToParent(
true);
3149QDomNodePrivate* QDomDocumentTypePrivate::cloneNode(
bool deep)
3151 QDomNodePrivate* p =
new QDomDocumentTypePrivate(
this, deep);
3157QDomNodePrivate* QDomDocumentTypePrivate::insertBefore(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
3160 QDomNodePrivate* p = QDomNodePrivate::insertBefore(newChild, refChild);
3162 if (p && p->isEntity())
3163 entities->map.insert(p->nodeName(), p);
3164 else if (p && p->isNotation())
3165 notations->map.insert(p->nodeName(), p);
3170QDomNodePrivate* QDomDocumentTypePrivate::insertAfter(QDomNodePrivate* newChild, QDomNodePrivate* refChild)
3173 QDomNodePrivate* p = QDomNodePrivate::insertAfter(newChild, refChild);
3175 if (p && p->isEntity())
3176 entities->map.insert(p->nodeName(), p);
3177 else if (p && p->isNotation())
3178 notations->map.insert(p->nodeName(), p);
3183QDomNodePrivate* QDomDocumentTypePrivate::replaceChild(QDomNodePrivate* newChild, QDomNodePrivate* oldChild)
3186 QDomNodePrivate* p = QDomNodePrivate::replaceChild(newChild, oldChild);
3189 if (oldChild && oldChild->isEntity())
3190 entities->map.remove(oldChild->nodeName());
3191 else if (oldChild && oldChild->isNotation())
3192 notations->map.remove(oldChild->nodeName());
3195 entities->map.insert(p->nodeName(), p);
3196 else if (p->isNotation())
3197 notations->map.insert(p->nodeName(), p);
3203QDomNodePrivate* QDomDocumentTypePrivate::removeChild(QDomNodePrivate* oldChild)
3206 QDomNodePrivate* p = QDomNodePrivate::removeChild( oldChild);
3208 if (p && p->isEntity())
3209 entities->map.remove(p->nodeName());
3210 else if (p && p->isNotation())
3211 notations->map.remove(p ->nodeName());
3216QDomNodePrivate* QDomDocumentTypePrivate::appendChild(QDomNodePrivate* newChild)
3218 return insertAfter(newChild,
nullptr);
3221static QString quotedValue(
const QString &data)
3223 QChar quote = data.indexOf(u'\'') == -1 ? u'\'' : u'"';
3224 return quote + data + quote;
3227void QDomDocumentTypePrivate::save(QTextStream& s,
int,
int indent)
const
3232 s <<
"<!DOCTYPE " << name;
3234 if (!publicId.isNull()) {
3235 s <<
" PUBLIC " << quotedValue(publicId);
3236 if (!systemId.isNull()) {
3237 s <<
' ' << quotedValue(systemId);
3239 }
else if (!systemId.isNull()) {
3240 s <<
" SYSTEM " << quotedValue(systemId);
3243 if (entities->length()>0 || notations->length()>0) {
3244 s <<
" [" << Qt::endl;
3246 auto it2 = notations->map.constBegin();
3247 for (; it2 != notations->map.constEnd(); ++it2)
3248 it2.value()->saveSubTree(it2.value(), s, 0, indent);
3250 auto it = entities->map.constBegin();
3251 for (; it != entities->map.constEnd(); ++it)
3252 it.value()->saveSubTree(it.value(), s, 0, indent);
3257 s <<
'>' << Qt::endl;
3261
3262
3263
3264
3266#define IMPL static_cast<QDomDocumentTypePrivate *>(impl)
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3288
3289
3290QDomDocumentType::QDomDocumentType() : QDomNode()
3295
3296
3297
3298
3299
3300
3301QDomDocumentType::QDomDocumentType(
const QDomDocumentType &documentType)
3302 : QDomNode(documentType)
3306QDomDocumentType::QDomDocumentType(QDomDocumentTypePrivate *pimpl)
3312
3313
3314
3315
3316
3317
3318QDomDocumentType &QDomDocumentType::operator=(
const QDomDocumentType &other) =
default;
3320
3321
3322
3323
3324
3325QString QDomDocumentType::name()
const
3329 return IMPL->nodeName();
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342QDomNamedNodeMap QDomDocumentType::entities()
const
3345 return QDomNamedNodeMap();
3346 return QDomNamedNodeMap(IMPL->entities);
3350
3351
3352QDomNamedNodeMap QDomDocumentType::notations()
const
3355 return QDomNamedNodeMap();
3356 return QDomNamedNodeMap(IMPL->notations);
3360
3361
3362
3363
3364
3365QString QDomDocumentType::publicId()
const
3369 return IMPL->publicId;
3373
3374
3375
3376
3377
3378QString QDomDocumentType::systemId()
const
3382 return IMPL->systemId;
3386
3387
3388
3389
3390
3391QString QDomDocumentType::internalSubset()
const
3395 return IMPL->internalSubset;
3399
3400
3401
3402
3405
3406
3407
3408
3409
3410
3415
3416
3417
3418
3420QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomDocumentPrivate* doc, QDomNodePrivate* parent)
3421 : QDomNodePrivate(doc, parent)
3423 name = u"#document-fragment"_s;
3426QDomDocumentFragmentPrivate::QDomDocumentFragmentPrivate(QDomNodePrivate* n,
bool deep)
3427 : QDomNodePrivate(n, deep)
3431QDomNodePrivate* QDomDocumentFragmentPrivate::cloneNode(
bool deep)
3433 QDomNodePrivate* p =
new QDomDocumentFragmentPrivate(
this, deep);
3440
3441
3442
3443
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3471
3472
3473QDomDocumentFragment::QDomDocumentFragment()
3477QDomDocumentFragment::QDomDocumentFragment(QDomDocumentFragmentPrivate* n)
3483
3484
3485
3486
3487
3488
3489QDomDocumentFragment::QDomDocumentFragment(
const QDomDocumentFragment &documentFragment)
3490 : QDomNode(documentFragment)
3495
3496
3497
3498
3499
3500
3501QDomDocumentFragment &QDomDocumentFragment::operator=(
const QDomDocumentFragment &other) =
default;
3504
3505
3506
3507
3508
3509
3512
3513
3514
3515
3517QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
3518 const QString& data)
3519 : QDomNodePrivate(d, p)
3522 name = u"#character-data"_s;
3525QDomCharacterDataPrivate::QDomCharacterDataPrivate(QDomCharacterDataPrivate* n,
bool deep)
3526 : QDomNodePrivate(n, deep)
3530QDomNodePrivate* QDomCharacterDataPrivate::cloneNode(
bool deep)
3532 QDomNodePrivate* p =
new QDomCharacterDataPrivate(
this, deep);
3538int QDomCharacterDataPrivate::dataLength()
const
3540 return value.size();
3543QString QDomCharacterDataPrivate::substringData(
unsigned long offset,
unsigned long n)
const
3545 return value.mid(offset, n);
3548void QDomCharacterDataPrivate::insertData(
unsigned long offset,
const QString& arg)
3550 value.insert(offset, arg);
3553void QDomCharacterDataPrivate::deleteData(
unsigned long offset,
unsigned long n)
3555 value.remove(offset, n);
3558void QDomCharacterDataPrivate::replaceData(
unsigned long offset,
unsigned long n,
const QString& arg)
3560 value.replace(offset, n, arg);
3563void QDomCharacterDataPrivate::appendData(
const QString& arg)
3569
3570
3571
3572
3574#define IMPL static_cast<QDomCharacterDataPrivate *>(impl)
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3602
3603
3604QDomCharacterData::QDomCharacterData()
3609
3610
3611
3612
3613
3614
3615QDomCharacterData::QDomCharacterData(
const QDomCharacterData &characterData)
3616 : QDomNode(characterData)
3620QDomCharacterData::QDomCharacterData(QDomCharacterDataPrivate* n)
3626
3627
3628
3629
3630
3631
3632QDomCharacterData &QDomCharacterData::operator=(
const QDomCharacterData &other) =
default;
3635
3636
3637
3638
3639
3640QString QDomCharacterData::data()
const
3644 return impl->nodeValue();
3648
3649
3650void QDomCharacterData::setData(
const QString &data)
3653 impl->setNodeValue(data);
3657
3658
3659int QDomCharacterData::length()
const
3662 return IMPL->dataLength();
3667
3668
3669QString QDomCharacterData::substringData(
unsigned long offset,
unsigned long count)
3673 return IMPL->substringData(offset, count);
3677
3678
3679void QDomCharacterData::appendData(
const QString& arg)
3682 IMPL->appendData(arg);
3686
3687
3688void QDomCharacterData::insertData(
unsigned long offset,
const QString& arg)
3691 IMPL->insertData(offset, arg);
3695
3696
3697void QDomCharacterData::deleteData(
unsigned long offset,
unsigned long count)
3700 IMPL->deleteData(offset, count);
3704
3705
3706
3707void QDomCharacterData::replaceData(
unsigned long offset,
unsigned long count,
const QString& arg)
3710 IMPL->replaceData(offset, count, arg);
3714
3715
3716
3717
3718QDomNode::NodeType QDomCharacterData::nodeType()
const
3721 return CharacterDataNode;
3722 return QDomNode::nodeType();
3728
3729
3730
3731
3733QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& name_)
3734 : QDomNodePrivate(d, parent)
3737 m_specified =
false;
3740QDomAttrPrivate::QDomAttrPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
const QString& nsURI,
const QString& qName)
3741 : QDomNodePrivate(d, p)
3743 qt_split_namespace(prefix, name, qName, !nsURI.isNull());
3744 namespaceURI = nsURI;
3745 createdWithDom1Interface =
false;
3746 m_specified =
false;
3749QDomAttrPrivate::QDomAttrPrivate(QDomAttrPrivate* n,
bool deep)
3750 : QDomNodePrivate(n, deep)
3752 m_specified = n->specified();
3755void QDomAttrPrivate::setNodeValue(
const QString& v)
3758 QDomTextPrivate *t =
new QDomTextPrivate(
nullptr,
this, v);
3762 auto removed = removeChild(first);
3763 if (removed && !removed->ref.loadRelaxed())
3769QDomNodePrivate* QDomAttrPrivate::cloneNode(
bool deep)
3771 QDomNodePrivate* p =
new QDomAttrPrivate(
this, deep);
3777bool QDomAttrPrivate::specified()
const
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792static QString encodeText(
const QString &str,
3793 const bool encodeQuotes =
true,
3794 const bool performAVN =
false,
3795 const bool encodeEOLs =
false)
3798 qsizetype start = 0;
3799 auto appendToOutput = [&](qsizetype cur,
const auto &replacement)
3802 retval.reserve(str.size() + replacement.size());
3803 retval.append(QStringView(str).first(cur).sliced(start));
3807 retval.append(replacement);
3810 const qsizetype len = str.size();
3811 for (qsizetype cur = 0; cur < len; ++cur) {
3812 switch (str[cur].unicode()) {
3814 appendToOutput(cur,
"<"_L1);
3818 appendToOutput(cur,
"""_L1);
3821 appendToOutput(cur,
"&"_L1);
3824 if (cur >= 2 && str[cur - 1] == u']' && str[cur - 2] == u']')
3825 appendToOutput(cur,
">"_L1);
3828 if (performAVN || encodeEOLs)
3829 appendToOutput(cur,
"
"_L1);
3833 appendToOutput(cur,
"
"_L1);
3837 appendToOutput(cur,
"	"_L1);
3844 retval.append(QStringView(str).first(len).sliced(start));
3850void QDomAttrPrivate::save(QTextStream& s,
int,
int)
const
3852 if (namespaceURI.isNull()) {
3853 s << name <<
"=\"" << encodeText(value,
true,
true) <<
'\"';
3855 s << prefix <<
':' << name <<
"=\"" << encodeText(value,
true,
true) <<
'\"';
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3868 ownerNode->prefix != prefix) {
3869 s <<
" xmlns:" << prefix <<
"=\"" << encodeText(namespaceURI,
true,
true) <<
'\"';
3875
3876
3877
3878
3880#define IMPL static_cast<QDomAttrPrivate *>(impl)
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3918
3919
3925
3926
3927
3928
3929
3930
3931QDomAttr::QDomAttr(
const QDomAttr &attr)
3936QDomAttr::QDomAttr(QDomAttrPrivate* n)
3942
3943
3944
3945
3946
3947
3948QDomAttr &QDomAttr::operator=(
const QDomAttr &other) =
default;
3951
3952
3953QString QDomAttr::name()
const
3957 return impl->nodeName();
3961
3962
3963
3964
3965
3966bool QDomAttr::specified()
const
3970 return IMPL->specified();
3974
3975
3976
3977
3978QDomElement QDomAttr::ownerElement()
const
3980 Q_ASSERT(impl->parent());
3981 if (!impl->parent()->isElement())
3982 return QDomElement();
3983 return QDomElement(
static_cast<QDomElementPrivate *>(impl->parent()));
3987
3988
3989
3990
3991
3992QString QDomAttr::value()
const
3996 return impl->nodeValue();
4000
4001
4002
4003
4004void QDomAttr::setValue(
const QString &value)
4008 impl->setNodeValue(value);
4009 IMPL->m_specified =
true;
4013
4014
4015
4016
4021
4022
4023
4024
4026QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
4027 const QString& tagname)
4028 : QDomNodePrivate(d, p)
4031 m_attr =
new QDomNamedNodeMapPrivate(
this);
4034QDomElementPrivate::QDomElementPrivate(QDomDocumentPrivate* d, QDomNodePrivate* p,
4035 const QString& nsURI,
const QString& qName)
4036 : QDomNodePrivate(d, p)
4038 qt_split_namespace(prefix, name, qName, !nsURI.isNull());
4039 namespaceURI = nsURI;
4040 createdWithDom1Interface =
false;
4041 m_attr =
new QDomNamedNodeMapPrivate(
this);
4044QDomElementPrivate::QDomElementPrivate(QDomElementPrivate* n,
bool deep) :
4045 QDomNodePrivate(n, deep)
4047 m_attr = n->m_attr->clone(
this);
4052QDomElementPrivate::~QDomElementPrivate()
4054 if (!m_attr->ref.deref())
4058QDomNodePrivate* QDomElementPrivate::cloneNode(
bool deep)
4060 QDomNodePrivate* p =
new QDomElementPrivate(
this, deep);
4066QString QDomElementPrivate::attribute(
const QString& name_,
const QString& defValue)
const
4068 QDomNodePrivate* n = m_attr->namedItem(name_);
4072 return n->nodeValue();
4075QString QDomElementPrivate::attributeNS(
const QString& nsURI,
const QString& localName,
const QString& defValue)
const
4077 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4081 return n->nodeValue();
4084void QDomElementPrivate::setAttribute(
const QString& aname,
const QString& newValue)
4086 QDomNodePrivate* n = m_attr->namedItem(aname);
4088 n =
new QDomAttrPrivate(ownerDocument(),
this, aname);
4089 n->setNodeValue(newValue);
4094 m_attr->setNamedItem(n);
4096 n->setNodeValue(newValue);
4100void QDomElementPrivate::setAttributeNS(
const QString& nsURI,
const QString& qName,
const QString& newValue)
4102 QString prefix, localName;
4103 qt_split_namespace(prefix, localName, qName,
true);
4104 QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4106 n =
new QDomAttrPrivate(ownerDocument(),
this, nsURI, qName);
4107 n->setNodeValue(newValue);
4112 m_attr->setNamedItem(n);
4114 n->setNodeValue(newValue);
4115 n->prefix = std::move(prefix);
4119void QDomElementPrivate::removeAttribute(
const QString& aname)
4121 QDomNodePrivate* p = m_attr->removeNamedItem(aname);
4122 if (p && p->ref.loadRelaxed() == 0)
4126QDomAttrPrivate* QDomElementPrivate::attributeNode(
const QString& aname)
4128 return static_cast<QDomAttrPrivate *>(m_attr->namedItem(aname));
4131QDomAttrPrivate* QDomElementPrivate::attributeNodeNS(
const QString& nsURI,
const QString& localName)
4133 return static_cast<QDomAttrPrivate *>(m_attr->namedItemNS(nsURI, localName));
4136QDomAttrPrivate* QDomElementPrivate::setAttributeNode(QDomAttrPrivate* newAttr)
4141 QDomNodePrivate* foundAttr = m_attr->namedItem(newAttr->nodeName());
4143 m_attr->removeNamedItem(newAttr->nodeName());
4146 m_attr->setNamedItem(newAttr);
4147 newAttr->setParent(
this);
4149 return static_cast<QDomAttrPrivate *>(foundAttr);
4152QDomAttrPrivate* QDomElementPrivate::setAttributeNodeNS(QDomAttrPrivate* newAttr)
4154 QDomNodePrivate* n =
nullptr;
4155 if (!newAttr->prefix.isNull())
4156 n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name);
4159 m_attr->setNamedItem(newAttr);
4161 return static_cast<QDomAttrPrivate *>(n);
4164QDomAttrPrivate* QDomElementPrivate::removeAttributeNode(QDomAttrPrivate* oldAttr)
4166 return static_cast<QDomAttrPrivate *>(m_attr->removeNamedItem(oldAttr->nodeName()));
4169bool QDomElementPrivate::hasAttribute(
const QString& aname)
const
4171 return m_attr->contains(aname);
4174bool QDomElementPrivate::hasAttributeNS(
const QString& nsURI,
const QString& localName)
const
4176 return m_attr->containsNS(nsURI, localName);
4179QString QDomElementPrivate::text()
const
4184 if (QDomNodePrivate* p = first) {
4186 if (p->isText() || p->isCDATASection()) {
4187 t += p->nodeValue();
4188 }
else if (p->isElement() && p->first) {
4205void QDomElementPrivate::save(QTextStream& s,
int depth,
int indent)
const
4207 if (!(prev && prev->isText()))
4208 s << QString(indent < 1 ? 0 : depth * indent, u' ');
4210 QString qName(name);
4211 QString nsDecl(u""_s);
4212 if (!namespaceURI.isNull()) {
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223 if (prefix.isEmpty()) {
4224 nsDecl = u" xmlns"_s;
4226 qName = prefix + u':' + name;
4227 nsDecl = u" xmlns:"_s + prefix;
4229 nsDecl += u"=\""_s + encodeText(namespaceURI) + u'\"';
4231 s <<
'<' << qName << nsDecl;
4235 if (!m_attr->map.isEmpty()) {
4237
4238
4239
4240
4241
4242
4243
4244 struct SavedAttribute {
4247 QString encodedValue;
4251 QVarLengthArray<SavedAttribute, 8> attributesToSave;
4252 attributesToSave.reserve(m_attr->map.size());
4254 QDuplicateTracker<QString> outputtedPrefixes;
4255 for (
const auto &[key, value] : std::as_const(m_attr->map).asKeyValueRange()) {
4257 bool mayNeedXmlNS =
false;
4259 SavedAttribute attr;
4260 attr.name = value->name;
4261 attr.encodedValue = encodeText(value->value,
true,
true);
4262 if (!value->namespaceURI.isNull()) {
4263 attr.prefix = value->prefix;
4264 mayNeedXmlNS =
true;
4267 attributesToSave.push_back(std::move(attr));
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4286 && ((!value->ownerNode || value->ownerNode->prefix != value->prefix)
4287 && !outputtedPrefixes.hasSeen(value->prefix)))
4289 SavedAttribute nsAttr;
4290 nsAttr.prefix = QStringLiteral(
"xmlns");
4291 nsAttr.name = value->prefix;
4292 nsAttr.encodedValue = encodeText(value->namespaceURI,
true,
true);
4293 attributesToSave.push_back(std::move(nsAttr));
4298 const auto savedAttributeComparator = [](
const SavedAttribute &lhs,
const SavedAttribute &rhs)
4300 const int cmp = QString::compare(lhs.prefix, rhs.prefix);
4301 return (cmp < 0) || ((cmp == 0) && (lhs.name < rhs.name));
4304 std::sort(attributesToSave.begin(), attributesToSave.end(), savedAttributeComparator);
4307 for (
const auto &attr : attributesToSave) {
4309 if (!attr.prefix.isEmpty())
4310 s << attr.prefix <<
':';
4311 s << attr.name <<
"=\"" << attr.encodedValue <<
'\"';
4317 if (first->isText())
4331void QDomElementPrivate::afterSave(QTextStream &s,
int depth,
int indent)
const
4334 QString qName(name);
4336 if (!prefix.isEmpty())
4337 qName = prefix + u':' + name;
4339 if (!last->isText())
4340 s << QString(indent < 1 ? 0 : depth * indent, u' ');
4342 s <<
"</" << qName <<
'>';
4345 if (!(next && next->isText())) {
4353
4354
4355
4356
4358#define IMPL static_cast<QDomElementPrivate *>(impl)
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
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4413
4414
4415
4416QDomElement::QDomElement()
4422
4423
4424
4425
4426
4427
4428QDomElement::QDomElement(
const QDomElement &element)
4433QDomElement::QDomElement(QDomElementPrivate* n)
4439
4440
4441
4442
4443
4444
4445QDomElement &QDomElement::operator=(
const QDomElement &other) =
default;
4448
4449
4450
4451
4454
4455
4456
4457
4458void QDomElement::setTagName(
const QString& name)
4465
4466
4467
4468
4469
4470
4471
4472
4473QString QDomElement::tagName()
const
4477 return impl->nodeName();
4482
4483
4484
4485
4486QDomNamedNodeMap QDomElement::attributes()
const
4489 return QDomNamedNodeMap();
4490 return QDomNamedNodeMap(IMPL->attributes());
4494
4495
4496
4497
4498
4499QString QDomElement::attribute(
const QString& name,
const QString& defValue)
const
4503 return IMPL->attribute(name, defValue);
4507
4508
4509
4510
4511
4512
4513void QDomElement::setAttribute(
const QString& name,
const QString& value)
4517 IMPL->setAttribute(name, value);
4521
4522
4523
4524
4525
4528
4529
4530
4531
4532
4535
4536
4537
4538
4539void QDomElement::setAttribute(
const QString& name, qlonglong value)
4545 IMPL->setAttribute(name, x);
4549
4550
4551
4552
4553void QDomElement::setAttribute(
const QString& name, qulonglong value)
4559 IMPL->setAttribute(name, x);
4563
4564
4565
4566
4567void QDomElement::setAttribute(
const QString& name,
float value)
4572 x.setNum(value,
'g', 8);
4573 IMPL->setAttribute(name, x);
4577
4578
4579
4580
4581void QDomElement::setAttribute(
const QString& name,
double value)
4586 x.setNum(value,
'g', 17);
4587 IMPL->setAttribute(name, x);
4591
4592
4593
4594
4595void QDomElement::removeAttribute(
const QString& name)
4599 IMPL->removeAttribute(name);
4603
4604
4605
4606
4607
4608
4609QDomAttr QDomElement::attributeNode(
const QString& name)
4613 return QDomAttr(IMPL->attributeNode(name));
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626QDomAttr QDomElement::setAttributeNode(
const QDomAttr& newAttr)
4630 return QDomAttr(IMPL->setAttributeNode(
static_cast<QDomAttrPrivate *>(newAttr.impl)));
4634
4635
4636
4637
4638QDomAttr QDomElement::removeAttributeNode(
const QDomAttr& oldAttr)
4642 return QDomAttr(IMPL->removeAttributeNode(
static_cast<QDomAttrPrivate *>(oldAttr.impl)));
4646
4647
4648
4649
4650
4651
4652
4653
4654QDomNodeList QDomElement::elementsByTagName(
const QString& tagname)
const
4656 return QDomNodeList(
new QDomNodeListPrivate(impl, tagname));
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671bool QDomElement::hasAttribute(
const QString& name)
const
4675 return IMPL->hasAttribute(name);
4679
4680
4681
4682
4683
4684
4685QString QDomElement::attributeNS(
const QString& nsURI,
const QString& localName,
const QString& defValue)
const
4689 return IMPL->attributeNS(nsURI, localName, defValue);
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName,
const QString& value)
4708 IMPL->setAttributeNS(nsURI, qName, value);
4712
4713
4714
4715
4718
4719
4720
4721
4724
4725
4726void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName, qlonglong value)
4732 IMPL->setAttributeNS(nsURI, qName, x);
4736
4737
4738void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName, qulonglong value)
4744 IMPL->setAttributeNS(nsURI, qName, x);
4748
4749
4750void QDomElement::setAttributeNS(
const QString& nsURI,
const QString& qName,
double value)
4755 x.setNum(value,
'g', 17);
4756 IMPL->setAttributeNS(nsURI, qName, x);
4760
4761
4762
4763
4764
4765void QDomElement::removeAttributeNS(
const QString& nsURI,
const QString& localName)
4769 QDomNodePrivate *n = IMPL->attributeNodeNS(nsURI, localName);
4772 IMPL->removeAttribute(n->nodeName());
4776
4777
4778
4779
4780
4781
4782
4783QDomAttr QDomElement::attributeNodeNS(
const QString& nsURI,
const QString& localName)
4787 return QDomAttr(IMPL->attributeNodeNS(nsURI, localName));
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800QDomAttr QDomElement::setAttributeNodeNS(
const QDomAttr& newAttr)
4804 return QDomAttr(IMPL->setAttributeNodeNS(
static_cast<QDomAttrPrivate *>(newAttr.impl)));
4808
4809
4810
4811
4812
4813
4814
4815
4816QDomNodeList QDomElement::elementsByTagNameNS(
const QString& nsURI,
const QString& localName)
const
4818 return QDomNodeList(
new QDomNodeListPrivate(impl, nsURI, localName));
4822
4823
4824
4825
4826bool QDomElement::hasAttributeNS(
const QString& nsURI,
const QString& localName)
const
4830 return IMPL->hasAttributeNS(nsURI, localName);
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847QString QDomElement::text()
const
4851 return IMPL->text();
4857
4858
4859
4860
4862QDomTextPrivate::QDomTextPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& val)
4863 : QDomCharacterDataPrivate(d, parent, val)
4868QDomTextPrivate::QDomTextPrivate(QDomTextPrivate* n,
bool deep)
4869 : QDomCharacterDataPrivate(n, deep)
4873QDomNodePrivate* QDomTextPrivate::cloneNode(
bool deep)
4875 QDomNodePrivate* p =
new QDomTextPrivate(
this, deep);
4881QDomTextPrivate* QDomTextPrivate::splitText(
int offset)
4884 qWarning(
"QDomText::splitText The node has no parent. So I cannot split");
4888 QDomTextPrivate* t =
new QDomTextPrivate(ownerDocument(),
nullptr, value.mid(offset));
4889 value.truncate(offset);
4891 parent()->insertAfter(t,
this);
4892 Q_ASSERT(t->ref.loadRelaxed() == 2);
4900void QDomTextPrivate::save(QTextStream& s,
int,
int)
const
4902 QDomTextPrivate *that =
const_cast<QDomTextPrivate*>(
this);
4903 s << encodeText(value, !(that->parent() && that->parent()->isElement()),
false,
true);
4907
4908
4909
4910
4912#define IMPL static_cast<QDomTextPrivate *>(impl)
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4933
4934
4935
4936
4938 : QDomCharacterData()
4943
4944
4945
4946
4947
4948
4949QDomText::QDomText(
const QDomText &text)
4950 : QDomCharacterData(text)
4954QDomText::QDomText(QDomTextPrivate* n)
4955 : QDomCharacterData(n)
4960
4961
4962
4963
4964
4965
4966QDomText &QDomText::operator=(
const QDomText &other) =
default;
4969
4970
4971
4972
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984QDomText QDomText::splitText(
int offset)
4988 return QDomText(IMPL->splitText(offset));
4994
4995
4996
4997
4999QDomCommentPrivate::QDomCommentPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& val)
5000 : QDomCharacterDataPrivate(d, parent, val)
5002 name = u"#comment"_s;
5005QDomCommentPrivate::QDomCommentPrivate(QDomCommentPrivate* n,
bool deep)
5006 : QDomCharacterDataPrivate(n, deep)
5011QDomNodePrivate* QDomCommentPrivate::cloneNode(
bool deep)
5013 QDomNodePrivate* p =
new QDomCommentPrivate(
this, deep);
5019void QDomCommentPrivate::save(QTextStream& s,
int depth,
int indent)
const
5022 if (!(prev && prev->isText()))
5023 s << QString(indent < 1 ? 0 : depth * indent, u' ');
5025 s <<
"<!--" << value;
5026 if (value.endsWith(u'-'))
5030 if (!(next && next->isText()))
5035
5036
5037
5038
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5062
5063
5064
5065QDomComment::QDomComment()
5066 : QDomCharacterData()
5071
5072
5073
5074
5075
5076
5077QDomComment::QDomComment(
const QDomComment &comment)
5078 : QDomCharacterData(comment)
5082QDomComment::QDomComment(QDomCommentPrivate* n)
5083 : QDomCharacterData(n)
5088
5089
5090
5091
5092
5093
5094QDomComment &QDomComment::operator=(
const QDomComment &other) =
default;
5097
5098
5099
5100
5103
5104
5105
5106
5108QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5110 : QDomTextPrivate(d, parent, val)
5112 name = u"#cdata-section"_s;
5115QDomCDATASectionPrivate::QDomCDATASectionPrivate(QDomCDATASectionPrivate* n,
bool deep)
5116 : QDomTextPrivate(n, deep)
5120QDomNodePrivate* QDomCDATASectionPrivate::cloneNode(
bool deep)
5122 QDomNodePrivate* p =
new QDomCDATASectionPrivate(
this, deep);
5128void QDomCDATASectionPrivate::save(QTextStream& s,
int,
int)
const
5132 s <<
"<![CDATA[" << value <<
"]]>";
5136
5137
5138
5139
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5167
5168
5169
5170QDomCDATASection::QDomCDATASection()
5176
5177
5178
5179
5180
5181
5182QDomCDATASection::QDomCDATASection(
const QDomCDATASection &cdataSection)
5183 : QDomText(cdataSection)
5187QDomCDATASection::QDomCDATASection(QDomCDATASectionPrivate* n)
5193
5194
5195
5196
5197
5198
5199QDomCDATASection &QDomCDATASection::operator=(
const QDomCDATASection &other) =
default;
5202
5203
5204
5205
5208
5209
5210
5211
5213QDomNotationPrivate::QDomNotationPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5214 const QString& aname,
5215 const QString& pub,
const QString& sys)
5216 : QDomNodePrivate(d, parent)
5223QDomNotationPrivate::QDomNotationPrivate(QDomNotationPrivate* n,
bool deep)
5224 : QDomNodePrivate(n, deep)
5230QDomNodePrivate* QDomNotationPrivate::cloneNode(
bool deep)
5232 QDomNodePrivate* p =
new QDomNotationPrivate(
this, deep);
5238void QDomNotationPrivate::save(QTextStream& s,
int,
int)
const
5240 s <<
"<!NOTATION " << name <<
' ';
5241 if (!m_pub.isNull()) {
5242 s <<
"PUBLIC " << quotedValue(m_pub);
5243 if (!m_sys.isNull())
5244 s <<
' ' << quotedValue(m_sys);
5246 s <<
"SYSTEM " << quotedValue(m_sys);
5248 s <<
'>' << Qt::endl;
5252
5253
5254
5255
5257#define IMPL static_cast<QDomNotationPrivate *>(impl)
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5289
5290
5291QDomNotation::QDomNotation()
5297
5298
5299
5300
5301
5302
5303QDomNotation::QDomNotation(
const QDomNotation ¬ation)
5304 : QDomNode(notation)
5308QDomNotation::QDomNotation(QDomNotationPrivate* n)
5314
5315
5316
5317
5318
5319
5320QDomNotation &QDomNotation::operator=(
const QDomNotation &other) =
default;
5323
5324
5325
5326
5329
5330
5331QString QDomNotation::publicId()
const
5339
5340
5341QString QDomNotation::systemId()
const
5351
5352
5353
5354
5356QDomEntityPrivate::QDomEntityPrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
5357 const QString& aname,
5358 const QString& pub,
const QString& sys,
const QString& notation)
5359 : QDomNodePrivate(d, parent)
5364 m_notationName = notation;
5367QDomEntityPrivate::QDomEntityPrivate(QDomEntityPrivate* n,
bool deep)
5368 : QDomNodePrivate(n, deep)
5372 m_notationName = n->m_notationName;
5375QDomNodePrivate* QDomEntityPrivate::cloneNode(
bool deep)
5377 QDomNodePrivate* p =
new QDomEntityPrivate(
this, deep);
5383void QDomEntityPrivate::save(QTextStream& s,
int,
int)
const
5385 QString _name = name;
5386 if (_name.startsWith(u'%'))
5387 _name = u"% "_s + _name.mid(1);
5389 if (m_sys.isNull() && m_pub.isNull()) {
5395 s <<
"<!ENTITY " << _name <<
' ';
5396 if (m_pub.isNull()) {
5397 s <<
"SYSTEM " << quotedValue(m_sys);
5399 s <<
"PUBLIC " << quotedValue(m_pub) <<
' ' << quotedValue(m_sys);
5401 if (! m_notationName.isNull()) {
5402 s <<
" NDATA " << m_notationName;
5404 s <<
'>' << Qt::endl;
5409
5410
5411
5412
5414#define IMPL static_cast<QDomEntityPrivate *>(impl)
5417
5418
5419
5420
5421
5422
5423
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
5454
5455
5456QDomEntity::QDomEntity()
5463
5464
5465
5466
5467
5468
5469QDomEntity::QDomEntity(
const QDomEntity &entity)
5474QDomEntity::QDomEntity(QDomEntityPrivate* n)
5480
5481
5482
5483
5484
5485
5486QDomEntity &QDomEntity::operator=(
const QDomEntity &other) =
default;
5489
5490
5491
5492
5495
5496
5497
5498QString QDomEntity::publicId()
const
5506
5507
5508
5509QString QDomEntity::systemId()
const
5517
5518
5519
5520
5521QString QDomEntity::notationName()
const
5525 return IMPL->m_notationName;
5531
5532
5533
5534
5536QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomDocumentPrivate* d, QDomNodePrivate* parent,
const QString& aname)
5537 : QDomNodePrivate(d, parent)
5542QDomEntityReferencePrivate::QDomEntityReferencePrivate(QDomNodePrivate* n,
bool deep)
5543 : QDomNodePrivate(n, deep)
5547QDomNodePrivate* QDomEntityReferencePrivate::cloneNode(
bool deep)
5549 QDomNodePrivate* p =
new QDomEntityReferencePrivate(
this, deep);
5555void QDomEntityReferencePrivate::save(QTextStream& s,
int,
int)
const
5557 s <<
'&' << name <<
';';
5561
5562
5563
5564
5567
5568
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
5602
5603
5604
5605
5606QDomEntityReference::QDomEntityReference()
5612
5613
5614
5615
5616
5617
5618QDomEntityReference::QDomEntityReference(
const QDomEntityReference &entityReference)
5619 : QDomNode(entityReference)
5623QDomEntityReference::QDomEntityReference(QDomEntityReferencePrivate* n)
5629
5630
5631
5632
5633
5634
5635QDomEntityReference &QDomEntityReference::operator=(
const QDomEntityReference &other) =
default;
5638
5639
5640
5641
5644
5645
5646
5647
5649QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomDocumentPrivate* d,
5650 QDomNodePrivate* parent,
const QString& target,
const QString& data)
5651 : QDomNodePrivate(d, parent)
5657QDomProcessingInstructionPrivate::QDomProcessingInstructionPrivate(QDomProcessingInstructionPrivate* n,
bool deep)
5658 : QDomNodePrivate(n, deep)
5663QDomNodePrivate* QDomProcessingInstructionPrivate::cloneNode(
bool deep)
5665 QDomNodePrivate* p =
new QDomProcessingInstructionPrivate(
this, deep);
5671void QDomProcessingInstructionPrivate::save(QTextStream& s,
int,
int)
const
5673 s <<
"<?" << name <<
' ' << value <<
"?>" << Qt::endl;
5677
5678
5679
5680
5683
5684
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
5716
5717
5718
5719
5720
5721
5724
5725
5726
5727
5728QDomProcessingInstruction::QDomProcessingInstruction()
5734
5735
5736
5737
5738
5739
5740QDomProcessingInstruction::QDomProcessingInstruction(
const QDomProcessingInstruction &processingInstruction)
5741 : QDomNode(processingInstruction)
5745QDomProcessingInstruction::QDomProcessingInstruction(QDomProcessingInstructionPrivate* n)
5751
5752
5753
5754
5755
5756
5757QDomProcessingInstruction &
5758QDomProcessingInstruction::operator=(
const QDomProcessingInstruction &other) =
default;
5761
5762
5763
5764
5767
5768
5769
5770
5771QString QDomProcessingInstruction::target()
const
5775 return impl->nodeName();
5779
5780
5781
5782
5783QString QDomProcessingInstruction::data()
const
5787 return impl->nodeValue();
5791
5792
5793
5794
5795void QDomProcessingInstruction::setData(
const QString &data)
5798 impl->setNodeValue(data);
5802
5803
5804
5805
5807QDomDocumentPrivate::QDomDocumentPrivate()
5808 : QDomNodePrivate(
nullptr),
5809 impl(
new QDomImplementationPrivate),
5812 type =
new QDomDocumentTypePrivate(
this,
this);
5815 name = u"#document"_s;
5818QDomDocumentPrivate::QDomDocumentPrivate(
const QString& aname)
5819 : QDomNodePrivate(
nullptr),
5820 impl(
new QDomImplementationPrivate),
5823 type =
new QDomDocumentTypePrivate(
this,
this);
5827 name = u"#document"_s;
5830QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentTypePrivate* dt)
5831 : QDomNodePrivate(
nullptr),
5832 impl(
new QDomImplementationPrivate),
5835 if (dt !=
nullptr) {
5838 type =
new QDomDocumentTypePrivate(
this,
this);
5842 name = u"#document"_s;
5845QDomDocumentPrivate::QDomDocumentPrivate(QDomDocumentPrivate* n,
bool deep)
5846 : QDomNodePrivate(n, deep),
5847 impl(n->impl->clone()),
5850 type =
static_cast<QDomDocumentTypePrivate*>(n->type->cloneNode());
5851 type->setParent(
this);
5854QDomDocumentPrivate::~QDomDocumentPrivate()
5858void QDomDocumentPrivate::clear()
5862 QDomNodePrivate::clear();
5865QDomDocument::ParseResult QDomDocumentPrivate::setContent(QXmlStreamReader *reader,
5866 QDomDocument::ParseOptions options)
5869 impl =
new QDomImplementationPrivate;
5870 type =
new QDomDocumentTypePrivate(
this,
this);
5874 const auto error = u"Failed to set content, XML reader is not initialized"_s;
5875 qWarning(
"%s", qPrintable(error));
5879 QDomParser domParser(
this, reader, options);
5881 if (!domParser.parse())
5882 return domParser.result();
5886QDomNodePrivate* QDomDocumentPrivate::cloneNode(
bool deep)
5888 QDomNodePrivate *p =
new QDomDocumentPrivate(
this, deep);
5894QDomElementPrivate* QDomDocumentPrivate::documentElement()
5896 QDomNodePrivate *p = first;
5897 while (p && !p->isElement())
5900 return static_cast<QDomElementPrivate *>(p);
5903QDomElementPrivate* QDomDocumentPrivate::createElement(
const QString &tagName)
5906 QString fixedName = fixedXmlName(tagName, &ok);
5910 QDomElementPrivate *e =
new QDomElementPrivate(
this,
nullptr, fixedName);
5915QDomElementPrivate* QDomDocumentPrivate::createElementNS(
const QString &nsURI,
const QString &qName)
5918 QString fixedName = fixedXmlName(qName, &ok,
true);
5922 QDomElementPrivate *e =
new QDomElementPrivate(
this,
nullptr, nsURI, fixedName);
5927QDomDocumentFragmentPrivate* QDomDocumentPrivate::createDocumentFragment()
5929 QDomDocumentFragmentPrivate *f =
new QDomDocumentFragmentPrivate(
this,
nullptr);
5934QDomTextPrivate* QDomDocumentPrivate::createTextNode(
const QString &data)
5937 QString fixedData = fixedCharData(data, &ok);
5941 QDomTextPrivate *t =
new QDomTextPrivate(
this,
nullptr, fixedData);
5946QDomCommentPrivate* QDomDocumentPrivate::createComment(
const QString &data)
5949 QString fixedData = fixedComment(data, &ok);
5953 QDomCommentPrivate *c =
new QDomCommentPrivate(
this,
nullptr, fixedData);
5958QDomCDATASectionPrivate* QDomDocumentPrivate::createCDATASection(
const QString &data)
5961 QString fixedData = fixedCDataSection(data, &ok);
5965 QDomCDATASectionPrivate *c =
new QDomCDATASectionPrivate(
this,
nullptr, fixedData);
5970QDomProcessingInstructionPrivate* QDomDocumentPrivate::createProcessingInstruction(
const QString &target,
5971 const QString &data)
5974 QString fixedData = fixedPIData(data, &ok);
5978 QString fixedTarget = fixedXmlName(target, &ok);
5982 QDomProcessingInstructionPrivate *p =
new QDomProcessingInstructionPrivate(
this,
nullptr, fixedTarget, fixedData);
5986QDomAttrPrivate* QDomDocumentPrivate::createAttribute(
const QString &aname)
5989 QString fixedName = fixedXmlName(aname, &ok);
5993 QDomAttrPrivate *a =
new QDomAttrPrivate(
this,
nullptr, fixedName);
5998QDomAttrPrivate* QDomDocumentPrivate::createAttributeNS(
const QString &nsURI,
const QString &qName)
6001 QString fixedName = fixedXmlName(qName, &ok,
true);
6005 QDomAttrPrivate *a =
new QDomAttrPrivate(
this,
nullptr, nsURI, fixedName);
6010QDomEntityReferencePrivate* QDomDocumentPrivate::createEntityReference(
const QString &aname)
6013 QString fixedName = fixedXmlName(aname, &ok);
6017 QDomEntityReferencePrivate *e =
new QDomEntityReferencePrivate(
this,
nullptr, fixedName);
6022QDomNodePrivate* QDomDocumentPrivate::importNode(QDomNodePrivate *importedNode,
bool deep)
6024 QDomNodePrivate *node =
nullptr;
6025 switch (importedNode->nodeType()) {
6026 case QDomNode::AttributeNode:
6027 node =
new QDomAttrPrivate(
static_cast<QDomAttrPrivate *>(importedNode),
true);
6029 case QDomNode::DocumentFragmentNode:
6030 node =
new QDomDocumentFragmentPrivate(
6031 static_cast<QDomDocumentFragmentPrivate *>(importedNode), deep);
6033 case QDomNode::ElementNode:
6034 node =
new QDomElementPrivate(
static_cast<QDomElementPrivate *>(importedNode), deep);
6036 case QDomNode::EntityNode:
6037 node =
new QDomEntityPrivate(
static_cast<QDomEntityPrivate *>(importedNode), deep);
6039 case QDomNode::EntityReferenceNode:
6040 node =
new QDomEntityReferencePrivate(
6041 static_cast<QDomEntityReferencePrivate *>(importedNode),
false);
6043 case QDomNode::NotationNode:
6044 node =
new QDomNotationPrivate(
static_cast<QDomNotationPrivate *>(importedNode), deep);
6046 case QDomNode::ProcessingInstructionNode:
6047 node =
new QDomProcessingInstructionPrivate(
6048 static_cast<QDomProcessingInstructionPrivate *>(importedNode), deep);
6050 case QDomNode::TextNode:
6051 node =
new QDomTextPrivate(
static_cast<QDomTextPrivate *>(importedNode), deep);
6053 case QDomNode::CDATASectionNode:
6054 node =
new QDomCDATASectionPrivate(
static_cast<QDomCDATASectionPrivate *>(importedNode),
6057 case QDomNode::CommentNode:
6058 node =
new QDomCommentPrivate(
static_cast<QDomCommentPrivate *>(importedNode), deep);
6064 node->setOwnerDocument(
this);
6072void QDomDocumentPrivate::saveDocument(QTextStream& s,
const int indent, QDomNode::EncodingPolicy encUsed)
const
6074 const QDomNodePrivate* n = first;
6076 if (encUsed == QDomNode::EncodingFromDocument) {
6077#if QT_CONFIG(regularexpression)
6078 const QDomNodePrivate* n = first;
6080 if (n && n->isProcessingInstruction() && n->nodeName() ==
"xml"_L1) {
6082 QString data = n->nodeValue();
6083 QRegularExpression encoding(QString::fromLatin1(
"encoding\\s*=\\s*((\"([^\"]*)\")|('([^']*)'))"));
6084 auto match = encoding.match(data);
6085 QString enc = match.captured(3);
6087 enc = match.captured(5);
6088 if (!enc.isEmpty()) {
6089 auto encoding = QStringConverter::encodingForName(enc.toUtf8().constData());
6091 qWarning() <<
"QDomDocument::save(): Unsupported encoding" << enc <<
"specified.";
6093 s.setEncoding(encoding.value());
6100 if (!doc && !(n->isProcessingInstruction() && n->nodeName() ==
"xml"_L1)) {
6102 type->save(s, 0, indent);
6105 n->saveSubTree(n, s, 0, indent);
6112 const QByteArray codecName = QStringConverter::nameForEncoding(s.encoding());
6114 s <<
"<?xml version=\"1.0\" encoding=\""
6119 const QDomNodePrivate* startNode = n;
6123 if (n->isProcessingInstruction() && n->nodeName() ==
"xml"_L1) {
6124 startNode = n->next;
6133 startNode->saveSubTree(startNode, s, 0, indent);
6134 startNode = startNode->next;
6140
6141
6142
6143
6145#define IMPL static_cast<QDomDocumentPrivate *>(impl)
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
6218
6219
6220
6221
6222
6223
6226
6227
6228QDomDocument::QDomDocument()
6234
6235
6236
6237QDomDocument::QDomDocument(
const QString& name)
6240 impl =
new QDomDocumentPrivate(name);
6244
6245
6246
6247
6248QDomDocument::QDomDocument(
const QDomDocumentType& doctype)
6250 impl =
new QDomDocumentPrivate(
static_cast<QDomDocumentTypePrivate *>(doctype.impl));
6254
6255
6256
6257
6258
6259
6260QDomDocument::QDomDocument(
const QDomDocument &document)
6261 : QDomNode(document)
6265QDomDocument::QDomDocument(QDomDocumentPrivate *pimpl)
6271
6272
6273
6274
6275
6276
6277QDomDocument &QDomDocument::operator=(
const QDomDocument &other) =
default;
6280
6281
6282QDomDocument::~QDomDocument()
6286#if QT_DEPRECATED_SINCE(6
, 8
)
6288QT_WARNING_DISABLE_DEPRECATED
6290
6291
6292
6293
6294
6295
6296
6297
6298bool QDomDocument::setContent(
const QString& text,
bool namespaceProcessing,
6299 QString *errorMsg,
int *errorLine,
int *errorColumn)
6301 QXmlStreamReader reader(text);
6302 reader.setNamespaceProcessing(namespaceProcessing);
6303 return setContent(&reader, namespaceProcessing, errorMsg, errorLine, errorColumn);
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
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361bool QDomDocument::setContent(
const QByteArray &data,
bool namespaceProcessing,
6362 QString *errorMsg,
int *errorLine,
int *errorColumn)
6364 QXmlStreamReader reader(data);
6365 reader.setNamespaceProcessing(namespaceProcessing);
6366 return setContent(&reader, namespaceProcessing, errorMsg, errorLine, errorColumn);
6369static inline QDomDocument::ParseOptions toParseOptions(
bool namespaceProcessing)
6371 return namespaceProcessing ? QDomDocument::ParseOption::UseNamespaceProcessing
6372 : QDomDocument::ParseOption::Default;
6375static inline void unpackParseResult(
const QDomDocument::ParseResult &parseResult,
6376 QString *errorMsg,
int *errorLine,
int *errorColumn)
6380 *errorMsg = parseResult.errorMessage;
6382 *errorLine =
static_cast<
int>(parseResult.errorLine);
6384 *errorColumn =
static_cast<
int>(parseResult.errorColumn);
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400bool QDomDocument::setContent(QIODevice* dev,
bool namespaceProcessing,
6401 QString *errorMsg,
int *errorLine,
int *errorColumn)
6403 ParseResult result = setContent(dev, toParseOptions(namespaceProcessing));
6404 unpackParseResult(result, errorMsg, errorLine, errorColumn);
6405 return bool(result);
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419bool QDomDocument::setContent(
const QString& text, QString *errorMsg,
int *errorLine,
int *errorColumn)
6421 return setContent(text,
false, errorMsg, errorLine, errorColumn);
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434bool QDomDocument::setContent(
const QByteArray& buffer, QString *errorMsg,
int *errorLine,
int *errorColumn )
6436 return setContent(buffer,
false, errorMsg, errorLine, errorColumn);
6440
6441
6442
6443
6444
6445
6446
6447
6448bool QDomDocument::setContent(QIODevice* dev, QString *errorMsg,
int *errorLine,
int *errorColumn )
6450 return setContent(dev,
false, errorMsg, errorLine, errorColumn);
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473bool QDomDocument::setContent(QXmlStreamReader *reader,
bool namespaceProcessing,
6474 QString *errorMsg,
int *errorLine,
int *errorColumn)
6476 ParseResult result = setContent(reader, toParseOptions(namespaceProcessing));
6477 unpackParseResult(result, errorMsg, errorLine, errorColumn);
6478 return bool(result);
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6499
6500
6501
6502
6503
6504
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
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
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594QDomDocument::ParseResult QDomDocument::setContentImpl(
const QByteArray &data, ParseOptions options)
6596 QXmlStreamReader reader(data);
6597 reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
6598 return setContent(&reader, options);
6601QDomDocument::ParseResult QDomDocument::setContent(QAnyStringView data, ParseOptions options)
6603 QXmlStreamReader reader(data);
6604 reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
6605 return setContent(&reader, options);
6608QDomDocument::ParseResult QDomDocument::setContent(QIODevice *device, ParseOptions options)
6610#if QT_VERSION < QT_VERSION_CHECK(7
, 0
, 0
)
6611 if (!device->isOpen()) {
6612 qWarning(
"QDomDocument called with unopened QIODevice. "
6613 "This will not be supported in future Qt versions.");
6614 if (!device->open(QIODevice::ReadOnly)) {
6615 const auto error = u"QDomDocument::setContent: Failed to open device."_s;
6616 qWarning(
"%s", qPrintable(error));
6622 QXmlStreamReader reader(device);
6623 reader.setNamespaceProcessing(options.testFlag(ParseOption::UseNamespaceProcessing));
6624 return setContent(&reader, options);
6627QDomDocument::ParseResult QDomDocument::setContent(QXmlStreamReader *reader, ParseOptions options)
6630 impl =
new QDomDocumentPrivate();
6631 return IMPL->setContent(reader, options);
6635
6636
6637
6638
6639
6640
6641
6642QString QDomDocument::toString(
int indent)
const
6645 QTextStream s(&str, QIODevice::WriteOnly);
6651
6652
6653
6654
6655
6656
6657
6658
6659QByteArray QDomDocument::toByteArray(
int indent)
const
6663 return toString(indent).toUtf8();
6668
6669
6670QDomDocumentType QDomDocument::doctype()
const
6673 return QDomDocumentType();
6674 return QDomDocumentType(IMPL->doctype());
6678
6679
6680QDomImplementation QDomDocument::implementation()
const
6683 return QDomImplementation();
6684 return QDomImplementation(IMPL->implementation());
6688
6689
6690QDomElement QDomDocument::documentElement()
const
6693 return QDomElement();
6694 return QDomElement(IMPL->documentElement());
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707QDomElement QDomDocument::createElement(
const QString& tagName)
6710 impl =
new QDomDocumentPrivate();
6711 return QDomElement(IMPL->createElement(tagName));
6715
6716
6717
6718
6719QDomDocumentFragment QDomDocument::createDocumentFragment()
6722 impl =
new QDomDocumentPrivate();
6723 return QDomDocumentFragment(IMPL->createDocumentFragment());
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736QDomText QDomDocument::createTextNode(
const QString& value)
6739 impl =
new QDomDocumentPrivate();
6740 return QDomText(IMPL->createTextNode(value));
6744
6745
6746
6747
6748
6749
6750
6751
6752QDomComment QDomDocument::createComment(
const QString& value)
6755 impl =
new QDomDocumentPrivate();
6756 return QDomComment(IMPL->createComment(value));
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769QDomCDATASection QDomDocument::createCDATASection(
const QString& value)
6772 impl =
new QDomDocumentPrivate();
6773 return QDomCDATASection(IMPL->createCDATASection(value));
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788QDomProcessingInstruction QDomDocument::createProcessingInstruction(
const QString& target,
6789 const QString& data)
6792 impl =
new QDomDocumentPrivate();
6793 return QDomProcessingInstruction(IMPL->createProcessingInstruction(target, data));
6798
6799
6800
6801
6802
6803
6804
6805
6806QDomAttr QDomDocument::createAttribute(
const QString& name)
6809 impl =
new QDomDocumentPrivate();
6810 return QDomAttr(IMPL->createAttribute(name));
6814
6815
6816
6817
6818
6819
6820
6821
6822QDomEntityReference QDomDocument::createEntityReference(
const QString& name)
6825 impl =
new QDomDocumentPrivate();
6826 return QDomEntityReference(IMPL->createEntityReference(name));
6830
6831
6832
6833
6834
6835
6836
6837QDomNodeList QDomDocument::elementsByTagName(
const QString& tagname)
const
6839 return QDomNodeList(
new QDomNodeListPrivate(impl, tagname));
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
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911QDomNode QDomDocument::importNode(
const QDomNode& importedNode,
bool deep)
6913 if (importedNode.isNull())
6916 impl =
new QDomDocumentPrivate();
6917 return QDomNode(IMPL->importNode(importedNode.impl, deep));
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932QDomElement QDomDocument::createElementNS(
const QString& nsURI,
const QString& qName)
6935 impl =
new QDomDocumentPrivate();
6936 return QDomElement(IMPL->createElementNS(nsURI, qName));
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951QDomAttr QDomDocument::createAttributeNS(
const QString& nsURI,
const QString& qName)
6954 impl =
new QDomDocumentPrivate();
6955 return QDomAttr(IMPL->createAttributeNS(nsURI, qName));
6959
6960
6961
6962
6963
6964
6965
6966QDomNodeList QDomDocument::elementsByTagNameNS(
const QString& nsURI,
const QString& localName)
6968 return QDomNodeList(
new QDomNodeListPrivate(impl, nsURI, localName));
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981QDomElement QDomDocument::elementById(
const QString& )
6983 qWarning(
"elementById() is not implemented and will always return a null node.");
6984 return QDomElement();
6988
6989
6990
6991
6996
6997
6998
6999
7002
7003
7004
7005
7006
7007QDomAttr QDomNode::toAttr()
const
7009 if (impl && impl->isAttr())
7010 return QDomAttr(
static_cast<QDomAttrPrivate *>(impl));
7015
7016
7017
7018
7019
7020QDomCDATASection QDomNode::toCDATASection()
const
7022 if (impl && impl->isCDATASection())
7023 return QDomCDATASection(
static_cast<QDomCDATASectionPrivate *>(impl));
7024 return QDomCDATASection();
7028
7029
7030
7031
7032
7033QDomDocumentFragment QDomNode::toDocumentFragment()
const
7035 if (impl && impl->isDocumentFragment())
7036 return QDomDocumentFragment(
static_cast<QDomDocumentFragmentPrivate *>(impl));
7037 return QDomDocumentFragment();
7041
7042
7043
7044
7045
7046QDomDocument QDomNode::toDocument()
const
7048 if (impl && impl->isDocument())
7049 return QDomDocument(
static_cast<QDomDocumentPrivate *>(impl));
7050 return QDomDocument();
7054
7055
7056
7057
7058
7059QDomDocumentType QDomNode::toDocumentType()
const
7061 if (impl && impl->isDocumentType())
7062 return QDomDocumentType(
static_cast<QDomDocumentTypePrivate *>(impl));
7063 return QDomDocumentType();
7067
7068
7069
7070
7071
7072QDomElement QDomNode::toElement()
const
7074 if (impl && impl->isElement())
7075 return QDomElement(
static_cast<QDomElementPrivate *>(impl));
7076 return QDomElement();
7080
7081
7082
7083
7084
7085QDomEntityReference QDomNode::toEntityReference()
const
7087 if (impl && impl->isEntityReference())
7088 return QDomEntityReference(
static_cast<QDomEntityReferencePrivate *>(impl));
7089 return QDomEntityReference();
7093
7094
7095
7096
7097
7098QDomText QDomNode::toText()
const
7100 if (impl && impl->isText())
7101 return QDomText(
static_cast<QDomTextPrivate *>(impl));
7106
7107
7108
7109
7110
7111QDomEntity QDomNode::toEntity()
const
7113 if (impl && impl->isEntity())
7114 return QDomEntity(
static_cast<QDomEntityPrivate *>(impl));
7115 return QDomEntity();
7119
7120
7121
7122
7123
7124QDomNotation QDomNode::toNotation()
const
7126 if (impl && impl->isNotation())
7127 return QDomNotation(
static_cast<QDomNotationPrivate *>(impl));
7128 return QDomNotation();
7132
7133
7134
7135
7136
7137QDomProcessingInstruction QDomNode::toProcessingInstruction()
const
7139 if (impl && impl->isProcessingInstruction())
7140 return QDomProcessingInstruction(
static_cast<QDomProcessingInstructionPrivate *>(impl));
7141 return QDomProcessingInstruction();
7145
7146
7147
7148
7149
7150QDomCharacterData QDomNode::toCharacterData()
const
7152 if (impl && impl->isCharacterData())
7153 return QDomCharacterData(
static_cast<QDomCharacterDataPrivate *>(impl));
7154 return QDomCharacterData();
7158
7159
7160
7161
7162
7163QDomComment QDomNode::toComment()
const
7165 if (impl && impl->isComment())
7166 return QDomComment(
static_cast<QDomCommentPrivate *>(impl));
7167 return QDomComment();
7171
7172
7173
7174