1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
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.
52 #ifndef Patternist_SequenceReceiver_H
53 #define Patternist_SequenceReceiver_H
55 #include <QSharedData>
57 #include <private/qitem_p.h>
66 * @short A push interface for the XPath Data Model. Similar to SAX's
69 * @ingroup Patternist_xdm
70 * @author Frans Englich <frans.englich@nokia.com>
72 class QAbstractXmlReceiver : public QSharedData
75 typedef QExplicitlySharedDataPointer<QAbstractXmlReceiver> Ptr;
77 inline QAbstractXmlReceiver()
81 virtual ~QAbstractXmlReceiver();
84 * @short Signals the start of an element by name @p name.
86 virtual void startElement(const QXmlName name) = 0;
89 * @short Signals the presence of the namespace declaration @p nb.
91 * This event is received @c after startElement(), as opposed to
92 * SAX, and before any attribute() events.
94 virtual void namespaceBinding(const QXmlName &nb) = 0;
97 * @short Signals the end of the current element.
99 virtual void endElement() = 0;
102 * @short Signals the presence of an attribute node.
104 * This function is guaranteed by the caller to always be
105 * called after a call to startElement() or attribute().
107 * @param name the name of the attribute. Guaranteed to always be
109 * @param value the value of the attribute. Guaranteed to always be
112 virtual void attribute(const QXmlName name,
113 const QString &value) = 0;
115 virtual void processingInstruction(const QXmlName name,
116 const QString &value) = 0;
117 virtual void comment(const QString &value) = 0;
120 * @short Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an
123 virtual void item(const Item &item) = 0;
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
131 * @see whitespaceOnly()
133 virtual void characters(const QString &value) = 0;
136 * This function may be called instead of characters() if, and only if,
137 * @p value consists only of whitespace.
139 * The caller gurantees that @p value, is not empty.
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.
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().
153 virtual void whitespaceOnly(const QStringRef &value);
156 * Start of a document node.
158 virtual void startDocument() = 0;
161 * End of a document node.
163 virtual void endDocument() = 0;
167 * Treats @p outputItem as an node and calls the appropriate function,
168 * such as attribute() or comment(), depending on its QXmlNodeModelIndex::NodeKind.
170 * This a helper function sub-classes can use to multi-plex Nodes received
173 * @param outputItem must be a QXmlNodeModelIndex.
175 void sendAsNode(const Item &outputItem);
179 * Call sendAsNode() for each child of @p node. As consistent with the
180 * XPath Data Model, this does not include attribute nodes.
182 template<const QXmlNodeModelIndex::Axis axis>
183 inline void sendFromAxis(const QXmlNodeModelIndex &node);
184 Q_DISABLE_COPY(QAbstractXmlReceiver)