00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 2000 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 <XSLT/XSLTDefinitions.hpp> 00064 00065 00066 00067 #include <cassert> 00068 #include <vector> 00069 00070 00071 00072 #include <XPath/QName.hpp> 00073 00074 00075 00076 #include <XSLT/XSLTProcessorException.hpp> 00077 00078 00079 00080 class Arg; 00081 class ElemTemplateElement; 00082 class StylesheetExecutionContext; 00083 class XObject; 00084 class XalanNode; 00085 00086 00087 00091 class XALAN_XSLT_EXPORT VariablesStack 00092 { 00093 public: 00094 00098 explicit 00099 VariablesStack(); 00100 00101 ~VariablesStack(); 00102 00103 00107 void 00108 reset(); 00109 00115 void 00116 pushElementFrame(const ElemTemplateElement* elem); 00117 00123 void 00124 popElementFrame(const ElemTemplateElement* elem); 00125 00133 void 00134 pushContextMarker(); 00135 00139 void 00140 popContextMarker(); 00141 00142 #if defined(XALAN_NO_NAMESPACES) 00143 typedef vector<pair<const QName*, const XObject*> > ParamsVectorType; 00144 #else 00145 typedef std::vector<std::pair<const QName*, const XObject*> > ParamsVectorType; 00146 #endif 00147 00155 void 00156 pushParams( 00157 const ParamsVectorType& theParams, 00158 const ElemTemplateElement* targetTemplate); 00159 00167 const XObject* 00168 getParamVariable(const QName& qname) const 00169 { 00170 return findXObject(qname, false); 00171 } 00172 00179 const XObject* 00180 getVariable(const QName& name) const 00181 { 00182 return findXObject(name, true); 00183 } 00184 00194 void 00195 pushVariable( 00196 const QName& name, 00197 const XObject* val, 00198 const ElemTemplateElement* e); 00199 00203 void 00204 start(); 00205 00209 void 00210 markGlobalStackFrame(); 00211 00219 void 00220 setCurrentStackFrameIndex(int currentStackFrameIndex = -1) 00221 { 00222 if (currentStackFrameIndex == -1) 00223 m_currentStackFrameIndex = m_stack.size(); 00224 else 00225 m_currentStackFrameIndex = currentStackFrameIndex; 00226 } 00227 00234 int 00235 getCurrentStackFrameIndex() const 00236 { 00237 return m_currentStackFrameIndex; 00238 } 00239 00240 class InvalidStackContextException : public XSLTProcessorException 00241 { 00242 public: 00243 00244 InvalidStackContextException(); 00245 00246 virtual 00247 ~InvalidStackContextException(); 00248 00249 private: 00250 00251 }; 00252 00253 class PushParamFunctor 00254 { 00255 public: 00256 00257 PushParamFunctor(VariablesStack& theVariablesStack) : 00258 m_variablesStack(theVariablesStack) 00259 { 00260 } 00261 00262 const void 00263 operator()(const ParamsVectorType::value_type& theEntry); 00264 00265 private: 00266 00267 VariablesStack& m_variablesStack; 00268 }; 00269 00270 private: 00271 00272 class StackEntry; 00273 00281 bool 00282 elementFrameAlreadyPushed(const ElemTemplateElement* elem) const; 00283 00289 void 00290 push(const StackEntry& theEntry); 00291 00295 void 00296 pop(); 00297 00303 const StackEntry& 00304 back() const 00305 { 00306 assert(m_stack.empty() == false); 00307 00308 return m_stack.back(); 00309 } 00310 00311 friend class CommitPushElementFrame; 00312 friend class EnsurePop; 00313 friend class PopPushStackEntry; 00314 friend class PushFunctor; 00315 friend class PushParamFunctor; 00316 00317 class StackEntry 00318 { 00319 public: 00320 00325 enum eStackEntryType { eContextMarker, 00326 eVariable, 00327 eElementFrameMarker, 00328 eNextValue }; 00329 00333 explicit 00334 StackEntry(); 00335 00339 StackEntry( 00340 const QName* name, 00341 const XObject* val); 00342 00346 StackEntry(const ElemTemplateElement* elem); 00347 00348 00352 StackEntry(const StackEntry& theSource); 00353 00357 ~StackEntry(); 00358 00364 eStackEntryType 00365 getType() const 00366 { 00367 return m_type; 00368 } 00369 00375 const QName* 00376 getName() const 00377 { 00378 return variable.m_qname; 00379 } 00380 00386 const XObject* 00387 getVariable() const 00388 { 00389 return variable.m_value; 00390 } 00391 00397 const ElemTemplateElement* 00398 getElement() const 00399 { 00400 return elementMarker.m_element; 00401 } 00402 00403 StackEntry& 00404 operator=(const StackEntry& theRHS); 00405 00406 bool 00407 operator==(const StackEntry& theRHS) const; 00408 00409 private: 00410 00411 // Data members... 00412 eStackEntryType m_type; 00413 00414 union 00415 { 00416 struct 00417 { 00418 const QName* m_qname; 00419 00420 const XObject* m_value; 00421 } variable; 00422 00423 struct 00424 { 00425 const ElemTemplateElement* m_element; 00426 } elementMarker; 00427 }; 00428 }; 00429 00430 #if defined(XALAN_NO_NAMESPACES) 00431 typedef vector<StackEntry> VariableStackStackType; 00432 #else 00433 typedef std::vector<StackEntry> VariableStackStackType; 00434 #endif 00435 00436 enum { eDefaultStackSize = 100 }; 00437 00438 00439 const XObject* 00440 findXObject( 00441 const QName& name, 00442 bool fSearchGlobalSpace) const; 00443 00444 const StackEntry* 00445 findVariable( 00446 const QName& name, 00447 bool fSearchGlobalSpace) const; 00448 00449 00450 VariableStackStackType m_stack; 00451 00452 int m_globalStackFrameIndex; 00453 00459 unsigned int m_currentStackFrameIndex; 00460 }; 00461 00462 00463 00464 #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++ XSL Transformer Version 1.0 |
|