Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

VariablesStack.hpp

Go to the documentation of this file.
00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(XALAN_VARIABLESSTACK_HEADER_GUARD) 00017 #define XALAN_VARIABLESSTACK_HEADER_GUARD 00018 00019 00020 00021 // Base include file. Must be first. 00022 #include <xalanc/XSLT/XSLTDefinitions.hpp> 00023 00024 00025 00026 #include <cassert> 00027 #include <vector> 00028 00029 00030 00031 #include <xalanc/XPath/XalanQName.hpp> 00032 #include <xalanc/XPath/XObject.hpp> 00033 00034 00035 00036 #include <xalanc/XSLT/XSLTProcessorException.hpp> 00037 00038 00039 00040 XALAN_CPP_NAMESPACE_BEGIN 00041 00042 00043 00044 class Arg; 00045 class ElemTemplateElement; 00046 class ElemVariable; 00047 class StylesheetExecutionContext; 00048 class XalanNode; 00049 00050 00051 00055 class XALAN_XSLT_EXPORT VariablesStack 00056 { 00057 public: 00058 00059 typedef unsigned long size_type; 00060 00064 explicit 00065 VariablesStack(); 00066 00067 ~VariablesStack(); 00068 00072 void 00073 reset(); 00074 00080 void 00081 pushElementFrame(const ElemTemplateElement* elem); 00082 00088 void 00089 popElementFrame(); 00090 00098 void 00099 pushContextMarker(); 00100 00104 void 00105 popContextMarker(); 00106 00107 struct ParamsVectorEntry 00108 { 00109 ParamsVectorEntry() : 00110 m_qname(0), 00111 m_value(), 00112 m_variable(0) 00113 { 00114 } 00115 00116 ParamsVectorEntry( 00117 const XalanQName* qname, 00118 const XObjectPtr value) : 00119 m_qname(qname), 00120 m_value(value), 00121 m_variable(0) 00122 { 00123 } 00124 00125 ParamsVectorEntry( 00126 const XalanQName* qname, 00127 const ElemVariable* variable) : 00128 m_qname(qname), 00129 m_value(), 00130 m_variable(variable) 00131 { 00132 } 00133 00134 const XalanQName* m_qname; 00135 00136 XObjectPtr m_value; 00137 00138 const ElemVariable* m_variable; 00139 }; 00140 00141 #if defined(XALAN_NO_STD_NAMESPACE) 00142 typedef vector<ParamsVectorEntry> ParamsVectorType; 00143 typedef vector<const ElemVariable*> RecursionGuardStackType; 00144 typedef vector<const ElemTemplateElement*> ElemTemplateElementStackType; 00145 #else 00146 typedef std::vector<ParamsVectorEntry> ParamsVectorType; 00147 typedef std::vector<const ElemVariable*> RecursionGuardStackType; 00148 typedef std::vector<const ElemTemplateElement*> ElemTemplateElementStackType; 00149 #endif 00150 00157 void 00158 pushParams(const ParamsVectorType& theParams); 00159 00170 const XObjectPtr 00171 getParamVariable( 00172 const XalanQName& qname, 00173 StylesheetExecutionContext& executionContext, 00174 bool& fNameFound) 00175 { 00176 return findXObject(qname, executionContext, true, false, fNameFound); 00177 } 00178 00190 const XObjectPtr 00191 getVariable( 00192 const XalanQName& qname, 00193 StylesheetExecutionContext& executionContext, 00194 bool& fNameFound) 00195 { 00196 return findXObject(qname, executionContext, false, true, fNameFound); 00197 } 00198 00208 void 00209 pushVariable( 00210 const XalanQName& name, 00211 const ElemVariable* var, 00212 const ElemTemplateElement* e); 00213 00223 void 00224 pushVariable( 00225 const XalanQName& name, 00226 const XObjectPtr& val, 00227 const ElemTemplateElement* e); 00228 00232 void 00233 start(); 00234 00238 void 00239 resetParams(); 00240 00244 void 00245 markGlobalStackFrame(); 00246 00250 void 00251 unmarkGlobalStackFrame(); 00252 00260 void 00261 setCurrentStackFrameIndex(size_type currentStackFrameIndex = ~0u) 00262 { 00263 if (currentStackFrameIndex == ~0u) 00264 { 00265 assert(size_type(m_stack.size()) == m_stack.size()); 00266 00267 m_currentStackFrameIndex = size_type(m_stack.size()); 00268 } 00269 else 00270 { 00271 m_currentStackFrameIndex = currentStackFrameIndex; 00272 } 00273 } 00274 00281 size_type 00282 getCurrentStackFrameIndex() const 00283 { 00284 return m_currentStackFrameIndex; 00285 } 00286 00292 size_type 00293 getGlobalStackFrameIndex() const 00294 { 00295 return m_globalStackFrameIndex; 00296 } 00297 00298 class InvalidStackContextException : public XSLTProcessorException 00299 { 00300 public: 00301 00302 InvalidStackContextException(); 00303 00304 virtual 00305 ~InvalidStackContextException(); 00306 00307 private: 00308 00309 }; 00310 00311 class PushParamFunctor 00312 { 00313 public: 00314 00315 PushParamFunctor(VariablesStack& theVariablesStack) : 00316 m_variablesStack(theVariablesStack) 00317 { 00318 } 00319 00320 void 00321 operator()(const ParamsVectorType::value_type& theEntry) const; 00322 00323 private: 00324 00325 VariablesStack& m_variablesStack; 00326 }; 00327 00328 class XALAN_XSLT_EXPORT StackEntry 00329 { 00330 public: 00331 00336 enum eType { eContextMarker, 00337 eVariable, 00338 eParam, 00339 eActiveParam, 00340 eElementFrameMarker, 00341 eNextValue }; 00342 00346 explicit 00347 StackEntry(); 00348 00352 StackEntry( 00353 const XalanQName* name, 00354 const XObjectPtr& val, 00355 bool isParam = false); 00356 00360 StackEntry( 00361 const XalanQName* name, 00362 const ElemVariable* var, 00363 bool isParam = false); 00364 00368 StackEntry(const ElemTemplateElement* elem); 00369 00370 00374 StackEntry(const StackEntry& theSource); 00375 00379 ~StackEntry(); 00380 00386 eType 00387 getType() const 00388 { 00389 return m_type; 00390 } 00391 00397 const XalanQName* 00398 getName() const 00399 { 00400 return m_qname; 00401 } 00402 00408 const XObjectPtr& 00409 getValue() const 00410 { 00411 return m_value; 00412 } 00413 00419 void 00420 setValue(const XObjectPtr& theValue) 00421 { 00422 m_value = theValue; 00423 } 00424 00430 const ElemVariable* 00431 getVariable() const 00432 { 00433 return m_variable; 00434 } 00435 00436 void 00437 activate(); 00438 00439 void 00440 deactivate(); 00441 00447 const ElemTemplateElement* 00448 getElement() const 00449 { 00450 return m_element; 00451 } 00452 00453 StackEntry& 00454 operator=(const StackEntry& theRHS); 00455 00456 bool 00457 operator==(const StackEntry& theRHS) const; 00458 00459 private: 00460 00461 // Data members... 00462 eType m_type; 00463 00464 const XalanQName* m_qname; 00465 00466 XObjectPtr m_value; 00467 00468 const ElemVariable* m_variable; 00469 00470 const ElemTemplateElement* m_element; 00471 }; 00472 00473 #if defined(XALAN_NO_STD_NAMESPACE) 00474 typedef vector<StackEntry> VariableStackStackType; 00475 #else 00476 typedef std::vector<StackEntry> VariableStackStackType; 00477 #endif 00478 00479 size_type 00480 getStackSize() const 00481 { 00482 return size_type(m_stack.size()); 00483 } 00484 00485 enum { eDefaultStackSize = 100 }; 00486 00487 private: 00488 00489 class CommitPushParams 00490 { 00491 public: 00492 00493 CommitPushParams(VariablesStack& theVariablesStack); 00494 00495 ~CommitPushParams(); 00496 00497 void 00498 commit() 00499 { 00500 m_variablesStack = 0; 00501 } 00502 00503 private: 00504 00505 VariablesStack* m_variablesStack; 00506 00507 size_type m_stackSize; 00508 }; 00509 00510 friend class CommitPushParams; 00511 00519 bool 00520 elementFrameAlreadyPushed(const ElemTemplateElement* elem) const; 00521 00527 void 00528 push(const StackEntry& theEntry); 00529 00533 void 00534 pop(); 00535 00541 const StackEntry& 00542 back() const 00543 { 00544 assert(m_stack.empty() == false); 00545 00546 return m_stack.back(); 00547 } 00548 00549 friend class CommitPushElementFrame; 00550 friend class EnsurePop; 00551 friend class PushParamFunctor; 00552 friend class SetAndRestoreForceGlobalSearch; 00553 00554 const XObjectPtr 00555 findXObject( 00556 const XalanQName& name, 00557 StylesheetExecutionContext& executionContext, 00558 bool fIsParam, 00559 bool fSearchGlobalSpace, 00560 bool& fNameFound); 00561 00562 size_type 00563 findEntry( 00564 const XalanQName& name, 00565 bool fIsParam, 00566 bool fSearchGlobalSpace); 00567 00568 00569 VariableStackStackType m_stack; 00570 00571 size_type m_globalStackFrameIndex; 00572 00573 bool m_globalStackFrameMarked; 00574 00580 size_type m_currentStackFrameIndex; 00581 00587 RecursionGuardStackType m_guardStack; 00588 00593 ElemTemplateElementStackType m_elementFrameStack; 00594 }; 00595 00596 00597 00598 XALAN_CPP_NAMESPACE_END 00599 00600 00601 00602 #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.

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