61eea1d11111712f49203a79cfac479b86be090d
[profile/ivi/qtxmlpatterns.git] / src / xmlpatterns / api / qxmlquery.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QXMLQUERY_H
43 #define QXMLQUERY_H
44
45 #include <QtCore/QUrl>
46 #include <QtXmlPatterns/QAbstractXmlNodeModel>
47 #include <QtXmlPatterns/QAbstractXmlReceiver>
48 #include <QtXmlPatterns/QXmlNamePool>
49
50 QT_BEGIN_HEADER
51 QT_BEGIN_NAMESPACE
52
53
54 class QAbstractMessageHandler;
55 class QAbstractUriResolver;
56 class QIODevice;
57 class QNetworkAccessManager;
58 class QXmlName;
59 class QXmlNodeIndex;
60 class QXmlQueryPrivate;
61 class QXmlResultItems;
62 class QXmlSerializer;
63
64 /* The members in the namespace QPatternistSDK are internal, not part of the public API, and
65  * unsupported. Using them leads to undefined behavior. */
66 namespace QPatternistSDK
67 {
68     class TestCase;
69 }
70
71 namespace QPatternist
72 {
73     class XsdSchemaParser;
74     class XsdValidatingInstanceReader;
75     class VariableLoader;
76 }
77
78 class Q_XMLPATTERNS_EXPORT QXmlQuery
79 {
80 public:
81     enum QueryLanguage
82     {
83         XQuery10                                = 1,
84         XSLT20                                  = 2,
85         XmlSchema11IdentityConstraintSelector   = 1024,
86         XmlSchema11IdentityConstraintField      = 2048,
87         XPath20                                 = 4096
88     };
89
90     QXmlQuery();
91     QXmlQuery(const QXmlQuery &other);
92     QXmlQuery(const QXmlNamePool &np);
93     QXmlQuery(QueryLanguage queryLanguage,
94               const QXmlNamePool &np = QXmlNamePool());
95     ~QXmlQuery();
96     QXmlQuery &operator=(const QXmlQuery &other);
97
98     void setMessageHandler(QAbstractMessageHandler *messageHandler);
99     QAbstractMessageHandler *messageHandler() const;
100
101     void setQuery(const QString &sourceCode, const QUrl &documentURI = QUrl());
102     void setQuery(QIODevice *sourceCode, const QUrl &documentURI = QUrl());
103     void setQuery(const QUrl &queryURI, const QUrl &baseURI = QUrl());
104
105     QXmlNamePool namePool() const;
106
107     void bindVariable(const QXmlName &name, const QXmlItem &value);
108     void bindVariable(const QString &localName, const QXmlItem &value);
109
110     void bindVariable(const QXmlName &name, QIODevice *);
111     void bindVariable(const QString &localName, QIODevice *);
112     void bindVariable(const QXmlName &name, const QXmlQuery &query);
113     void bindVariable(const QString &localName, const QXmlQuery &query);
114
115     bool isValid() const;
116
117     void evaluateTo(QXmlResultItems *result) const;
118     bool evaluateTo(QAbstractXmlReceiver *callback) const;
119     bool evaluateTo(QStringList *target) const;
120     bool evaluateTo(QIODevice *target) const;
121     bool evaluateTo(QString *output) const;
122
123     void setUriResolver(const QAbstractUriResolver *resolver);
124     const QAbstractUriResolver *uriResolver() const;
125
126     void setFocus(const QXmlItem &item);
127     bool setFocus(const QUrl &documentURI);
128     bool setFocus(QIODevice *document);
129     bool setFocus(const QString &focus);
130
131     void setInitialTemplateName(const QXmlName &name);
132     void setInitialTemplateName(const QString &name);
133     QXmlName initialTemplateName() const;
134
135     void setNetworkAccessManager(QNetworkAccessManager *newManager);
136     QNetworkAccessManager *networkAccessManager() const;
137
138     QueryLanguage queryLanguage() const;
139 private:
140     friend class QXmlName;
141     friend class QXmlSerializer;
142     friend class QPatternistSDK::TestCase;
143     friend class QPatternist::XsdSchemaParser;
144     friend class QPatternist::XsdValidatingInstanceReader;
145     friend class QPatternist::VariableLoader;
146     template<typename TInputType> friend bool setFocusHelper(QXmlQuery *const queryInstance,
147                                                              const TInputType &focusValue);
148     QXmlQueryPrivate *d;
149 };
150
151 QT_END_NAMESPACE
152 QT_END_HEADER
153
154 #endif