Qt 4.8
qacceltreeresourceloader_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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 Patternist_AccelTreeResourceLoader_H
53 #define Patternist_AccelTreeResourceLoader_H
54 
55 #include <QtCore/QEventLoop>
56 #include <QtNetwork/QNetworkReply>
57 
58 #include "qabstractxmlreceiver.h"
59 #include "qacceltree_p.h"
60 #include "qacceltreebuilder_p.h"
62 #include "qnamepool_p.h"
64 #include "qreportcontext_p.h"
65 
67 
69 
70 class QIODevice;
71 
72 namespace QPatternist
73 {
81  class NetworkLoop : public QEventLoop
82  {
83  Q_OBJECT
84  public:
86  {
87  }
88 
89  public Q_SLOTS:
91  {
92  Q_UNUSED(code);
93  m_hasReceivedError = true;
94  exit(1);
95  }
96 
97  void finished()
98  {
100  exit(1);
101  else
102  exit(0);
103  }
104  private:
106  };
107 
115  {
116  public:
122  {
124  ContinueOnError
125  };
126 
132 
133  virtual Item openDocument(const QUrl &uri,
134  const ReportContext::Ptr &context);
135  virtual Item openDocument(QIODevice *source, const QUrl &documentUri,
136  const ReportContext::Ptr &context);
137  virtual SequenceType::Ptr announceDocument(const QUrl &uri, const Usage usageHint);
138  virtual bool isDocumentAvailable(const QUrl &uri);
139 
140  virtual bool isUnparsedTextAvailable(const QUrl &uri,
141  const QString &encoding);
142 
143  virtual Item openUnparsedText(const QUrl &uri,
144  const QString &encoding,
145  const ReportContext::Ptr &context,
146  const SourceLocationReflection *const where);
147 
161  static QNetworkReply *load(const QUrl &uri,
162  QNetworkAccessManager *const networkManager,
163  const ReportContext::Ptr &context, ErrorHandling handling = FailOnError);
164 
168  static QNetworkReply *load(const QUrl &uri,
169  const NetworkAccessDelegator::Ptr &networkDelegator,
170  const ReportContext::Ptr &context, ErrorHandling handling = FailOnError);
171 
176  virtual QSet<QUrl> deviceURIs() const;
177 
178  virtual void clear(const QUrl &uri);
179 
180  private:
181  static bool streamToReceiver(QIODevice *const dev,
182  AccelTreeBuilder<true> *const receiver,
183  const NamePool::Ptr &np,
184  const ReportContext::Ptr &context,
185  const QUrl &uri);
186  bool retrieveDocument(const QUrl &uri,
187  const ReportContext::Ptr &context);
188  bool retrieveDocument(QIODevice *source, const QUrl &documentUri,
189  const ReportContext::Ptr &context);
193  bool retrieveUnparsedText(const QUrl &uri,
194  const QString &encoding,
195  const ReportContext::Ptr &context,
196  const SourceLocationReflection *const where);
197 
203  };
204 }
205 
207 
209 
210 #endif
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
Handles requests for documents, and instantiates them as AccelTree instances.
QHash< QUrl, AccelTree::Ptr > m_loadedDocuments
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
Definition: qnetworkreply.h:65
Builds an AccelTree from a stream of XML/Item events received through the NodeBuilder interface...
Definition: qacceltree_p.h:69
static void clear(QVariant::Private *d)
Definition: qvariant.cpp:197
NetworkError
Indicates all possible error conditions found during the processing of the request.
Definition: qnetworkreply.h:70
const NetworkAccessDelegator::Ptr m_networkAccessDelegator
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QUrl class provides a convenient interface for working with URLs.
Definition: qurl.h:61
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
An helper class which enables QNetworkAccessManager to be used in a blocking manner.
The QEventLoop class provides a means of entering and leaving an event loop.
Definition: qeventloop.h:55
The namespace for the internal API of QtXmlPatterns.
static bool openDocument(const QUrl &file)
The QNetworkAccessManager class allows the application to send network requests and receive replies...
#define Q_OBJECT
Definition: qobjectdefs.h:157
QHash< QPair< QUrl, QString >, QString > m_unparsedTexts
void exit(int returnCode=0)
Tells the event loop to exit with a return code.
Definition: qeventloop.cpp:288
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
#define load(x)
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
AccelTreeBuilder< true >::Features m_features
The resource loader will report the error via the report context.
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition: qiodevice.h:66
#define QT_END_HEADER
Definition: qglobal.h:137
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void error(QNetworkReply::NetworkError code)
Base class for all instances that represents something at a certain location.
Base class for resource loaders that manage device variables.