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

📄 qxml.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    // private functions    bool eat_ws();    bool next_eat_ws();    void QT_FASTCALL next();    bool atEnd();    void init(const QXmlInputSource* i);    void initData();    bool entityExist(const QString&) const;    bool parseBeginOrContinue(int state, bool incremental);    bool parseProlog();    bool parseElement();    bool processElementEmptyTag();    bool processElementETagBegin2();    bool processElementAttribute();    bool parseMisc();    bool parseContent();    bool parsePI();    bool parseDoctype();    bool parseComment();    bool parseName();    bool parseNmtoken();    bool parseAttribute();    bool parseReference();    bool processReference();    bool parseExternalID();    bool parsePEReference();    bool parseMarkupdecl();    bool parseAttlistDecl();    bool parseAttType();    bool parseAttValue();    bool parseElementDecl();    bool parseNotationDecl();    bool parseChoiceSeq();    bool parseEntityDecl();    bool parseEntityValue();    bool parseString();    bool insertXmlRef(const QString&, const QString&, bool);    bool reportEndEntities();    void reportParseError(const QString& error);    typedef bool (QXmlSimpleReaderPrivate::*ParseFunction) ();    void unexpectedEof(ParseFunction where, int state);    void parseFailed(ParseFunction where, int state);    void pushParseState(ParseFunction function, int state);    Q_DECLARE_PUBLIC(QXmlSimpleReader)    QXmlSimpleReader *q_ptr;    friend class QXmlSimpleReaderLocator;};/*!    \class QXmlParseException    \reentrant    \brief The QXmlParseException class is used to report errors with    the QXmlErrorHandler interface.    \module XML    \ingroup xml-tools    The XML subsystem constructs an instance of this class when it    detects an error. You can retrieve the place where the error    occurred using systemId(), publicId(), lineNumber() and    columnNumber(), along with the error message(). The possible error    messages are:    \list        \o "no error occurred"        \o "error triggered by consumer"        \o "unexpected end of file"        \o "more than one document type definition"        \o "error occurred while parsing element"        \o "tag mismatch"        \o "error occurred while parsing content"        \o "unexpected character"        \o "invalid name for processing instruction"        \o "version expected while reading the XML declaration"        \o "wrong value for standalone declaration"        \o "encoding declaration or standalone declaration expected while reading the XML declaration"        \o "standalone declaration expected while reading the XML declaration"        \o "error occurred while parsing document type definition"        \o "letter is expected"        \o "error occurred while parsing comment"        \o "error occurred while parsing reference"        \o "internal general entity reference not allowed in DTD"        \o "external parsed general entity reference not allowed in attribute value"        \o "external parsed general entity reference not allowed in DTD"        \o "unparsed entity reference n wrong context"        \o "recursive entities"        \o "error in the text declaration of an external entity"    \endlist    Note that, if you want to display these error messages to your    application's users, they will be displayed in English unless    they are explicitly translated.    \sa QXmlErrorHandler, QXmlReader*//*!    Constructs a parse exception with the error string \a name for    column \a c and line \a l for the public identifier \a p and the    system identifier \a s.*/QXmlParseException::QXmlParseException(const QString& name, int c, int l,                                       const QString& p, const QString& s){    d = new QXmlParseExceptionPrivate;    d->msg = name;    d->column = c;    d->line = l;    d->pub = p;    d->sys = s;}/*!    Destroys the QXmlParseException.*/QXmlParseException::~QXmlParseException(){    delete d;}/*!    Returns the error message.*/QString QXmlParseException::message() const{    return d->msg;}/*!    Returns the column number where the error occurred.*/int QXmlParseException::columnNumber() const{    return d->column;}/*!    Returns the line number where the error occurred.*/int QXmlParseException::lineNumber() const{    return d->line;}/*!    Returns the public identifier where the error occurred.*/QString QXmlParseException::publicId() const{    return d->pub;}/*!    Returns the system identifier where the error occurred.*/QString QXmlParseException::systemId() const{    return d->sys;}/*!    \class QXmlLocator    \reentrant    \brief The QXmlLocator class provides the XML handler classes with    information about the parsing position within a file.    \module XML    \ingroup xml-tools    The reader reports a QXmlLocator to the content handler before it    starts to parse the document. This is done with the    QXmlContentHandler::setDocumentLocator() function. The handler    classes can now use this locator to get the position (lineNumber()    and columnNumber()) that the reader has reached.*//*!    Constructor.*/QXmlLocator::QXmlLocator(){}/*!    Destructor.*/QXmlLocator::~QXmlLocator(){}/*!    \fn int QXmlLocator::columnNumber() const    Returns the column number (starting at 1) or -1 if there is no    column number available.*//*!    \fn int QXmlLocator::lineNumber() const    Returns the line number (starting at 1) or -1 if there is no line    number available.*/class QXmlSimpleReaderLocator : public QXmlLocator{public:    QXmlSimpleReaderLocator(QXmlSimpleReader* parent)    {        reader = parent;    }    ~QXmlSimpleReaderLocator()    {    }    int columnNumber() const    {        return (reader->d_ptr->columnNr == -1 ? -1 : reader->d_ptr->columnNr + 1);    }    int lineNumber() const    {        return (reader->d_ptr->lineNr == -1 ? -1 : reader->d_ptr->lineNr + 1);    }//    QString getPublicId()//    QString getSystemId()private:    QXmlSimpleReader *reader;};/********************************************* * * QXmlNamespaceSupport * *********************************************/typedef QMap<QString, QString> NamespaceMap;class QXmlNamespaceSupportPrivate{public:    QXmlNamespaceSupportPrivate()    {        ns.insert(QLatin1String("xml"), QLatin1String("http://www.w3.org/XML/1998/namespace")); // the XML namespace    }    ~QXmlNamespaceSupportPrivate()    {    }    QStack<NamespaceMap> nsStack;    NamespaceMap ns;};/*!    \class QXmlNamespaceSupport    \reentrant    \brief The QXmlNamespaceSupport class is a helper class for XML    readers which want to include namespace support.    \module XML    \ingroup xml-tools    You can set the prefix for the current namespace with setPrefix(),    and get the list of current prefixes (or those for a given URI)    with prefixes(). The namespace URI is available from uri(). Use    pushContext() to start a new namespace context, and popContext()    to return to the previous namespace context. Use splitName() or    processName() to split a name into its prefix and local name.    \sa {Namespace Support via Features}*//*!    Constructs a QXmlNamespaceSupport.*/QXmlNamespaceSupport::QXmlNamespaceSupport(){    d = new QXmlNamespaceSupportPrivate;}/*!    Destroys a QXmlNamespaceSupport.*/QXmlNamespaceSupport::~QXmlNamespaceSupport(){    delete d;}/*!    This function declares a prefix \a pre in the current namespace    context to be the namespace URI \a uri. The prefix remains in    force until this context is popped, unless it is shadowed in a    descendant context.    Note that there is an asymmetry in this library. prefix() does not    return the default "" prefix, even if you have declared one; to    check for a default prefix, you must look it up explicitly using    uri(). This asymmetry exists to make it easier to look up prefixes    for attribute names, where the default prefix is not allowed.*/void QXmlNamespaceSupport::setPrefix(const QString& pre, const QString& uri){    if(pre.isNull()) {        d->ns.insert(QLatin1String(""), uri);    } else {        d->ns.insert(pre, uri);    }}/*!    Returns one of the prefixes mapped to the namespace URI \a uri.    If more than one prefix is currently mapped to the same URI, this    function makes an arbitrary selection; if you want all of the    prefixes, use prefixes() instead.    Note: to check for a default prefix, use the uri() function with    an argument of "".*/QString QXmlNamespaceSupport::prefix(const QString& uri) const{    NamespaceMap::const_iterator itc, it = d->ns.constBegin();    while ((itc=it) != d->ns.constEnd()) {        ++it;        if (*itc == uri && !itc.key().isEmpty())            return itc.key();    }    return QLatin1String("");}/*!    Looks up the prefix \a prefix in the current context and returns    the currently-mapped namespace URI. Use the empty string ("") for    the default namespace.*/QString QXmlNamespaceSupport::uri(const QString& prefix) const{    return d->ns[prefix];}/*!    Splits the name \a qname at the ':' and returns the prefix in \a    prefix and the local name in \a localname.    \sa processName()*/void QXmlNamespaceSupport::splitName(const QString& qname, QString& prefix,                                     QString& localname) const{    int pos = qname.indexOf(QLatin1Char(':'));    if (pos == -1)        pos = qname.size();    prefix = qname.left(pos);    localname = qname.mid(pos+1);}/*!    Processes a raw XML 1.0 name in the current context by removing    the prefix and looking it up among the prefixes currently    declared.    \a qname is the raw XML 1.0 name to be processed. \a isAttribute    is true if the name is an attribute name.    This function stores the namespace URI in \a nsuri (which will be    set to an empty string if the raw name has an undeclared prefix),    and stores the local name (without prefix) in \a localname (which    will be set to an empty string if no namespace is in use).    Note that attribute names are processed differently than element    names: an unprefixed element name gets the default namespace (if    any), while an unprefixed attribute name does not.*/void QXmlNamespaceSupport::processName(const QString& qname,        bool isAttribute,        QString& nsuri, QString& localname) const{    int len = qname.size();    const QChar *data = qname.constData();    for (int pos = 0; pos < len; ++pos) {        if (data[pos] == QLatin1Char(':')) {            nsuri = uri(qname.left(pos));            localname = qname.mid(pos + 1);            return;        }    }    // there was no ':'    nsuri.clear();    // attributes don't take default namespace    if (!isAttribute && !d->ns.isEmpty()) {	/*	    We want to access d->ns.value(""), but as an optimization	    we use the fact that "" compares less than any other	    string, so it's either first in the map or not there.	*/        NamespaceMap::const_iterator first = d->ns.constBegin();        if (first.key().isEmpty())            nsuri = first.value(); // get default namespace    }    localname = qname;

⌨️ 快捷键说明

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