Qt 4.8
qstackcontextbase.cpp
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 
48 template<typename TSuperClass>
50  m_expressionVariables(10),
51  m_positionIterators(5),
52  m_itemCacheCells(5),
53  m_itemSequenceCacheCells(5)
54 {
55  /* The m_* containers are initialized with default sizes. Estimated guesses on usage patterns. */
56 }
57 
58 template<typename TSuperClass>
60  : TSuperClass(prevContext),
61  m_rangeVariables(10),
62  m_expressionVariables(10),
63  m_positionIterators(5),
64  m_itemCacheCells(5),
65  m_itemSequenceCacheCells(5)
66 {
67  Q_ASSERT(prevContext);
68 }
69 
70 template<typename TSuperClass>
72 {
73  if(slot >= m_itemCacheCells.size())
74  m_itemCacheCells.resize(qMax(slot + 1, m_itemCacheCells.size()));
75 
76  return m_itemCacheCells[slot];
77 }
78 
79 template<typename TSuperClass>
81 {
82  if(slot >= m_itemSequenceCacheCells.size())
83  m_itemSequenceCacheCells.resize(qMax(slot + 1, m_itemSequenceCacheCells.size()));
84 
85  return m_itemSequenceCacheCells;
86 }
87 
88 template<typename TSuperClass>
90 {
91  Q_ASSERT(slot < m_rangeVariables.size());
92  Q_ASSERT(m_rangeVariables.at(slot));
93  return m_rangeVariables.at(slot);
94 }
95 
96 template<typename TSuperClass>
98 {
99  Q_ASSERT(slot < m_expressionVariables.size());
100  Q_ASSERT(m_expressionVariables.at(slot));
101  return m_expressionVariables.at(slot);
102 }
103 
104 template<typename TSuperClass>
106 {
107  Q_ASSERT(slot < m_positionIterators.size());
108  return m_positionIterators.at(slot);
109 }
110 
111 template<typename TSuperClass>
112 template<typename VectorType, typename UnitType>
113 inline
115  const UnitType &newValue,
116  VectorType &container) const
117 {
118  if(slot < container.size())
119  container.replace(slot, newValue);
120  else
121  {
122  container.resize(slot + 1);
123  container.replace(slot, newValue);
124  }
125 }
126 
127 template<typename TSuperClass>
129  const Item &newValue)
130 {
131  setSlotVariable(slot, newValue, m_rangeVariables);
132 }
133 
134 template<typename TSuperClass>
136  const Expression::Ptr &newValue)
137 {
138  setSlotVariable(slot, newValue, m_expressionVariables);
139 }
140 
141 template<typename TSuperClass>
143  const Item::Iterator::Ptr &newValue)
144 {
145  setSlotVariable(slot, newValue, m_positionIterators);
146 }
147 
148 template<typename TSuperClass>
150 {
151  return m_templateParameterStore;
152 }
153 
qint32 VariableSlotID
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
Base class for all DynamicContext classes that needs to supply variables. It has a new frame for loca...
Represents a cache entry for a single Item, as opposed to for a sequence of items.
Definition: qcachecells_p.h:81
Represents an item in the XPath 2.0 Data Model.
Definition: qitem_p.h:182