Qt 4.8
qacceltreebuilder_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_AccelTreeBuilder_H
53 #define Patternist_AccelTreeBuilder_H
54 
55 #include <QSet>
56 #include <QStack>
57 
58 #include "private/qxmlutils_p.h"
59 #include "qacceltree_p.h"
60 #include "qbuiltintypes_p.h"
62 #include "qnamepool_p.h"
63 #include "qnodebuilder_p.h"
64 #include "qreportcontext_p.h"
66 #include "qpatternistlocale_p.h"
67 #include <QtDebug>
68 
70 
72 
73 namespace QPatternist
74 {
85  template<bool FromDocument>
86  class AccelTreeBuilder : public NodeBuilder
87  , public SourceLocationReflection
88  {
89  public:
91 
95  enum Feature
96  {
99  };
100  Q_DECLARE_FLAGS(Features, Feature)
101 
102 
105  AccelTreeBuilder(const QUrl &docURI,
106  const QUrl &baseURI,
107  const NamePool::Ptr &np,
108  ReportContext *const context,
109  Features features = NoneFeature);
110  virtual void startDocument();
111  virtual void endDocument();
112  virtual void startElement(const QXmlName &name);
113  void startElement(const QXmlName &name, qint64 line, qint64 column);
114  virtual void endElement();
115  virtual void attribute(const QXmlName &name, const QStringRef &value);
116  virtual void characters(const QStringRef &ch);
117  virtual void whitespaceOnly(const QStringRef &ch);
118  virtual void processingInstruction(const QXmlName &target,
119  const QString &data);
120  virtual void namespaceBinding(const QXmlName &nb);
121  virtual void comment(const QString &content);
122  virtual void item(const Item &it);
123 
125  virtual NodeBuilder::Ptr create(const QUrl &baseURI) const;
126  virtual void startOfSequence();
127  virtual void endOfSequence();
128 
130  {
131  return m_document;
132  }
133 
134  virtual void atomicValue(const QVariant &value);
135 
136  virtual const SourceLocationReflection *actualReflection() const;
137  virtual QSourceLocation sourceLocation() const;
138 
139  private:
140  inline void startStructure();
141 
143  {
144  return m_ancestors.count() -1;
145  }
146 
148  {
149  return m_ancestors.isEmpty() ? -1 : m_ancestors.top();
150  }
151 
153  {
156  };
157 
171 
177 
190 
191  Features m_features;
192  };
193 
196 
197 #include "qacceltreebuilder.cpp"
198 }
199 
201 
203 
204 #endif
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QStack< AccelTree::PreNumber > m_ancestors
virtual NodeBuilder::Ptr create(const QUrl &baseURI) const
Creates a copy of this NodeBuilder, that operates independently of this NodeBuilder.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
The accel tree builder will store source locations for each start element.
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
#define it(className, varName)
virtual QAbstractXmlNodeModel::Ptr builtDocument()
Returns the document that has been built.
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
virtual void whitespaceOnly(const QStringRef &ch)
Builds an AccelTree from a stream of XML/Item events received through the NodeBuilder interface...
Definition: qacceltree_p.h:69
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
AccelTreeBuilder(const QUrl &docURI, const QUrl &baseURI, const NamePool::Ptr &np, ReportContext *const context, Features features=NoneFeature)
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
virtual void startElement(const QXmlName &name)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
const char * name
virtual void namespaceBinding(const QXmlName &nb)
Signals the presence of the namespace declaration nb.
The namespace for the internal API of QtXmlPatterns.
QExplicitlySharedDataPointer< AccelTreeBuilder > Ptr
virtual void processingInstruction(const QXmlName &target, const QString &data)
The QSourceLocation class identifies a location in a resource by URI, line, and column.
static const char * data(const QByteArray &arr)
virtual const SourceLocationReflection * actualReflection() const
AccelTree::PreNumber m_skippedDocumentNodes
virtual void atomicValue(const QVariant &value)
__int64 qint64
Definition: qglobal.h:942
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
virtual void comment(const QString &content)
The QXmlName class represents the name of an XML node, in an efficient, namespace-aware way...
Definition: qxmlname.h:58
QStack< AccelTree::PreNumber > m_size
Contains functions used for formatting arguments, such as keywords and paths, in translated strings...
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182
virtual void endElement()
Signals the end of the current element.
virtual void attribute(const QXmlName &name, const QStringRef &value)
virtual void characters(const QStringRef &ch)
virtual void item(const Item &it)
Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an AtomicValue...
AccelTree::Ptr builtDocument() const
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
Definition: qvector.h:139
A callback for reporting errors.
virtual QSourceLocation sourceLocation() const
AccelTree::PreNumber currentDepth() const
#define QT_END_HEADER
Definition: qglobal.h:137
AccelTree::PreNumber currentParent() const
No special features are enabled.
Base class for all instances that represents something at a certain location.
T & top()
Returns a reference to the stack&#39;s top item.
Definition: qstack.h:72