Xalan-C++ API Documentation

The Xalan C++ XSL Transformer Version 1.1

Main Page   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 #else
00180     typedef std::vector<ParamsVectorEntry>  ParamsVectorType;
00181 #endif
00182 
00190     void
00191     pushParams(
00192             const ParamsVectorType&     theParams,
00193             const ElemTemplateElement*  targetTemplate);
00194 
00205     const XObjectPtr
00206     getParamVariable(
00207             const XalanQName&               qname,
00208             StylesheetExecutionContext&     executionContext,
00209             bool&                           fNameFound)
00210     {
00211         return findXObject(qname, executionContext, true, false, fNameFound);
00212     }
00213 
00225     const XObjectPtr
00226     getVariable(
00227             const XalanQName&               qname,
00228             StylesheetExecutionContext&     executionContext,
00229             bool&                           fNameFound)
00230     {
00231         return findXObject(qname, executionContext, false, true, fNameFound);
00232     }
00233 
00243     void
00244     pushVariable(
00245             const XalanQName&           name,
00246             const ElemVariable*         var,
00247             const ElemTemplateElement*  e);
00248 
00258     void
00259     pushVariable(
00260             const XalanQName&           name,
00261             const XObjectPtr&           val,
00262             const ElemTemplateElement*  e);
00263 
00267     void
00268     start();
00269 
00273     void
00274     resetParams();
00275 
00279     void
00280     markGlobalStackFrame();
00281 
00285     void
00286     unmarkGlobalStackFrame();
00287 
00295     void
00296     setCurrentStackFrameIndex(int   currentStackFrameIndex = -1)
00297     {
00298         if (currentStackFrameIndex == -1)
00299             m_currentStackFrameIndex = m_stack.size();
00300         else
00301             m_currentStackFrameIndex = currentStackFrameIndex;
00302     }
00303 
00310     int
00311     getCurrentStackFrameIndex() const
00312     {
00313         return m_currentStackFrameIndex;
00314     }
00315 
00321     int
00322     getGlobalStackFrameIndex() const
00323     {
00324         return m_globalStackFrameIndex;
00325     }
00326 
00327     class InvalidStackContextException : public XSLTProcessorException
00328     {
00329     public:
00330 
00331         InvalidStackContextException();
00332 
00333         virtual
00334         ~InvalidStackContextException();
00335 
00336     private:
00337 
00338     };
00339 
00340     class PushParamFunctor
00341     {
00342     public:
00343 
00344         PushParamFunctor(VariablesStack&    theVariablesStack) :
00345             m_variablesStack(theVariablesStack)
00346         {
00347         }
00348 
00349         const void
00350         operator()(const ParamsVectorType::value_type&  theEntry);
00351 
00352     private:
00353 
00354         VariablesStack&     m_variablesStack;
00355     };
00356 
00357 private:
00358 
00359     class StackEntry;
00360 
00368     bool
00369     elementFrameAlreadyPushed(const ElemTemplateElement*    elem) const;
00370 
00376     void
00377     push(const StackEntry&  theEntry);
00378 
00382     void
00383     pop();
00384 
00390     const StackEntry&
00391     back() const
00392     {
00393         assert(m_stack.empty() == false);
00394 
00395         return m_stack.back();
00396     }
00397 
00398     friend class CommitPushElementFrame;
00399     friend class EnsurePop;
00400     friend class PushParamFunctor;
00401     friend class SetAndRestoreForceGlobalSearch;
00402 
00403     class XALAN_XSLT_EXPORT StackEntry
00404     {
00405     public:
00406 
00411         enum eType { eContextMarker,
00412                     eVariable,
00413                     eParam,
00414                     eActiveParam,
00415                     eElementFrameMarker,
00416                     eNextValue };
00417 
00421         explicit
00422         StackEntry();
00423 
00427         StackEntry(
00428             const XalanQName*   name,
00429             const XObjectPtr&   val,
00430             bool                isParam = false);
00431 
00435         StackEntry(
00436             const XalanQName*       name,
00437             const ElemVariable*     var,
00438             bool                    isParam = false);
00439 
00443         StackEntry(const ElemTemplateElement*   elem);
00444 
00445 
00449         StackEntry(const StackEntry&    theSource);
00450 
00454         ~StackEntry();
00455 
00461         eType
00462         getType() const
00463         {
00464             return m_type;
00465         }
00466 
00472         const XalanQName*
00473         getName() const
00474         {
00475             return m_qname;
00476         }
00477 
00483         const XObjectPtr&
00484         getValue() const
00485         {
00486             return m_value;
00487         }
00488 
00494         void
00495         setValue(const XObjectPtr&  theValue)
00496         {
00497             m_value = theValue;
00498         }
00499 
00505         const ElemVariable*
00506         getVariable() const
00507         {
00508             return m_variable;
00509         }
00510 
00511         void
00512         activate();
00513 
00514         void
00515         deactivate();
00516 
00522         const ElemTemplateElement*
00523         getElement() const
00524         {
00525             return m_element;
00526         }
00527 
00528         StackEntry&
00529         operator=(const StackEntry&     theRHS);
00530 
00531         bool
00532         operator==(const StackEntry&    theRHS) const;
00533 
00534     private:
00535 
00536         // Data members...
00537         eType                       m_type;
00538 
00539         const XalanQName*           m_qname;
00540 
00541         XObjectPtr                  m_value;
00542 
00543         const ElemVariable*         m_variable;
00544 
00545         const ElemTemplateElement*  m_element;
00546     };
00547 
00548 #if defined(XALAN_NO_NAMESPACES)
00549     typedef vector<StackEntry>          VariableStackStackType;
00550 #else
00551     typedef std::vector<StackEntry>     VariableStackStackType;
00552 #endif
00553 
00554     enum { eDefaultStackSize = 100 };
00555 
00556 
00557     const XObjectPtr
00558     findXObject(
00559             const XalanQName&               name,
00560             StylesheetExecutionContext&     executionContext,
00561             bool                            fIsParam,
00562             bool                            fSearchGlobalSpace,
00563             bool&                           fNameFound);
00564 
00565     StackEntry*
00566     findEntry(
00567             const XalanQName&   name,
00568             bool                fIsParam,
00569             bool                fSearchGlobalSpace);
00570 
00571 
00572     VariableStackStackType  m_stack;
00573 
00574     int                     m_globalStackFrameIndex;
00575 
00576     bool                    m_globalStackFrameMarked;
00577 
00583     unsigned int            m_currentStackFrameIndex;   
00584 };
00585 
00586 
00587 
00588 #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++ XSL Transformer Version 1.1
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.