/src/xmlpatterns/functions/qnodefns_p.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 176 lines · 52 code · 18 blank · 106 comment · 0 complexity · 96881fad88db85bef7eea607a7fb2388 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 QtXmlPatterns module 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. //
  42. // W A R N I N G
  43. // -------------
  44. //
  45. // This file is not part of the Qt API. It exists purely as an
  46. // implementation detail. This header file may change from version to
  47. // version without notice, or even be removed.
  48. //
  49. // We mean it.
  50. #ifndef Patternist_NodeFNs_H
  51. #define Patternist_NodeFNs_H
  52. #include "qfunctioncall_p.h"
  53. #include "qcastingplatform_p.h"
  54. /**
  55. * @file
  56. * @short Contains classes implementing the functions found in
  57. * <a href="http://www.w3.org/TR/xpath-functions/#node-functions">XQuery 1.0 and
  58. * XPath 2.0 Functions and Operators, 14 Functions and Operators on Nodes</a>.
  59. *
  60. * @ingroup Patternist_functions
  61. */
  62. QT_BEGIN_HEADER
  63. QT_BEGIN_NAMESPACE
  64. namespace QPatternist
  65. {
  66. /**
  67. * @short Implements the function <tt>fn:name()</tt>.
  68. *
  69. * @ingroup Patternist_functions
  70. * @author Frans Englich <frans.englich@nokia.com>
  71. */
  72. class NameFN : public FunctionCall
  73. {
  74. public:
  75. virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
  76. };
  77. /**
  78. * @short Implements the function <tt>fn:local-name()</tt>.
  79. *
  80. * @ingroup Patternist_functions
  81. * @author Frans Englich <frans.englich@nokia.com>
  82. */
  83. class LocalNameFN : public FunctionCall
  84. {
  85. public:
  86. virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
  87. };
  88. /**
  89. * @short Implements the function <tt>fn:namespace-uri()</tt>.
  90. *
  91. * @ingroup Patternist_functions
  92. * @author Frans Englich <frans.englich@nokia.com>
  93. */
  94. class NamespaceURIFN : public FunctionCall
  95. {
  96. public:
  97. virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
  98. };
  99. /**
  100. * @short Implements the function <tt>fn:number()</tt>.
  101. *
  102. * NumberFN uses CastingPlatform for performing the actual casting.
  103. *
  104. * @ingroup Patternist_functions
  105. * @author Frans Englich <frans.englich@nokia.com>
  106. */
  107. class NumberFN : public FunctionCall,
  108. public CastingPlatform<NumberFN, false>
  109. {
  110. public:
  111. virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
  112. /**
  113. * Overridden in order to call CastingPlatform::prepareCasting(). It also
  114. * implements the optimization of rewriting to its operand if its
  115. * type is xs:double(since the <tt>fn:number()</tt> call is in that case superflorous).
  116. */
  117. virtual Expression::Ptr typeCheck(const StaticContext::Ptr &context,
  118. const SequenceType::Ptr &reqType);
  119. /**
  120. * @returns always BuiltinTypes::xsDouble.
  121. */
  122. inline ItemType::Ptr targetType() const
  123. {
  124. return BuiltinTypes::xsDouble;
  125. }
  126. };
  127. /**
  128. * @short Implements the function <tt>fn:lang()</tt>.
  129. *
  130. * @ingroup Patternist_functions
  131. * @author Frans Englich <frans.englich@nokia.com>
  132. */
  133. class LangFN : public FunctionCall
  134. {
  135. public:
  136. virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
  137. private:
  138. static inline bool isLangMatch(const QString &candidate, const QString &toMatch);
  139. };
  140. /**
  141. * @short Implements the function <tt>fn:root()</tt>.
  142. *
  143. * @ingroup Patternist_functions
  144. * @author Frans Englich <frans.englich@nokia.com>
  145. */
  146. class RootFN : public FunctionCall
  147. {
  148. public:
  149. virtual Item evaluateSingleton(const DynamicContext::Ptr &context) const;
  150. /**
  151. * Infers its cardinality from the argument.
  152. */
  153. virtual SequenceType::Ptr staticType() const;
  154. };
  155. }
  156. QT_END_NAMESPACE
  157. QT_END_HEADER
  158. #endif