⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdom.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
QDomImplementation::QDomImplementation(QDomImplementationPrivate *p){    // We want to be co-owners, so increase the reference count    impl = p;    if (impl)        impl->ref.ref();}/*!    Assigns \a x to this DOM implementation.*/QDomImplementation& QDomImplementation::operator=(const QDomImplementation &x){    QDomImplementationPrivate *p = x.impl;    if (p)        p->ref.ref();    p = qAtomicSetPtr(&impl, p);    if (p && !p->ref.deref())        delete p;    return *this;}/*!    Returns true if \a x and this DOM implementation object were    created from the same QDomDocument; otherwise returns false.*/bool QDomImplementation::operator==(const QDomImplementation &x) const{    return (impl == x.impl);}/*!    Returns true if \a x and this DOM implementation object were    created from different QDomDocuments; otherwise returns false.*/bool QDomImplementation::operator!=(const QDomImplementation &x) const{    return (impl != x.impl);}/*!    Destroys the object and frees its resources.*/QDomImplementation::~QDomImplementation(){    if (impl && !impl->ref.deref())        delete impl;}/*!    The function returns true if QDom implements the requested \a    version of a \a feature; otherwise returns false.    The currently supported features and their versions:    \table    \header \i Feature \i Version    \row \i XML \i 1.0    \endtable*/bool QDomImplementation::hasFeature(const QString& feature, const QString& version) const{    if (feature == QLatin1String("XML")) {        if (version.isEmpty() || version == QLatin1String("1.0")) {            return true;        }    }    // ### add DOM level 2 features    return false;}/*!    Creates a document type node for the name \a qName.    \a publicId specifies the public identifier of the external    subset. If you specify an empty string (QString()) as the \a    publicId, this means that the document type has no public    identifier.    \a systemId specifies the system identifier of the external    subset. If you specify an empty string as the \a systemId, this    means that the document type has no system identifier.    Since you cannot have a public identifier without a system    identifier, the public identifier is set to an empty string if    there is no system identifier.    DOM level 2 does not support any other document type declaration    features.    The only way you can use a document type that was created this    way, is in combination with the createDocument() function to    create a QDomDocument with this document type.    In the DOM specification, this is the only way to create a non-null    document. For historical reasons, Qt also allows to create the    document using the default empty constructor. The resulting document    is null, but becomes non-null when a factory function, for example    QDomDocument::createElement(), is called. The document also becomes    non-null when setContent() is called.    \sa createDocument()*/QDomDocumentType QDomImplementation::createDocumentType(const QString& qName, const QString& publicId, const QString& systemId){    bool ok;    QString fixedName = fixedXmlName(qName, &ok, true);    if (!ok)        return QDomDocumentType();    QString fixedPublicId = fixedPubidLiteral(publicId, &ok);    if (!ok)        return QDomDocumentType();    QString fixedSystemId = fixedSystemLiteral(systemId, &ok);    if (!ok)        return QDomDocumentType();    QDomDocumentTypePrivate *dt = new QDomDocumentTypePrivate(0);    dt->name = fixedName;    if (systemId.isNull()) {        dt->publicId.clear();        dt->systemId.clear();    } else {        dt->publicId = fixedPublicId;        dt->systemId = fixedSystemId;    }    dt->ref.deref();    return QDomDocumentType(dt);}/*!    Creates a DOM document with the document type \a doctype. This    function also adds a root element node with the qualified name \a    qName and the namespace URI \a nsURI.*/QDomDocument QDomImplementation::createDocument(const QString& nsURI, const QString& qName, const QDomDocumentType& doctype){    QDomDocument doc(doctype);    QDomElement root = doc.createElementNS(nsURI, qName);    if (root.isNull())        return QDomDocument();    doc.appendChild(root);    return doc;}/*!    Returns false if the object was created by    QDomDocument::implementation(); otherwise returns true.*/bool QDomImplementation::isNull(){    return (impl == 0);}/*!    \enum QDomImplementation::InvalidDataPolicy    This enum specifies what should be done when a factory function    in QDomDocument is called with invalid data.    \value AcceptInvalidChars The data should be stored in the DOM object        anyway. In this case the resulting XML document might not be well-formed.        This is the default value and QDom's behavior in Qt < 4.1.    \value DropInvalidChars The invalid characters should be removed from        the data.    \value ReturnNullNode The factory function should return a null node.    \sa setInvalidDataPolicy() invalidDataPolicy()*//*!   \enum QDomNode::EncodingPolicy   \since 4.3   This enum specifies how QDomNode::save() determines what encoding to use   when serializing.   \value EncodingFromDocument The encoding is fetched from the document.   \value EncodingFromTextStream The encoding is fetched from the QTextStream.   See also the overload of the save() function that takes an EncodingPolicy.*//*!    \since 4.1    Returns the invalid data policy, which specifies what should be done when    a factory function in QDomDocument is passed invalid data.    \sa setInvalidDataPolicy() InvalidDataPolicy*/QDomImplementation::InvalidDataPolicy QDomImplementation::invalidDataPolicy(){    return QDomImplementationPrivate::invalidDataPolicy;}/*!    \since 4.1    Sets the invalid data policy, which specifies what should be done when    a factory function in QDomDocument is passed invalid data.    The \a policy is set for all instances of QDomDocument which already    exist and which will be created in the future.    \code        QDomDocument doc;        QDomImplementation impl;        // This will create the element, but the resulting XML document will        // be invalid, because '~' is not a valid character in a tag name.        impl.setInvalidDataPolicy(QDomImplementation::AcceptInvalidData);        QDomElement elt1 = doc.createElement("foo~bar");        // This will create an element with the tag name "foobar".        impl.setInvalidDataPolicy(QDomImplementation::DropInvalidData);        QDomElement elt2 = doc.createElement("foo~bar");        // This will create a null element.        impl.setInvalidDataPolicy(QDomImplementation::ReturnNullNode);        QDomElement elt3 = doc.createElement("foo~bar");    \endcode    \sa invalidDataPolicy() InvalidDataPolicy*/void QDomImplementation::setInvalidDataPolicy(InvalidDataPolicy policy){    QDomImplementationPrivate::invalidDataPolicy = policy;}/************************************************************** * * QDomNodeListPrivate * **************************************************************/QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl){    ref  = 1;    node_impl = n_impl;    if (node_impl)        node_impl->ref.ref();    timestamp = -1;}QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &name){    ref = 1;    node_impl = n_impl;    if (node_impl)        node_impl->ref.ref();    tagname = name;    timestamp = -1;}QDomNodeListPrivate::QDomNodeListPrivate(QDomNodePrivate *n_impl, const QString &_nsURI, const QString &localName){    ref = 1;    node_impl = n_impl;    if (node_impl)        node_impl->ref.ref();    tagname = localName;    nsURI = _nsURI;    timestamp = -1;}QDomNodeListPrivate::~QDomNodeListPrivate(){    if (node_impl && !node_impl->ref.deref())        delete node_impl;}bool QDomNodeListPrivate::operator==(const QDomNodeListPrivate &other) const{    return (node_impl == other.node_impl) && (tagname == other.tagname);}bool QDomNodeListPrivate::operator!=(const QDomNodeListPrivate &other) const{    return (node_impl != other.node_impl) || (tagname != other.tagname);}void QDomNodeListPrivate::createList(){    if (!node_impl)        return;    timestamp = qt_nodeListTime;    QDomNodePrivate* p = node_impl->first;    list.clear();    if (tagname.isNull()) {        while (p) {            list.append(p);            p = p->next;        }    } else if (nsURI.isNull()) {        while (p && p != node_impl) {            if (p->isElement() && p->nodeName() == tagname) {                list.append(p);            }            if (p->first)                p = p->first;            else if (p->next)                p = p->next;            else {                p = p->parent();                while (p && p != node_impl && !p->next)                    p = p->parent();                if (p && p != node_impl)                    p = p->next;            }        }    } else {        while (p && p != node_impl) {            if (p->isElement() && p->name==tagname && p->namespaceURI==nsURI) {                list.append(p);            }            if (p->first)                p = p->first;            else if (p->next)                p = p->next;            else {                p = p->parent();                while (p && p != node_impl && !p->next)                    p = p->parent();                if (p && p != node_impl)                    p = p->next;            }        }    }}QDomNodePrivate* QDomNodeListPrivate::item(int index){    if (!node_impl)        return 0;    if (timestamp < qt_nodeListTime)        createList();    if (index >= list.size())        return 0;    return list.at(index);}uint QDomNodeListPrivate::length() const{    if (!node_impl)        return 0;    if (timestamp < qt_nodeListTime) {        QDomNodeListPrivate *that = (QDomNodeListPrivate*)this;        that->createList();    }    return list.count();}/************************************************************** * * QDomNodeList * **************************************************************//*!    \class QDomNodeList    \reentrant    \brief The QDomNodeList class is a list of QDomNode objects.    \module XML    \ingroup xml-tools    Lists can be obtained by QDomDocument::elementsByTagName() and    QDomNode::childNodes(). The Document Object Model (DOM) requires    these lists to be "live": whenever you change the underlying    document, the contents of the list will get updated.    You can get a particular node from the list with item(). The    number of items in the list is returned by length().    For further information about the Document Object Model see    \l{http://www.w3.org/TR/REC-DOM-Level-1/}{Level 1} and    \l{http://www.w3.org/TR/DOM-Level-2-Core/}{Level 2 Core}.    For a more general introduction of the DOM implementation see the    QDomDocument documentation.    \sa QDomNode::childNodes() QDomDocument::elementsByTagName()*//*!    Creates an empty node list.*/QDomNodeList::QDomNodeList(){    impl = 0;}QDomNodeList::QDomNodeList(QDomNodeListPrivate* p){    impl = p;}/*!    Constructs a copy of \a n.*/QDomNodeList::QDomNodeList(const QDomNodeList& n){    impl = n.impl;    if (impl)        impl->ref.ref();}/*!    Assigns \a n to this node list.*/QDomNodeList& QDomNodeList::operator=(const QDomNodeList &n){    QDomNodeListPrivate *x = n.impl;    if (x)        x->ref.ref();    x = qAtomicSetPtr(&impl, x);    if (x && !x->ref.deref())        delete x;    return *this;}/*!    Returns true if the node list \a n and this node list are equal;    otherwise returns false.*/bool QDomNodeList::operator==(const QDomNodeList &n) const{    if (impl == n.impl)        return true;    if (!impl || !n.impl)        return false;    return (*impl == *n.impl);}/*!    Returns true the node list \a n and this node list are not equal;    otherwise returns false.*/bool QDomNodeList::operator!=(const QDomNodeList &n) const{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -