Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

VariablesStack.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XALAN_VARIABLESSTACK_HEADER_GUARD)
17 #define XALAN_VARIABLESSTACK_HEADER_GUARD
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
26 #include <cassert>
27 
28 
29 
31 
32 
33 
35 #include <xalanc/XPath/XObject.hpp>
36 
37 
38 
40 
41 
42 
43 XALAN_CPP_NAMESPACE_BEGIN
44 
45 
46 
47 class Arg;
49 class ElemVariable;
51 class XalanNode;
52 
53 
54 
59 {
60 public:
61 
62  typedef unsigned long size_type;
63 
67  explicit
68  VariablesStack(MemoryManagerType& theManager);
69 
70  ~VariablesStack();
71 
75  void
76  reset();
77 
83  void
84  pushElementFrame(const ElemTemplateElement* elem);
85 
91  void
92  popElementFrame();
93 
101  void
102  pushContextMarker();
103 
107  void
108  popContextMarker();
109 
111  {
113  m_qname(0),
114  m_value(),
115  m_variable(0)
116  {
117  }
118 
120  const XalanQName* qname,
121  const XObjectPtr value) :
122  m_qname(qname),
123  m_value(value),
124  m_variable(0)
125  {
126  }
127 
129  const XalanQName* qname,
130  const ElemVariable* variable) :
131  m_qname(qname),
132  m_value(),
133  m_variable(variable)
134  {
135  }
136 
138 
140 
142  };
143 
147 
154  void
155  pushParams(const ParamsVectorType& theParams);
156 
167  const XObjectPtr
168  getParamVariable(
169  const XalanQName& qname,
170  StylesheetExecutionContext& executionContext,
171  bool& fNameFound)
172  {
173  return findXObject(qname, executionContext, true, false, fNameFound);
174  }
175 
187  const XObjectPtr
188  getVariable(
189  const XalanQName& qname,
190  StylesheetExecutionContext& executionContext,
191  bool& fNameFound)
192  {
193  return findXObject(qname, executionContext, false, true, fNameFound);
194  }
195 
205  void
206  pushVariable(
207  const XalanQName& name,
208  const ElemVariable* var,
209  const ElemTemplateElement* e);
210 
220  void
221  pushVariable(
222  const XalanQName& name,
223  const XObjectPtr& val,
224  const ElemTemplateElement* e);
225 
229  void
230  start();
231 
235  void
236  resetParams();
237 
241  void
242  markGlobalStackFrame();
243 
247  void
248  unmarkGlobalStackFrame();
249 
257  void
258  setCurrentStackFrameIndex(size_type currentStackFrameIndex = ~0u)
259  {
260  if (currentStackFrameIndex == ~0u)
261  {
262  assert(size_type(m_stack.size()) == m_stack.size());
263 
264  m_currentStackFrameIndex = size_type(m_stack.size());
265  }
266  else
267  {
268  m_currentStackFrameIndex = currentStackFrameIndex;
269  }
270  }
271 
278  size_type
279  getCurrentStackFrameIndex() const
280  {
281  return m_currentStackFrameIndex;
282  }
283 
289  size_type
290  getGlobalStackFrameIndex() const
291  {
292  return m_globalStackFrameIndex;
293  }
294 
296  {
297  public:
298 
300 
301  virtual
303 
304 
305  virtual const XalanDOMChar*
306  getType() const
307  {
308  return m_type;
309  }
310 
311  private:
312 
313  static const XalanDOMChar m_type[];
314 
315  };
316 
318  {
319  public:
320 
321  PushParamFunctor(VariablesStack& theVariablesStack) :
322  m_variablesStack(theVariablesStack)
323  {
324  }
325 
326  void
327  operator()(const ParamsVectorType::value_type& theEntry) const;
328 
329  private:
330 
331  VariablesStack& m_variablesStack;
332  };
333 
335  {
336  public:
337 
342  enum eType { eContextMarker,
347  eNextValue };
348 
352  explicit
353  StackEntry();
354 
358  StackEntry(
359  const XalanQName* name,
360  const XObjectPtr& val,
361  bool isParam = false);
362 
366  StackEntry(
367  const XalanQName* name,
368  const ElemVariable* var,
369  bool isParam = false);
370 
374  StackEntry(const ElemTemplateElement* elem);
375 
376 
380  StackEntry(const StackEntry& theSource);
381 
385  ~StackEntry();
386 
392  eType
393  getType() const
394  {
395  return m_type;
396  }
397 
403  const XalanQName*
404  getName() const
405  {
406  return m_qname;
407  }
408 
414  const XObjectPtr&
415  getValue() const
416  {
417  return m_value;
418  }
419 
425  void
426  setValue(const XObjectPtr& theValue)
427  {
428  m_value = theValue;
429  }
430 
436  const ElemVariable*
437  getVariable() const
438  {
439  return m_variable;
440  }
441 
442  void
443  activate();
444 
445  void
446  deactivate();
447 
453  const ElemTemplateElement*
454  getElement() const
455  {
456  return m_element;
457  }
458 
459  StackEntry&
460  operator=(const StackEntry& theRHS);
461 
462  bool
463  operator==(const StackEntry& theRHS) const;
464 
465  private:
466 
467  // Data members...
468  eType m_type;
469 
470  const XalanQName* m_qname;
471 
472  XObjectPtr m_value;
473 
474  const ElemVariable* m_variable;
475 
476  const ElemTemplateElement* m_element;
477  };
478 
480 
481  size_type
482  getStackSize() const
483  {
484  return size_type(m_stack.size());
485  }
486 
487  enum { eDefaultStackSize = 100 };
488 
489 private:
490 
491  class CommitPushParams
492  {
493  public:
494 
495  CommitPushParams(VariablesStack& theVariablesStack);
496 
497  ~CommitPushParams();
498 
499  void
500  commit()
501  {
502  m_variablesStack = 0;
503  }
504 
505  private:
506 
507  VariablesStack* m_variablesStack;
508 
509  size_type m_stackSize;
510  };
511 
512  friend class CommitPushParams;
513 
521  bool
522  elementFrameAlreadyPushed(const ElemTemplateElement* elem) const;
523 
529  void
530  push(const StackEntry& theEntry);
531 
535  void
536  pop();
537 
543  const StackEntry&
544  back() const
545  {
546  assert(m_stack.empty() == false);
547 
548  return m_stack.back();
549  }
550 
551  friend class CommitPushElementFrame;
552  friend class EnsurePop;
553  friend class PushParamFunctor;
554  friend class SetAndRestoreForceGlobalSearch;
555 
556  const XObjectPtr
557  findXObject(
558  const XalanQName& name,
559  StylesheetExecutionContext& executionContext,
560  bool fIsParam,
561  bool fSearchGlobalSpace,
562  bool& fNameFound);
563 
564  size_type
565  findEntry(
566  const XalanQName& name,
567  bool fIsParam,
568  bool fSearchGlobalSpace);
569 
570 
571  VariableStackStackType m_stack;
572 
573  size_type m_globalStackFrameIndex;
574 
575  bool m_globalStackFrameMarked;
576 
582  size_type m_currentStackFrameIndex;
583 
589  RecursionGuardStackType m_guardStack;
590 
595  ElemTemplateElementStackType m_elementFrameStack;
596 };
597 
598 
599 
600 XALAN_CPP_NAMESPACE_END
601 
602 
603 
604 #endif // #if !defined(XALAN_VARIABLESSTACK_HEADER_GUARD)

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo