00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-2004 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(XALAN_VARIABLESSTACK_HEADER_GUARD) 00058 #define XALAN_VARIABLESSTACK_HEADER_GUARD 00059 00060 00061 00062 // Base include file. Must be first. 00063 #include <xalanc/XSLT/XSLTDefinitions.hpp> 00064 00065 00066 00067 #include <cassert> 00068 #include <vector> 00069 00070 00071 00072 #include <xalanc/XPath/XalanQName.hpp> 00073 #include <xalanc/XPath/XObject.hpp> 00074 00075 00076 00077 #include <xalanc/XSLT/XSLTProcessorException.hpp> 00078 00079 00080 00081 XALAN_CPP_NAMESPACE_BEGIN 00082 00083 00084 00085 class Arg; 00086 class ElemTemplateElement; 00087 class ElemVariable; 00088 class StylesheetExecutionContext; 00089 class XalanNode; 00090 00091 00092 00096 class XALAN_XSLT_EXPORT VariablesStack 00097 { 00098 public: 00099 00103 explicit 00104 VariablesStack(); 00105 00106 ~VariablesStack(); 00107 00108 00112 void 00113 reset(); 00114 00120 void 00121 pushElementFrame(const ElemTemplateElement* elem); 00122 00128 void 00129 popElementFrame(); 00130 00138 void 00139 pushContextMarker(); 00140 00144 void 00145 popContextMarker(); 00146 00147 struct ParamsVectorEntry 00148 { 00149 ParamsVectorEntry() : 00150 m_qname(0), 00151 m_value(), 00152 m_variable(0) 00153 { 00154 } 00155 00156 ParamsVectorEntry( 00157 const XalanQName* qname, 00158 const XObjectPtr value) : 00159 m_qname(qname), 00160 m_value(value), 00161 m_variable(0) 00162 { 00163 } 00164 00165 ParamsVectorEntry( 00166 const XalanQName* qname, 00167 const ElemVariable* variable) : 00168 m_qname(qname), 00169 m_value(), 00170 m_variable(variable) 00171 { 00172 } 00173 00174 const XalanQName* m_qname; 00175 00176 XObjectPtr m_value; 00177 00178 const ElemVariable* m_variable; 00179 }; 00180 00181 #if defined(XALAN_NO_STD_NAMESPACE) 00182 typedef vector<ParamsVectorEntry> ParamsVectorType; 00183 typedef vector<const ElemVariable*> RecursionGuardStackType; 00184 typedef vector<const ElemTemplateElement*> ElemTemplateElementStackType; 00185 #else 00186 typedef std::vector<ParamsVectorEntry> ParamsVectorType; 00187 typedef std::vector<const ElemVariable*> RecursionGuardStackType; 00188 typedef std::vector<const ElemTemplateElement*> ElemTemplateElementStackType; 00189 #endif 00190 00197 void 00198 pushParams(const ParamsVectorType& theParams); 00199 00210 const XObjectPtr 00211 getParamVariable( 00212 const XalanQName& qname, 00213 StylesheetExecutionContext& executionContext, 00214 bool& fNameFound) 00215 { 00216 return findXObject(qname, executionContext, true, false, fNameFound); 00217 } 00218 00230 const XObjectPtr 00231 getVariable( 00232 const XalanQName& qname, 00233 StylesheetExecutionContext& executionContext, 00234 bool& fNameFound) 00235 { 00236 return findXObject(qname, executionContext, false, true, fNameFound); 00237 } 00238 00248 void 00249 pushVariable( 00250 const XalanQName& name, 00251 const ElemVariable* var, 00252 const ElemTemplateElement* e); 00253 00263 void 00264 pushVariable( 00265 const XalanQName& name, 00266 const XObjectPtr& val, 00267 const ElemTemplateElement* e); 00268 00272 void 00273 start(); 00274 00278 void 00279 resetParams(); 00280 00284 void 00285 markGlobalStackFrame(); 00286 00290 void 00291 unmarkGlobalStackFrame(); 00292 00300 void 00301 setCurrentStackFrameIndex(int currentStackFrameIndex = -1) 00302 { 00303 if (currentStackFrameIndex == -1) 00304 m_currentStackFrameIndex = m_stack.size(); 00305 else 00306 m_currentStackFrameIndex = currentStackFrameIndex; 00307 } 00308 00315 int 00316 getCurrentStackFrameIndex() const 00317 { 00318 return m_currentStackFrameIndex; 00319 } 00320 00326 int 00327 getGlobalStackFrameIndex() const 00328 { 00329 return m_globalStackFrameIndex; 00330 } 00331 00332 class InvalidStackContextException : public XSLTProcessorException 00333 { 00334 public: 00335 00336 InvalidStackContextException(); 00337 00338 virtual 00339 ~InvalidStackContextException(); 00340 00341 private: 00342 00343 }; 00344 00345 class PushParamFunctor 00346 { 00347 public: 00348 00349 PushParamFunctor(VariablesStack& theVariablesStack) : 00350 m_variablesStack(theVariablesStack) 00351 { 00352 } 00353 00354 void 00355 operator()(const ParamsVectorType::value_type& theEntry) const; 00356 00357 private: 00358 00359 VariablesStack& m_variablesStack; 00360 }; 00361 00362 class XALAN_XSLT_EXPORT StackEntry 00363 { 00364 public: 00365 00370 enum eType { eContextMarker, 00371 eVariable, 00372 eParam, 00373 eActiveParam, 00374 eElementFrameMarker, 00375 eNextValue }; 00376 00380 explicit 00381 StackEntry(); 00382 00386 StackEntry( 00387 const XalanQName* name, 00388 const XObjectPtr& val, 00389 bool isParam = false); 00390 00394 StackEntry( 00395 const XalanQName* name, 00396 const ElemVariable* var, 00397 bool isParam = false); 00398 00402 StackEntry(const ElemTemplateElement* elem); 00403 00404 00408 StackEntry(const StackEntry& theSource); 00409 00413 ~StackEntry(); 00414 00420 eType 00421 getType() const 00422 { 00423 return m_type; 00424 } 00425 00431 const XalanQName* 00432 getName() const 00433 { 00434 return m_qname; 00435 } 00436 00442 const XObjectPtr& 00443 getValue() const 00444 { 00445 return m_value; 00446 } 00447 00453 void 00454 setValue(const XObjectPtr& theValue) 00455 { 00456 m_value = theValue; 00457 } 00458 00464 const ElemVariable* 00465 getVariable() const 00466 { 00467 return m_variable; 00468 } 00469 00470 void 00471 activate(); 00472 00473 void 00474 deactivate(); 00475 00481 const ElemTemplateElement* 00482 getElement() const 00483 { 00484 return m_element; 00485 } 00486 00487 StackEntry& 00488 operator=(const StackEntry& theRHS); 00489 00490 bool 00491 operator==(const StackEntry& theRHS) const; 00492 00493 private: 00494 00495 // Data members... 00496 eType m_type; 00497 00498 const XalanQName* m_qname; 00499 00500 XObjectPtr m_value; 00501 00502 const ElemVariable* m_variable; 00503 00504 const ElemTemplateElement* m_element; 00505 }; 00506 00507 #if defined(XALAN_NO_STD_NAMESPACE) 00508 typedef vector<StackEntry> VariableStackStackType; 00509 #else 00510 typedef std::vector<StackEntry> VariableStackStackType; 00511 #endif 00512 00513 typedef VariableStackStackType::size_type size_type; 00514 00515 size_type 00516 getStackSize() const 00517 { 00518 return m_stack.size(); 00519 } 00520 00521 enum { eDefaultStackSize = 100 }; 00522 00523 private: 00524 00525 class CommitPushParams 00526 { 00527 public: 00528 00529 CommitPushParams(VariablesStack& theVariablesStack); 00530 00531 ~CommitPushParams(); 00532 00533 void 00534 commit() 00535 { 00536 m_variablesStack = 0; 00537 } 00538 00539 private: 00540 00541 VariablesStack* m_variablesStack; 00542 00543 size_type m_stackSize; 00544 }; 00545 00546 friend class CommitPushParams; 00547 00555 bool 00556 elementFrameAlreadyPushed(const ElemTemplateElement* elem) const; 00557 00563 void 00564 push(const StackEntry& theEntry); 00565 00569 void 00570 pop(); 00571 00577 const StackEntry& 00578 back() const 00579 { 00580 assert(m_stack.empty() == false); 00581 00582 return m_stack.back(); 00583 } 00584 00585 friend class CommitPushElementFrame; 00586 friend class EnsurePop; 00587 friend class PushParamFunctor; 00588 friend class SetAndRestoreForceGlobalSearch; 00589 00590 const XObjectPtr 00591 findXObject( 00592 const XalanQName& name, 00593 StylesheetExecutionContext& executionContext, 00594 bool fIsParam, 00595 bool fSearchGlobalSpace, 00596 bool& fNameFound); 00597 00598 VariableStackStackType::size_type 00599 findEntry( 00600 const XalanQName& name, 00601 bool fIsParam, 00602 bool fSearchGlobalSpace); 00603 00604 00605 VariableStackStackType m_stack; 00606 00607 int m_globalStackFrameIndex; 00608 00609 bool m_globalStackFrameMarked; 00610 00616 unsigned int m_currentStackFrameIndex; 00617 00623 RecursionGuardStackType m_guardStack; 00624 00629 ElemTemplateElementStackType m_elementFrameStack; 00630 }; 00631 00632 00633 00634 XALAN_CPP_NAMESPACE_END 00635 00636 00637 00638 #endif // #if !defined(XALAN_VARIABLESSTACK_HEADER_GUARD)
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.7 |
|