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 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 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 Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 // 41 // W A R N I N G 42 // ------------- 43 // 44 // This file is not part of the Qt API. It exists purely as an 45 // implementation detail. This header file may change from version to 46 // version without notice, or even be removed. 47 // 48 // We mean it. 49 50 #ifndef Patternist_qtokenvalue_p_H 51 #define Patternist_qtokenvalue_p_H 52 53 #include <QPair> 54 #include <QString> 55 #include <QList> 56 57 #include <private/qatomiccomparator_p.h> 58 #include <private/qatomicmathematician_p.h> 59 #include <private/qcombinenodes_p.h> 60 #include <private/qexpression_p.h> 61 #include <private/qfunctionargument_p.h> 62 #include <private/qorderby_p.h> 63 #include <private/qpath_p.h> 64 #include <private/qvalidate_p.h> 65 66 /** 67 * @file 68 * @short Contains functions and classes used by the parser and tokenizer. 69 */ 70 71 QT_BEGIN_NAMESPACE 72 73 namespace QPatternist 74 { 75 /** 76 * @short A union of all the enums the parser uses. 77 */ 78 union EnumUnion 79 { 80 AtomicComparator::Operator valueOperator; 81 AtomicMathematician::Operator mathOperator; 82 CombineNodes::Operator combinedNodeOp; 83 QXmlNodeModelIndex::Axis axis; 84 QXmlNodeModelIndex::DocumentOrder nodeOperator; 85 StaticContext::BoundarySpacePolicy boundarySpacePolicy; 86 StaticContext::ConstructionMode constructionMode; 87 StaticContext::OrderingEmptySequence orderingEmptySequence; 88 StaticContext::OrderingMode orderingMode; 89 OrderBy::OrderSpec::Direction sortDirection; 90 Validate::Mode validationMode; 91 VariableSlotID slot; 92 int tokenizerPosition; 93 qint16 zeroer; 94 bool Bool; 95 xsDouble Double; 96 Path::Kind pathKind; 97 }; 98 99 typedef QPair<QString, Expression::Ptr> AttributeHolder; 100 typedef QVector<AttributeHolder> AttributeHolderVector; 101 102 class OrderSpecTransfer 103 { 104 public: 105 typedef QList<OrderSpecTransfer> List; OrderSpecTransfer()106 inline OrderSpecTransfer() 107 { 108 } 109 OrderSpecTransfer(const Expression::Ptr & aExpr,const OrderBy::OrderSpec aOrderSpec)110 inline OrderSpecTransfer(const Expression::Ptr &aExpr, 111 const OrderBy::OrderSpec aOrderSpec) : expression(aExpr), 112 orderSpec(aOrderSpec) 113 { 114 Q_ASSERT(expression); 115 } 116 117 Expression::Ptr expression; 118 OrderBy::OrderSpec orderSpec; 119 }; 120 121 /** 122 * @short The value the parser, but not the tokenizers, uses for tokens and 123 * non-terminals. 124 * 125 * It is inefficient but ensures nothing leaks, by invoking C++ 126 * destructors even in the cases the code throws exceptions. This might be 127 * able to be done in a more efficient way -- suggestions are welcome. 128 */ 129 class TokenValue 130 { 131 public: 132 QString sval; 133 134 Expression::Ptr expr; 135 Expression::List expressionList; 136 137 Cardinality cardinality; 138 ItemType::Ptr itemType; 139 SequenceType::Ptr sequenceType; 140 FunctionArgument::List functionArguments; 141 FunctionArgument::Ptr functionArgument; 142 QVector<QXmlName> qNameVector; 143 QXmlName qName; 144 /** 145 * Holds enum values. 146 */ 147 EnumUnion enums; 148 149 AttributeHolder attributeHolder; 150 AttributeHolderVector attributeHolders; 151 OrderSpecTransfer::List orderSpecs; 152 OrderSpecTransfer orderSpec; 153 }; 154 } 155 156 struct XPATHLTYPE 157 { 158 int first_line; 159 int first_column; 160 int last_line; 161 int last_column; 162 }; 163 #ifndef XPATHLTYPE_IS_DECLARED 164 # define XPATHLTYPE_IS_DECLARED 165 #endif 166 167 QT_END_NAMESPACE 168 169 #endif // Patternist_qtokenvalue_p_H 170