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

📄 qxml.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}/*!    Returns a list of all the prefixes currently declared.    If there is a default prefix, this function does not return it in    the list; check for the default prefix using uri() with an    argument of "".*/QStringList QXmlNamespaceSupport::prefixes() const{    QStringList list;    NamespaceMap::const_iterator itc, it = d->ns.constBegin();    while ((itc=it) != d->ns.constEnd()) {        ++it;        if (!itc.key().isEmpty())            list.append(itc.key());    }    return list;}/*!    \overload    Returns a list of all prefixes currently declared for the    namespace URI \a uri.    The "xml:" prefix is included. If you only want one prefix that is    mapped to the namespace URI, and you don't care which one you get,    use the prefix() function instead.    Note: The empty (default) prefix is never included in this list;    to check for the presence of a default namespace, call uri() with    "" as the argument.*/QStringList QXmlNamespaceSupport::prefixes(const QString& uri) const{    QStringList list;    NamespaceMap::const_iterator itc, it = d->ns.constBegin();    while ((itc=it) != d->ns.constEnd()) {        ++it;        if (*itc == uri && !itc.key().isEmpty())            list.append(itc.key());    }    return list;}/*!    Starts a new namespace context.    Normally, you should push a new context at the beginning of each    XML element: the new context automatically inherits the    declarations of its parent context, and it also keeps track of    which declarations were made within this context.    \sa popContext()*/void QXmlNamespaceSupport::pushContext(){    d->nsStack.push(d->ns);}/*!    Reverts to the previous namespace context.    Normally, you should pop the context at the end of each XML    element. After popping the context, all namespace prefix mappings    that were previously in force are restored.    \sa pushContext()*/void QXmlNamespaceSupport::popContext(){    d->ns.clear();    if(!d->nsStack.isEmpty())        d->ns = d->nsStack.pop();}/*!    Resets this namespace support object ready for reuse.*/void QXmlNamespaceSupport::reset(){    delete d;    d = new QXmlNamespaceSupportPrivate;}/********************************************* * * QXmlAttributes * *********************************************//*!    \class QXmlAttributes    \reentrant    \brief The QXmlAttributes class provides XML attributes.    \module XML    \ingroup xml-tools    If attributes are reported by QXmlContentHandler::startElement()    this class is used to pass the attribute values.    Use index() to locate the position of an attribute in the list,    count() to retrieve the number of attributes, and clear() to    remove the attributes. New attributes can be added with append().    Use type() to get an attribute's type and value() to get its    value. The attribute's name is available from localName() or    qName(), and its namespace URI from uri().*//*!    \fn QXmlAttributes::QXmlAttributes()    Constructs an empty attribute list.*//*!    \fn QXmlAttributes::~QXmlAttributes()    Destroys the attributes object.*//*!    Looks up the index of an attribute by the qualified name \a qName.    Returns the index of the attribute or -1 if it wasn't found.    \sa {Namespace Support via Features}*/int QXmlAttributes::index(const QString& qName) const{    for (int i = 0; i < attList.size(); ++i) {        if (attList.at(i).qname == qName)            return i;    }    return -1;}/*! \overload  */int QXmlAttributes::index(const QLatin1String& qName) const{    for (int i = 0; i < attList.size(); ++i) {        if (attList.at(i).qname == qName)            return i;    }    return -1;}/*!    \overload    Looks up the index of an attribute by a namespace name.    \a uri specifies the namespace URI, or an empty string if the name    has no namespace URI. \a localPart specifies the attribute's local    name.    Returns the index of the attribute, or -1 if it wasn't found.    \sa {Namespace Support via Features}*/int QXmlAttributes::index(const QString& uri, const QString& localPart) const{    for (int i = 0; i < attList.size(); ++i) {        const Attribute &att = attList.at(i);        if (att.uri == uri && att.localname == localPart)            return i;    }    return -1;}/*!    Returns the number of attributes in the list.    \sa count()*/int QXmlAttributes::length() const{    return attList.count();}/*!    \fn int QXmlAttributes::count() const    Returns the number of attributes in the list. This function is    equivalent to length().*//*!    Looks up an attribute's local name for the attribute at position    \a index. If no namespace processing is done, the local name is    an empty string.    \sa {Namespace Support via Features}*/QString QXmlAttributes::localName(int index) const{    return attList.at(index).localname;}/*!    Looks up an attribute's XML 1.0 qualified name for the attribute    at position \a index.    \sa {Namespace Support via Features}*/QString QXmlAttributes::qName(int index) const{    return attList.at(index).qname;}/*!    Looks up an attribute's namespace URI for the attribute at    position \a index. If no namespace processing is done or if the    attribute has no namespace, the namespace URI is an empty string.    \sa {Namespace Support via Features}*/QString QXmlAttributes::uri(int index) const{    return attList.at(index).uri;}/*!    Looks up an attribute's type for the attribute at position \a    index.    Currently only "CDATA" is returned.*/QString QXmlAttributes::type(int) const{    return QLatin1String("CDATA");}/*!    \overload    Looks up an attribute's type for the qualified name \a qName.    Currently only "CDATA" is returned.*/QString QXmlAttributes::type(const QString&) const{    return QLatin1String("CDATA");}/*!    \overload    Looks up an attribute's type by namespace name.    \a uri specifies the namespace URI and \a localName specifies the    local name. If the name has no namespace URI, use an empty string    for \a uri.    Currently only "CDATA" is returned.*/QString QXmlAttributes::type(const QString&, const QString&) const{    return QLatin1String("CDATA");}/*!    Returns an attribute's value for the attribute at position \a    index. The index must be a valid position    (i.e., 0 <= \a index < count()).*/QString QXmlAttributes::value(int index) const{    return attList.at(index).value;}/*!    \overload    Returns an attribute's value for the qualified name \a qName, or an    empty string if no attribute exists for the name given.    \sa {Namespace Support via Features}*/QString QXmlAttributes::value(const QString& qName) const{    int i = index(qName);    if (i == -1)        return QString();    return attList.at(i).value;}/*!    \overload    Returns an attribute's value for the qualified name \a qName, or an    empty string if no attribute exists for the name given.    \sa {Namespace Support via Features}*/QString QXmlAttributes::value(const QLatin1String& qName) const{    int i = index(qName);    if (i == -1)        return QString();    return attList.at(i).value;}/*!    \overload    Returns an attribute's value by namespace name.    \a uri specifies the namespace URI, or an empty string if the name    has no namespace URI. \a localName specifies the attribute's local    name.*/QString QXmlAttributes::value(const QString& uri, const QString& localName) const{    int i = index(uri, localName);    if (i == -1)        return QString();    return attList.at(i).value;}/*!    Clears the list of attributes.    \sa append()*/void QXmlAttributes::clear(){    attList.clear();}/*!    Appends a new attribute entry to the list of attributes. The    qualified name of the attribute is \a qName, the namespace URI is    \a uri and the local name is \a localPart. The value of the    attribute is \a value.    \sa qName() uri() localName() value()*/void QXmlAttributes::append(const QString &qName, const QString &uri, const QString &localPart, const QString &value){    Attribute att;    att.qname = qName;    att.uri = uri;    att.localname = localPart;    att.value = value;    attList.append(att);}/********************************************* * * QXmlInputSource * *********************************************//*!    \class QXmlInputSource    \reentrant    \brief The QXmlInputSource class provides the input data for the    QXmlReader subclasses.    \module XML    \ingroup xml-tools    All subclasses of QXmlReader read the input XML document from this    class.    This class recognizes the encoding of the data by reading the    encoding declaration in the XML file if it finds one, and reading    the data using the corresponding encoding. If it does not find an    encoding declaration, then it assumes that the data is either in    UTF-8 or UTF-16, depending on whether it can find a byte-order    mark.    There are two ways to populate the input source with data: you can    construct it with a QIODevice* so that the input source reads the    data from that device. Or you can set the data explicitly with one    of the setData() functions.    Usually you either construct a QXmlInputSource that works on a    QIODevice* or you construct an empty QXmlInputSource and set the    data with setData(). There are only rare occasions where you would    want to mix both methods.    The QXmlReader subclasses use the next() function to read the    input character by character. If you want to start from the    beginning again, use reset().    The functions data() and fetchData() are useful if you want to do    something with the data other than parsing, e.g. displaying the    raw XML file. The benefit of using the QXmlInputClass in such    cases is that it tries to use the correct encoding.    \sa QXmlReader QXmlSimpleReader*/// the following two are guaranteed not to be a characterconst ushort QXmlInputSource::EndOfData = 0xfffe;const ushort QXmlInputSource::EndOfDocument = 0xffff;/*    Common part of the constructors.*/void QXmlInputSource::init(){    d = new QXmlInputSourcePrivate;

⌨️ 快捷键说明

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