Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/xmlpatterns/acceltree/qacceliterators.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/xmlpatterns/acceltree/qacceliterators_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6666     * contains common functions and members.
    6767     *
    68      * @author Frans Englich<fenglich@trolltech.com>
     68     * @author Frans Englich<frans.englich@nokia.com>
    6969     */
    7070    class AccelIterator : public QXmlNodeModelIndex::Iterator
     
    111111     * @short Iterates along the @c ancestor or @c ancestor-or-self axis in an AccelTree.
    112112     *
    113      * @author Frans Englich<fenglich@trolltech.com>
     113     * @author Frans Englich<frans.englich@nokia.com>
    114114     */
    115115    template<const bool IncludeSelf>
     
    152152     * @short Iterates along the @c child axis in an AccelTree.
    153153     *
    154      * @author Frans Englich<fenglich@trolltech.com>
     154     * @author Frans Englich<frans.englich@nokia.com>
    155155     */
    156156    class ChildIterator : public AccelIterator
     
    191191     * @short Iterates along the sibling axes in an AccelTree.
    192192     *
    193      * @author Frans Englich<fenglich@trolltech.com>
     193     * @author Frans Englich<frans.englich@nokia.com>
    194194     */
    195195    template<const bool IsFollowing>
     
    263263     * AccelTree.
    264264     *
    265      * @author Frans Englich <fenglich@trolltech.com>
     265     * @author Frans Englich <frans.englich@nokia.com>
    266266     */
    267267    template<const bool IncludeSelf>
     
    343343     * @short Implements axis @c following for the AccelTree.
    344344     *
    345      * @author Frans Englich <fenglich@trolltech.com>
     345     * @author Frans Englich <frans.englich@nokia.com>
    346346     */
    347347    class FollowingIterator : public AccelIterator
     
    363363     * @short Implements axis @c preceding for the AccelTree.
    364364     *
    365      * @author Frans Englich <fenglich@trolltech.com>
     365     * @author Frans Englich <frans.englich@nokia.com>
    366366     */
    367367    class PrecedingIterator : public AccelIterator
     
    388388     * @short Implements axis @c attribute for the AccelTree.
    389389     *
    390      * @author Frans Englich <fenglich@trolltech.com>
     390     * @author Frans Englich <frans.englich@nokia.com>
    391391     */
    392392    class AttributeIterator : public AccelIterator
  • trunk/src/xmlpatterns/acceltree/qacceltree.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4343
    4444#include "qabstractxmlreceiver.h"
     45#include "qabstractxmlnodemodel_p.h"
    4546#include "qacceliterators_p.h"
    4647#include "qacceltree_p.h"
     
    5657using namespace QPatternist;
    5758
     59namespace QPatternist {
     60
     61    class AccelTreePrivate : public QAbstractXmlNodeModelPrivate
     62    {
     63        public:
     64            AccelTreePrivate(AccelTree *accelTree)
     65                : m_accelTree(accelTree)
     66            {
     67            }
     68
     69            virtual QSourceLocation sourceLocation(const QXmlNodeModelIndex &index) const
     70            {
     71                return m_accelTree->sourceLocation(index);
     72            }
     73
     74        private:
     75            AccelTree *m_accelTree;
     76    };
     77}
     78
     79AccelTree::AccelTree(const QUrl &docURI, const QUrl &bURI)
     80     : QAbstractXmlNodeModel(new AccelTreePrivate(this))
     81     , m_documentURI(docURI)
     82     , m_baseURI(bURI)
     83{
     84    /* Pre-allocate at least a little bit. */
     85    // TODO. Do it according to what an average 4 KB doc contains.
     86    basicData.reserve(100);
     87    data.reserve(30);
     88}
     89
    5890void AccelTree::printStats(const NamePool::Ptr &np) const
    5991{
     
    72104    {
    73105        const BasicNodeData &v = basicData.at(i);
    74         pDebug() << "|" << i
     106        pDebug() << '|' << i
    75107                 << "\t\t|" << v.depth()
    76108                 << "\t|" << v.size()
     
    82114                 << "\t|";
    83115        /*
    84         pDebug() << "|" << QString().arg(i, 14)
    85                  << "|" << QString().arg(v.depth(), 6)
    86                  << "|" << QString().arg(v.size(), 6)
    87                  << "|" << QString().arg(postNumber(i), 14)
    88                  << "|" << QString().arg(v.kind(), 6)
    89                  << "|";
     116        pDebug() << '|' << QString().arg(i, 14)
     117                 << '|' << QString().arg(v.depth(), 6)
     118                 << '|' << QString().arg(v.size(), 6)
     119                 << '|' << QString().arg(postNumber(i), 14)
     120                 << '|' << QString().arg(v.kind(), 6)
     121                 << '|';
    90122                 */
    91123    }
     
    675707}
    676708
     709QSourceLocation AccelTree::sourceLocation(const QXmlNodeModelIndex &index) const
     710{
     711    const PreNumber key = toPreNumber(index);
     712    if (sourcePositions.contains(key)) {
     713        const QPair<qint64, qint64> position = sourcePositions.value(key);
     714        return QSourceLocation(m_documentURI, position.first, position.second);
     715    } else {
     716        return QSourceLocation();
     717    }
     718}
     719
    677720void AccelTree::copyChildren(const QXmlNodeModelIndex &node,
    678721                             QAbstractXmlReceiver *const receiver,
  • trunk/src/xmlpatterns/acceltree/qacceltree_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7777     * of staircase join, although that is only due to time constraints.
    7878     *
    79      * @author Frans Englich <fenglich@trolltech.com>
     79     * @author Frans Englich <frans.englich@nokia.com>
    8080     * @see <a href="http://www.pathfinder-xquery.org/?q=research/xpath-accel">XPath
    8181     * Accelerator</a>
     
    9090     * XPath Evaluation in Any RDBMS, Torsten Grust</a>
    9191     */
    92     class AccelTree : public QAbstractXmlNodeModel
     92    class Q_AUTOTEST_EXPORT AccelTree : public QAbstractXmlNodeModel
    9393    {
     94        friend class AccelTreePrivate;
    9495    public:
    9596        using QAbstractXmlNodeModel::createIndex;
     
    100101        typedef qint8 Depth;
    101102
    102         inline AccelTree(const QUrl &docURI,
    103                          const QUrl &bURI) : m_documentURI(docURI),
    104                                              m_baseURI(bURI)
    105         {
    106             /* Pre-allocate at least a little bit. */
    107             // TODO. Do it according to what an average 4 KB doc contains.
    108             basicData.reserve(100);
    109             data.reserve(30);
    110         }
     103        AccelTree(const QUrl &docURI, const QUrl &bURI);
    111104
    112105        /**
     
    116109         * only used by those classes.
    117110         *
    118          * @author Frans Englich <fenglich@trolltech.com>
     111         * @author Frans Englich <frans.englich@nokia.com>
    119112         * @todo Can't m_kind be coded somewhere else? If m_name is invalid,
    120113         * its bits can be used to distinguish the node types that doesn't have
     
    129122        {
    130123        public:
     124            /* No need to initialize the members. See AccelTreeBuilder. */
    131125            inline BasicNodeData()
    132126            {
     
    217211
    218212            /**
    219              * Technically it is sufficient with 8 bits. However, at least MSVC
     213             * Technically it is sufficient with 7 bits. However, at least MSVC
    220214             * 2005 miscompiles it such that QXmlNodeModelIndex::Text becomes
    221215             * -64 instead of 64 with hilarious crashes as result.
     
    281275
    282276        QVector<BasicNodeData> basicData;
     277        QHash<PreNumber, QPair<qint64, qint64> > sourcePositions;
    283278
    284279        inline QUrl documentUri() const
     
    382377    private:
    383378        /**
     379         * Returns the source location for the object with the given @p index.
     380         */
     381        QSourceLocation sourceLocation(const QXmlNodeModelIndex &index) const;
     382
     383        /**
    384384         * Copies the children of @p node to @p receiver.
    385385         */
  • trunk/src/xmlpatterns/acceltree/qacceltreebuilder.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5050                                                 const QUrl &baseURI,
    5151                                                 const NamePool::Ptr &np,
    52                                                  ReportContext *const context) : m_preNumber(-1)
    53                                                                                , m_isPreviousAtomic(false)
    54                                                                                , m_hasCharacters(false)
    55                                                                                , m_isCharactersCompressed(false)
    56                                                                                , m_namePool(np)
    57                                                                                , m_document(new AccelTree(docURI, baseURI))
    58                                                                                , m_skippedDocumentNodes(0)
    59                                                                                , m_documentURI(docURI)
    60                                                                                , m_context(context)
     52                                                 ReportContext *const context,
     53                                                 Features features) : m_preNumber(-1)
     54                                                                    , m_isPreviousAtomic(false)
     55                                                                    , m_hasCharacters(false)
     56                                                                    , m_isCharactersCompressed(false)
     57                                                                    , m_namePool(np)
     58                                                                    , m_document(new AccelTree(docURI, baseURI))
     59                                                                    , m_skippedDocumentNodes(0)
     60                                                                    , m_documentURI(docURI)
     61                                                                    , m_context(context)
     62                                                                    , m_features(features)
    6163{
    6264    Q_ASSERT(m_namePool);
     
    127129void AccelTreeBuilder<FromDocument>::startElement(const QXmlName &name)
    128130{
     131    startElement(name, 1, 1);
     132}
     133
     134template <bool FromDocument>
     135void AccelTreeBuilder<FromDocument>::startElement(const QXmlName &name, qint64 line, qint64 column)
     136{
    129137    startStructure();
    130138
    131     m_document->basicData.append(AccelTree::BasicNodeData(currentDepth(), currentParent(), QXmlNodeModelIndex::Element, -1, name));
     139    AccelTree::BasicNodeData data(currentDepth(), currentParent(), QXmlNodeModelIndex::Element, -1, name);
     140    m_document->basicData.append(data);
     141    if (m_features & SourceLocationsFeature)
     142        m_document->sourcePositions.insert(m_document->maximumPreNumber(), qMakePair(line, column));
    132143
    133144    ++m_preNumber;
  • trunk/src/xmlpatterns/acceltree/qacceltreebuilder_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    8181     * are from node constructor expressions.
    8282     *
    83      * @author Frans Englich <fenglich@trolltech.com>
     83     * @author Frans Englich <frans.englich@nokia.com>
    8484     */
    8585    template<bool FromDocument>
     
    9191
    9292        /**
     93         * Describes the memory relevant features the builder shall support.
     94         */
     95        enum Feature
     96        {
     97            NoneFeature,                ///< No special features are enabled.
     98            SourceLocationsFeature = 1  ///< The accel tree builder will store source locations for each start element.
     99        };
     100        Q_DECLARE_FLAGS(Features, Feature)
     101
     102        /**
    93103         * @param context may be @c null.
    94104         */
     
    96106                         const QUrl &baseURI,
    97107                         const NamePool::Ptr &np,
    98                          ReportContext *const context);
     108                         ReportContext *const context,
     109                         Features features = NoneFeature);
    99110        virtual void startDocument();
    100111        virtual void endDocument();
    101112        virtual void startElement(const QXmlName &name);
     113        void startElement(const QXmlName &name, qint64 line, qint64 column);
    102114        virtual void endElement();
    103115        virtual void attribute(const QXmlName &name, const QStringRef &value);
     
    176188         */
    177189        ReportContext *const            m_context;
     190
     191        Features                        m_features;
    178192    };
     193
     194    Q_DECLARE_OPERATORS_FOR_FLAGS(AccelTreeBuilder<true>::Features)
     195    Q_DECLARE_OPERATORS_FOR_FLAGS(AccelTreeBuilder<false>::Features)
    179196
    180197#include "qacceltreebuilder.cpp"
  • trunk/src/xmlpatterns/acceltree/qacceltreeresourceloader.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4747#include <QtNetwork/QNetworkRequest>
    4848
    49 #include "qacceltreebuilder_p.h"
    5049#include "qatomicstring_p.h"
    5150#include "qautoptr_p.h"
     
    5857using namespace QPatternist;
    5958
    60 static inline uint qHash(const QUrl &uri)
    61 {
    62         return qHash(uri.toString());
    63 }
    64 
    6559AccelTreeResourceLoader::AccelTreeResourceLoader(const NamePool::Ptr &np,
    66                                                  const NetworkAccessDelegator::Ptr &manager) : m_namePool(np)
    67                                                                                              , m_networkAccessDelegator(manager)
     60                                                 const NetworkAccessDelegator::Ptr &manager,
     61                                                 AccelTreeBuilder<true>::Features features)
     62    : m_namePool(np)
     63    , m_networkAccessDelegator(manager)
     64    , m_features(features)
    6865{
    6966    Q_ASSERT(m_namePool);
     
    7572{
    7673    Q_ASSERT(uri.isValid());
    77     AccelTreeBuilder<true> builder(uri, uri, m_namePool, context.data());
     74    AccelTreeBuilder<true> builder(uri, uri, m_namePool, context.data(), m_features);
    7875
    7976    const AutoPtr<QNetworkReply> reply(load(uri, m_networkAccessDelegator, context));
     
    8986}
    9087
     88bool AccelTreeResourceLoader::retrieveDocument(QIODevice *source, const QUrl &documentUri, const ReportContext::Ptr &context)
     89{
     90    Q_ASSERT(source);
     91    Q_ASSERT(source->isReadable());
     92    Q_ASSERT(documentUri.isValid());
     93
     94    AccelTreeBuilder<true> builder(documentUri, documentUri, m_namePool, context.data(), m_features);
     95
     96    bool success = false;
     97    success = streamToReceiver(source, &builder, m_namePool, context, documentUri);
     98
     99    m_loadedDocuments.insert(documentUri, builder.builtDocument());
     100
     101    return success;
     102}
     103
    91104QNetworkReply *AccelTreeResourceLoader::load(const QUrl &uri,
    92105                                             const NetworkAccessDelegator::Ptr &networkDelegator,
    93                                              const ReportContext::Ptr &context)
     106                                             const ReportContext::Ptr &context, ErrorHandling errorHandling)
    94107{
    95108    return load(uri,
    96109                networkDelegator->managerFor(uri),
    97                 context);
     110                context, errorHandling);
    98111}
    99112
    100113QNetworkReply *AccelTreeResourceLoader::load(const QUrl &uri,
    101114                                             QNetworkAccessManager *const networkManager,
    102                                              const ReportContext::Ptr &context)
     115                                             const ReportContext::Ptr &context, ErrorHandling errorHandling)
     116
    103117{
    104118    Q_ASSERT(networkManager);
     
    112126    networkLoop.connect(reply, SIGNAL(finished()), SLOT(finished()));
    113127
    114     if(networkLoop.exec())
     128    if(networkLoop.exec(QEventLoop::ExcludeUserInputEvents))
    115129    {
    116130        const QString errorMessage(escape(reply->errorString()));
     
    121135        const QSourceLocation location(uri);
    122136
    123         if(context)
     137        if(context && (errorHandling == FailOnError))
    124138            context->error(errorMessage, ReportContext::FODC0002, location);
    125139
     
    131145
    132146bool AccelTreeResourceLoader::streamToReceiver(QIODevice *const dev,
    133                                                QAbstractXmlReceiver *const receiver,
     147                                               AccelTreeBuilder<true> *const receiver,
    134148                                               const NamePool::Ptr &np,
    135149                                               const ReportContext::Ptr &context,
     
    155169                /* Send the name. */
    156170                receiver->startElement(np->allocateQName(reader.namespaceUri().toString(), reader.name().toString(),
    157                                                          reader.prefix().toString()));
     171                                                         reader.prefix().toString()), reader.lineNumber(), reader.columnNumber());
    158172
    159173                /* Send namespace declarations. */
     
    259273        if(retrieveDocument(uri, context))
    260274            return m_loadedDocuments.value(uri)->root(QXmlNodeModelIndex()); /* Pass in dummy object. We know AccelTree doesn't use it. */
     275        else
     276            return Item();
     277    }
     278}
     279
     280Item AccelTreeResourceLoader::openDocument(QIODevice *source, const QUrl &documentUri,
     281                                           const ReportContext::Ptr &context)
     282{
     283    const AccelTree::Ptr doc(m_loadedDocuments.value(documentUri));
     284
     285    if(doc)
     286        return doc->root(QXmlNodeModelIndex()); /* Pass in dummy object. We know AccelTree doesn't use it. */
     287    else
     288    {
     289        if(retrieveDocument(source, documentUri, context))
     290            return m_loadedDocuments.value(documentUri)->root(QXmlNodeModelIndex()); /* Pass in dummy object. We know AccelTree doesn't use it. */
    261291        else
    262292            return Item();
  • trunk/src/xmlpatterns/acceltree/qacceltreeresourceloader_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5353#define Patternist_AccelTreeResourceLoader_H
    5454
    55 #include <QtCore/QHash>
    5655#include <QtCore/QEventLoop>
    5756#include <QtNetwork/QNetworkReply>
     
    5958#include "qabstractxmlreceiver.h"
    6059#include "qacceltree_p.h"
     60#include "qacceltreebuilder_p.h"
    6161#include "qdeviceresourceloader_p.h"
    6262#include "qnamepool_p.h"
     
    7777     *
    7878     * @see AccelTreeResourceLoader::load()
    79      * @author Frans Englich <fenglich@trolltech.com>
     79     * @author Frans Englich <frans.englich@nokia.com>
    8080     */
    8181    class NetworkLoop : public QEventLoop
     
    110110     * them as AccelTree instances.
    111111     *
    112      * @author Frans Englich <fenglich@trolltech.com>
     112     * @author Frans Englich <frans.englich@nokia.com>
    113113     */
    114114    class Q_AUTOTEST_EXPORT AccelTreeResourceLoader : public DeviceResourceLoader
     
    116116    public:
    117117        /**
     118         * Describes the behaviour of the resource loader in case of an
     119         * error.
     120         */
     121        enum ErrorHandling
     122        {
     123            FailOnError,        ///< The resource loader will report the error via the report context.
     124            ContinueOnError     ///< The resource loader will report no error and return an empty QNetworkReply.
     125        };
     126
     127        /**
    118128         * AccelTreeResourceLoader does not own @p context.
    119129         */
    120130        AccelTreeResourceLoader(const NamePool::Ptr &np,
    121                                 const NetworkAccessDelegator::Ptr &networkDelegator);
     131                                const NetworkAccessDelegator::Ptr &networkDelegator, AccelTreeBuilder<true>::Features = AccelTreeBuilder<true>::NoneFeature);
    122132
    123133        virtual Item openDocument(const QUrl &uri,
     134                                  const ReportContext::Ptr &context);
     135        virtual Item openDocument(QIODevice *source, const QUrl &documentUri,
    124136                                  const ReportContext::Ptr &context);
    125137        virtual SequenceType::Ptr announceDocument(const QUrl &uri, const Usage usageHint);
     
    134146                                      const SourceLocationReflection *const where);
    135147
    136 
    137148        /**
    138149         * @short Helper function that do NetworkAccessDelegator::get(), but
     
    150161        static QNetworkReply *load(const QUrl &uri,
    151162                                   QNetworkAccessManager *const networkManager,
    152                                    const ReportContext::Ptr &context);
     163                                   const ReportContext::Ptr &context, ErrorHandling handling = FailOnError);
    153164
    154165        /**
     
    157168        static QNetworkReply *load(const QUrl &uri,
    158169                                   const NetworkAccessDelegator::Ptr &networkDelegator,
    159                                    const ReportContext::Ptr &context);
     170                                   const ReportContext::Ptr &context, ErrorHandling handling = FailOnError);
    160171
    161172        /**
     
    166177
    167178        virtual void clear(const QUrl &uri);
     179
    168180    private:
    169181        static bool streamToReceiver(QIODevice *const dev,
    170                                      QAbstractXmlReceiver *const receiver,
     182                                     AccelTreeBuilder<true> *const receiver,
    171183                                     const NamePool::Ptr &np,
    172184                                     const ReportContext::Ptr &context,
     
    174186        bool retrieveDocument(const QUrl &uri,
    175187                              const ReportContext::Ptr &context);
     188        bool retrieveDocument(QIODevice *source, const QUrl &documentUri,
     189                              const ReportContext::Ptr &context);
    176190        /**
    177191         * If @p context is @c null, no error reporting should be done.
     
    186200        const NetworkAccessDelegator::Ptr       m_networkAccessDelegator;
    187201        QHash<QPair<QUrl, QString>, QString>    m_unparsedTexts;
     202        AccelTreeBuilder<true>::Features        m_features;
    188203    };
    189204}
  • trunk/src/xmlpatterns/acceltree/qcompressedwhitespace.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/xmlpatterns/acceltree/qcompressedwhitespace_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtXmlPatterns module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    8383     * The compression scheme originates from Saxon, by Michael Kay.
    8484     *
    85      * @author Frans Englich <fenglich@trolltech.com>
     85     * @author Frans Englich <frans.englich@nokia.com>
    8686     */
    87     class CompressedWhitespace
     87    class Q_AUTOTEST_EXPORT CompressedWhitespace
    8888    {
    8989        public:
Note: See TracChangeset for help on using the changeset viewer.