0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the QtXmlPatterns module of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
**
|
|
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.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
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_SequenceReceiver_H
|
|
53 |
#define Patternist_SequenceReceiver_H
|
|
54 |
|
|
55 |
#include <QSharedData>
|
|
56 |
|
|
57 |
#include "qitem_p.h"
|
|
58 |
|
|
59 |
QT_BEGIN_HEADER
|
|
60 |
|
|
61 |
QT_BEGIN_NAMESPACE
|
|
62 |
|
|
63 |
namespace QPatternist
|
|
64 |
{
|
|
65 |
/**
|
|
66 |
* @short A push interface for the XPath Data Model. Similar to SAX's
|
|
67 |
* ContentHandler.
|
|
68 |
*
|
|
69 |
* @ingroup Patternist_xdm
|
|
70 |
* @author Frans Englich <frans.englich@nokia.com>
|
|
71 |
*/
|
|
72 |
class QAbstractXmlReceiver : public QSharedData
|
|
73 |
{
|
|
74 |
public:
|
|
75 |
typedef QExplicitlySharedDataPointer<QAbstractXmlReceiver> Ptr;
|
|
76 |
|
|
77 |
inline QAbstractXmlReceiver()
|
|
78 |
{
|
|
79 |
}
|
|
80 |
|
|
81 |
virtual ~QAbstractXmlReceiver();
|
|
82 |
|
|
83 |
/**
|
|
84 |
* @short Signals the start of an element by name @p name.
|
|
85 |
*/
|
|
86 |
virtual void startElement(const QXmlName name) = 0;
|
|
87 |
|
|
88 |
/**
|
|
89 |
* @short Signals the presence of the namespace declaration @p nb.
|
|
90 |
*
|
|
91 |
* This event is received @c after startElement(), as opposed to
|
|
92 |
* SAX, and before any attribute() events.
|
|
93 |
*/
|
|
94 |
virtual void namespaceBinding(const QXmlName &nb) = 0;
|
|
95 |
|
|
96 |
/**
|
|
97 |
* @short Signals the end of the current element.
|
|
98 |
*/
|
|
99 |
virtual void endElement() = 0;
|
|
100 |
|
|
101 |
/**
|
|
102 |
* @short Signals the presence of an attribute node.
|
|
103 |
*
|
|
104 |
* This function is guaranteed by the caller to always be
|
|
105 |
* called after a call to startElement() or attribute().
|
|
106 |
*
|
|
107 |
* @param name the name of the attribute. Guaranteed to always be
|
|
108 |
* non-null.
|
|
109 |
* @param value the value of the attribute. Guaranteed to always be
|
|
110 |
* non-null.
|
|
111 |
*/
|
|
112 |
virtual void attribute(const QXmlName name,
|
|
113 |
const QString &value) = 0;
|
|
114 |
|
|
115 |
virtual void processingInstruction(const QXmlName name,
|
|
116 |
const QString &value) = 0;
|
|
117 |
virtual void comment(const QString &value) = 0;
|
|
118 |
|
|
119 |
/**
|
|
120 |
* @short Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an
|
|
121 |
* AtomicValue.
|
|
122 |
*/
|
|
123 |
virtual void item(const Item &item) = 0;
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Sends a text node with value @p value. Adjascent text nodes
|
|
127 |
* may be sent. There's no restrictions on @p value, beyond that it
|
|
128 |
* must be valid XML characters. For instance, @p value may contain
|
|
129 |
* only whitespace.
|
|
130 |
*
|
|
131 |
* @see whitespaceOnly()
|
|
132 |
*/
|
|
133 |
virtual void characters(const QString &value) = 0;
|
|
134 |
|
|
135 |
/**
|
|
136 |
* This function may be called instead of characters() if, and only if,
|
|
137 |
* @p value consists only of whitespace.
|
|
138 |
*
|
|
139 |
* The caller gurantees that @p value, is not empty.
|
|
140 |
*
|
|
141 |
* By whitespace is meant a sequence of characters that are either
|
|
142 |
* spaces, tabs, or the two new line characters, in any order. In
|
|
143 |
* other words, the whole of Unicode's whitespace category is not
|
|
144 |
* considered whitespace.
|
|
145 |
*
|
|
146 |
* However, there's no guarantee or requirement that whitespaceOnly()
|
|
147 |
* is called for text nodes containing whitespace only, characters()
|
|
148 |
* may be called just as well. This is why the default implementation
|
|
149 |
* for whitespaceOnly() calls characters().
|
|
150 |
*
|
|
151 |
* @see characters()
|
|
152 |
*/
|
|
153 |
virtual void whitespaceOnly(const QStringRef &value);
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Start of a document node.
|
|
157 |
*/
|
|
158 |
virtual void startDocument() = 0;
|
|
159 |
|
|
160 |
/**
|
|
161 |
* End of a document node.
|
|
162 |
*/
|
|
163 |
virtual void endDocument() = 0;
|
|
164 |
|
|
165 |
protected:
|
|
166 |
/**
|
|
167 |
* Treats @p outputItem as an node and calls the appropriate function,
|
|
168 |
* such as attribute() or comment(), depending on its QXmlNodeModelIndex::NodeKind.
|
|
169 |
*
|
|
170 |
* This a helper function sub-classes can use to multi-plex Nodes received
|
|
171 |
* via item().
|
|
172 |
*
|
|
173 |
* @param outputItem must be a QXmlNodeModelIndex.
|
|
174 |
*/
|
|
175 |
void sendAsNode(const Item &outputItem);
|
|
176 |
|
|
177 |
private:
|
|
178 |
/**
|
|
179 |
* Call sendAsNode() for each child of @p node. As consistent with the
|
|
180 |
* XPath Data Model, this does not include attribute nodes.
|
|
181 |
*/
|
|
182 |
template<const QXmlNodeModelIndex::Axis axis>
|
|
183 |
inline void sendFromAxis(const QXmlNodeModelIndex &node);
|
|
184 |
Q_DISABLE_COPY(QAbstractXmlReceiver)
|
|
185 |
};
|
|
186 |
}
|
|
187 |
|
|
188 |
QT_END_NAMESPACE
|
|
189 |
|
|
190 |
QT_END_HEADER
|
|
191 |
|
|
192 |
#endif
|