1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
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 The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef PatternistSDK_DebugExpressionFactory_H
30#define PatternistSDK_DebugExpressionFactory_H
31
32#include "Global.h"
33#include <private/qexpressionfactory_p.h>
34#include <private/qfunctionfactory_p.h>
35
36QT_BEGIN_NAMESPACE
37
38namespace QPatternistSDK
39{
40 class ASTItem;
41
42 /**
43 * @short Is a QPatternist::ExpressionFactory, with the
44 * difference that it provides the hooks for building from a tree of
45 * debug data from the compiled expression.
46 *
47 * This tree can be retrieved via astTree(). The astTree() function
48 * returns the AST built the last time createExpression() was called.
49 *
50 * @ingroup PatternistSDK
51 * @author Frans Englich <frans.englich@nokia.com>
52 */
53 class DebugExpressionFactory : public QPatternist::ExpressionFactory
54 {
55 public:
56 DebugExpressionFactory() : m_ast(0)
57 {
58 }
59
60 typedef QExplicitlySharedDataPointer<DebugExpressionFactory> Ptr;
61 /**
62 * Identical to ExpressionFactory::createExpression() with the difference
63 * that it builds an ASTItem tree which can be accessed via astTree().
64 */
65 virtual QPatternist::Expression::Ptr createExpression(QIODevice *const expr,
66 const QPatternist::StaticContext::Ptr &context,
67 const QXmlQuery::QueryLanguage lang,
68 const QPatternist::SequenceType::Ptr &requiredType,
69 const QUrl &queryURI,
70 const QXmlName &initialTemplateName);
71
72 /**
73 * @returns an ASTItem tree built for the last created expression,
74 * via createExpression().
75 */
76 virtual ASTItem *astTree() const;
77
78 /**
79 * @returns a list containing string representations of all available
80 * functions in Patternist. Each QString in the returned QStringList
81 * is a function synopsis for human consumption.
82 */
83 static QStringList availableFunctionSignatures();
84
85 protected:
86 /**
87 * Performs the ASTItem tree building.
88 */
89 virtual void processTreePass(const QPatternist::Expression::Ptr &tree,
90 const CompilationStage stage);
91
92 void processTemplateRule(const QPatternist::Expression::Ptr &body,
93 const QPatternist::TemplatePattern::Ptr &pattern,
94 const QXmlName &mode,
95 const TemplateCompilationStage stage);
96
97 void processNamedTemplate(const QXmlName &name,
98 const QPatternist::Expression::Ptr &body,
99 const TemplateCompilationStage stage);
100 private:
101 static ASTItem *buildASTTree(const QPatternist::Expression::Ptr &expr,
102 ASTItem *const parent,
103 const QPatternist::SequenceType::Ptr &reqType);
104 ASTItem *m_ast;
105 };
106}
107
108QT_END_NAMESPACE
109
110#endif
111// vim: et:ts=4:sw=4:sts=4
112

source code of qtxmlpatterns/tests/auto/xmlpatternssdk/DebugExpressionFactory.h