Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.4

Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

VariablesStack.hpp

Go to the documentation of this file.
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/XalanQName.hpp>
00073 #include <XPath/XObject.hpp>
00074 
00075 
00076 
00077 #include <XSLT/XSLTProcessorException.hpp>
00078 
00079 
00080 
00081 class Arg;
00082 class ElemTemplateElement;
00083 class ElemVariable;
00084 class StylesheetExecutionContext;
00085 class XalanNode;
00086 
00087 
00088 
00092 class XALAN_XSLT_EXPORT VariablesStack
00093 {
00094 public:
00095 
00099     explicit
00100     VariablesStack();
00101 
00102     ~VariablesStack();
00103 
00104     
00108     void
00109     reset();
00110 
00116     void
00117     pushElementFrame(const ElemTemplateElement*     elem);
00118 
00124     void
00125     popElementFrame(const ElemTemplateElement*  elem);
00126 
00134     void
00135     pushContextMarker();
00136 
00140     void
00141     popContextMarker();
00142 
00143     struct ParamsVectorEntry
00144     {
00145         ParamsVectorEntry() :
00146             m_qname(0),
00147             m_value(),
00148             m_variable(0)
00149         {
00150         }
00151 
00152         ParamsVectorEntry(
00153                 const XalanQName*   qname,
00154                 const XObjectPtr    value) :
00155             m_qname(qname),
00156             m_value(value),
00157             m_variable(0)
00158         {
00159         }
00160 
00161         ParamsVectorEntry(
00162                 const XalanQName*       qname,
00163                 const ElemVariable*     variable) :
00164             m_qname(qname),
00165             m_value(),
00166             m_variable(variable)
00167         {
00168         }
00169 
00170         const XalanQName*       m_qname;
00171 
00172         XObjectPtr              m_value;
00173 
00174         const ElemVariable*     m_variable;
00175     };
00176 
00177 #if defined(XALAN_NO_NAMESPACES)
00178     typedef vector<ParamsVectorEntry>       ParamsVectorType;
00179     typedef vector<const ElemVariable*>     RecursionGuardStackType;
00180 #else
00181     typedef std::vector<ParamsVectorEntry>      ParamsVectorType;
00182     typedef std::vector<const ElemVariable*>    RecursionGuardStackType;
00183 #endif
00184 
00192     void
00193     pushParams(
00194             const ParamsVectorType&     theParams,
00195             const ElemTemplateElement*  targetTemplate);
00196 
00207     const XObjectPtr
00208     getParamVariable(
00209             const XalanQName&               qname,
00210             StylesheetExecutionContext&     executionContext,
00211             bool&                           fNameFound)
00212     {
00213         return findXObject(qname, executionContext, true, false, fNameFound);
00214     }
00215 
00227     const XObjectPtr
00228     getVariable(
00229             const XalanQName&               qname,
00230             StylesheetExecutionContext&     executionContext,
00231             bool&                           fNameFound)
00232     {
00233         return findXObject(qname, executionContext, false, true, fNameFound);
00234     }
00235 
00245     void
00246     pushVariable(
00247             const XalanQName&           name,
00248             const ElemVariable*         var,
00249             const ElemTemplateElement*  e);
00250 
00260     void
00261     pushVariable(
00262             const XalanQName&           name,
00263             const XObjectPtr&           val,
00264             const ElemTemplateElement*  e);
00265 
00269     void
00270     start();
00271 
00275     void
00276     resetParams();
00277 
00281     void
00282     markGlobalStackFrame();
00283 
00287     void
00288     unmarkGlobalStackFrame();
00289 
00297     void
00298     setCurrentStackFrameIndex(int   currentStackFrameIndex = -1)
00299     {
00300         if (currentStackFrameIndex == -1)
00301             m_currentStackFrameIndex = m_stack.size();
00302         else
00303             m_currentStackFrameIndex = currentStackFrameIndex;
00304     }
00305 
00312     int
00313     getCurrentStackFrameIndex() const
00314     {
00315         return m_currentStackFrameIndex;
00316     }
00317 
00323     int
00324     getGlobalStackFrameIndex() const
00325     {
00326         return m_globalStackFrameIndex;
00327     }
00328 
00329     class InvalidStackContextException : public XSLTProcessorException
00330     {
00331     public:
00332 
00333         InvalidStackContextException();
00334 
00335         virtual
00336         ~InvalidStackContextException();
00337 
00338     private:
00339 
00340     };
00341 
00342     class PushParamFunctor
00343     {
00344     public:
00345 
00346         PushParamFunctor(VariablesStack&    theVariablesStack) :
00347             m_variablesStack(theVariablesStack)
00348         {
00349         }
00350 
00351         const void
00352         operator()(const ParamsVectorType::value_type&  theEntry);
00353 
00354     private:
00355 
00356         VariablesStack&     m_variablesStack;
00357     };
00358 
00359     class XALAN_XSLT_EXPORT StackEntry
00360     {
00361     public:
00362 
00367         enum eType { eContextMarker,
00368                     eVariable,
00369                     eParam,
00370                     eActiveParam,
00371                     eElementFrameMarker,
00372                     eNextValue };
00373 
00377         explicit
00378         StackEntry();
00379 
00383         StackEntry(
00384             const XalanQName*   name,
00385             const XObjectPtr&   val,
00386             bool                isParam = false);
00387 
00391         StackEntry(
00392             const XalanQName*       name,
00393             const ElemVariable*     var,
00394             bool                    isParam = false);
00395 
00399         StackEntry(const ElemTemplateElement*   elem);
00400 
00401 
00405         StackEntry(const StackEntry&    theSource);
00406 
00410         ~StackEntry();
00411 
00417         eType
00418         getType() const
00419         {
00420             return m_type;
00421         }
00422 
00428         const XalanQName*
00429         getName() const
00430         {
00431             return m_qname;
00432         }
00433 
00439         const XObjectPtr&
00440         getValue() const
00441         {
00442             return m_value;
00443         }
00444 
00450         void
00451         setValue(const XObjectPtr&  theValue)
00452         {
00453             m_value = theValue;
00454         }
00455 
00461         const ElemVariable*
00462         getVariable() const
00463         {
00464             return m_variable;
00465         }
00466 
00467         void
00468         activate();
00469 
00470         void
00471         deactivate();
00472 
00478         const ElemTemplateElement*
00479         getElement() const
00480         {
00481             return m_element;
00482         }
00483 
00484         StackEntry&
00485         operator=(const StackEntry&     theRHS);
00486 
00487         bool
00488         operator==(const StackEntry&    theRHS) const;
00489 
00490     private:
00491 
00492         // Data members...
00493         eType                       m_type;
00494 
00495         const XalanQName*           m_qname;
00496 
00497         XObjectPtr                  m_value;
00498 
00499         const ElemVariable*         m_variable;
00500 
00501         const ElemTemplateElement*  m_element;
00502     };
00503 
00504 #if defined(XALAN_NO_NAMESPACES)
00505     typedef vector<StackEntry>          VariableStackStackType;
00506 #else
00507     typedef std::vector<StackEntry>     VariableStackStackType;
00508 #endif
00509 
00510     enum { eDefaultStackSize = 100 };
00511 
00512 private:
00513 
00521     bool
00522     elementFrameAlreadyPushed(const ElemTemplateElement*    elem) const;
00523 
00529     void
00530     push(const StackEntry&  theEntry);
00531 
00535     void
00536     pop();
00537 
00543     const StackEntry&
00544     back() const
00545     {
00546         assert(m_stack.empty() == false);
00547 
00548         return m_stack.back();
00549     }
00550 
00551     friend class CommitPushElementFrame;
00552     friend class EnsurePop;
00553     friend class PushParamFunctor;
00554     friend class SetAndRestoreForceGlobalSearch;
00555 
00556     const XObjectPtr
00557     findXObject(
00558             const XalanQName&               name,
00559             StylesheetExecutionContext&     executionContext,
00560             bool                            fIsParam,
00561             bool                            fSearchGlobalSpace,
00562             bool&                           fNameFound);
00563 
00564     VariableStackStackType::size_type
00565     findEntry(
00566             const XalanQName&   name,
00567             bool                fIsParam,
00568             bool                fSearchGlobalSpace);
00569 
00570 
00571     VariableStackStackType      m_stack;
00572 
00573     int                         m_globalStackFrameIndex;
00574 
00575     bool                        m_globalStackFrameMarked;
00576 
00582     unsigned int                m_currentStackFrameIndex;   
00583 
00589     RecursionGuardStackType     m_guardStack;
00590 };
00591 
00592 
00593 
00594 #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.4
Copyright © 2000, 2001, 2002 The Apache Software Foundation. All Rights Reserved.