[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 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.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at [email protected].
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | //
|
---|
| 43 | // W A R N I N G
|
---|
| 44 | // -------------
|
---|
| 45 | //
|
---|
| 46 | // This file is not part of the Qt API. It exists purely as an
|
---|
| 47 | // implementation detail. This header file may change from version to
|
---|
| 48 | // version without notice, or even be removed.
|
---|
| 49 | //
|
---|
| 50 | // We mean it.
|
---|
| 51 |
|
---|
| 52 | #ifndef QXMLQUERY_P_H
|
---|
| 53 | #define QXMLQUERY_P_H
|
---|
| 54 |
|
---|
| 55 | #include <QAbstractMessageHandler>
|
---|
| 56 | #include <QAbstractUriResolver>
|
---|
| 57 | #include <QPointer>
|
---|
| 58 | #include <QSourceLocation>
|
---|
| 59 | #include <QUrl>
|
---|
| 60 | #include <QVariant>
|
---|
| 61 | #include <QXmlName>
|
---|
| 62 | #include <QXmlNamePool>
|
---|
| 63 | #include <QXmlQuery>
|
---|
| 64 |
|
---|
| 65 | #include "qacceltreebuilder_p.h"
|
---|
| 66 | #include "qacceltreeresourceloader_p.h"
|
---|
| 67 | #include "qcoloringmessagehandler_p.h"
|
---|
| 68 | #include "qcommonsequencetypes_p.h"
|
---|
| 69 | #include "qexpressionfactory_p.h"
|
---|
| 70 | #include "qfocus_p.h"
|
---|
| 71 | #include "qfunctionfactorycollection_p.h"
|
---|
| 72 | #include "qgenericdynamiccontext_p.h"
|
---|
| 73 | #include "qgenericstaticcontext_p.h"
|
---|
| 74 | #include "qnamepool_p.h"
|
---|
| 75 | #include "qnetworkaccessdelegator_p.h"
|
---|
| 76 | #include "qreferencecountedvalue_p.h"
|
---|
| 77 | #include "qresourcedelegator_p.h"
|
---|
| 78 | #include "qstaticfocuscontext_p.h"
|
---|
| 79 | #include "quriloader_p.h"
|
---|
| 80 | #include "qvariableloader_p.h"
|
---|
| 81 |
|
---|
| 82 | QT_BEGIN_NAMESPACE
|
---|
| 83 |
|
---|
| 84 | class QXmlQueryPrivate
|
---|
| 85 | {
|
---|
| 86 | public:
|
---|
| 87 |
|
---|
| 88 | inline QXmlQueryPrivate(const QXmlNamePool &np = QXmlNamePool()) : namePool(np)
|
---|
| 89 | , messageHandler(0)
|
---|
| 90 | , uriResolver(0)
|
---|
| 91 | , queryLanguage(QXmlQuery::XQuery10)
|
---|
| 92 | , m_networkAccessDelegator(new QPatternist::NetworkAccessDelegator(0, 0))
|
---|
| 93 | {
|
---|
| 94 | m_networkAccessDelegator->m_variableURIManager = new QPatternist::URILoader(ownerObject(), namePool.d, variableLoader());
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | void detach()
|
---|
| 98 | {
|
---|
| 99 | if(m_variableLoader)
|
---|
| 100 | m_variableLoader = QPatternist::VariableLoader::Ptr(new QPatternist::VariableLoader(namePool.d, m_variableLoader));
|
---|
| 101 |
|
---|
| 102 | delete m_networkAccessDelegator->m_variableURIManager;
|
---|
| 103 | m_networkAccessDelegator->m_variableURIManager = new QPatternist::URILoader(ownerObject(), namePool.d, m_variableLoader);
|
---|
| 104 |
|
---|
| 105 | if(m_resourceLoader)
|
---|
| 106 | {
|
---|
| 107 | const QPatternist::AccelTreeResourceLoader::Ptr nev(new QPatternist::AccelTreeResourceLoader(namePool.d,
|
---|
| 108 | m_networkAccessDelegator));
|
---|
| 109 | m_resourceLoader = QPatternist::ResourceLoader::Ptr(new QPatternist::ResourceDelegator(m_resourceLoader->deviceURIs(),
|
---|
| 110 | m_resourceLoader,
|
---|
| 111 | nev));
|
---|
| 112 | }
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | bool isValid()
|
---|
| 116 | {
|
---|
| 117 | return expression();
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | inline void recompileRequired()
|
---|
| 121 | {
|
---|
| 122 | m_expr.reset();
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | inline QPatternist::VariableLoader::Ptr variableLoader()
|
---|
| 126 | {
|
---|
| 127 | if(!m_variableLoader)
|
---|
| 128 | m_variableLoader = QPatternist::VariableLoader::Ptr(new QPatternist::VariableLoader(namePool.d));
|
---|
| 129 |
|
---|
| 130 | return m_variableLoader;
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | inline QPatternist::GenericStaticContext::Ptr staticContext()
|
---|
| 134 | {
|
---|
| 135 | if(m_staticContext && m_expr)
|
---|
| 136 | return m_staticContext;
|
---|
| 137 | /* Else, re-create the staticContext. */
|
---|
| 138 |
|
---|
| 139 | if(!messageHandler)
|
---|
| 140 | messageHandler = new QPatternist::ColoringMessageHandler(ownerObject());
|
---|
| 141 |
|
---|
| 142 | if(!m_functionFactory)
|
---|
| 143 | {
|
---|
[561] | 144 | if(queryLanguage == QXmlQuery::XSLT20)
|
---|
| 145 | m_functionFactory = QPatternist::FunctionFactoryCollection::xslt20Factory(namePool.d);
|
---|
| |
---|