/tests/auto/xmlpatternssdk/DebugExpressionFactory.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 128 lines · 45 code · 15 blank · 68 comment · 0 complexity · 8515962321c6dc928c19ad30c96b8f25 MD5 · raw file

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