dbertoni    2002/10/30 23:12:03

  Modified:    c/src/XPath XPathEvaluator.cpp XPathEvaluator.hpp
                        XPathExecutionContext.hpp XPathProcessor.hpp
                        XPathProcessorImpl.cpp XPathProcessorImpl.hpp
  Added:       c/src/XPath XPathConstructionContext.cpp
                        XPathConstructionContext.hpp
                        XPathConstructionContextDefault.cpp
                        XPathConstructionContextDefault.hpp
                        XalanQNameByValueAllocator.cpp
                        XalanQNameByValueAllocator.hpp
  Log:
  New construction context class for better dynamic memory allocation.
  
  Revision  Changes    Path
  1.6       +19 -8     xml-xalan/c/src/XPath/XPathEvaluator.cpp
  
  Index: XPathEvaluator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathEvaluator.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XPathEvaluator.cpp        5 Sep 2001 20:11:34 -0000       1.5
  +++ XPathEvaluator.cpp        31 Oct 2002 07:12:03 -0000      1.6
  @@ -63,13 +63,14 @@
   
   
   
  -#include <XPath/ElementPrefixResolverProxy.hpp>
  -#include <XPath/XObjectFactoryDefault.hpp>
  -#include <XPath/XPathEnvSupportDefault.hpp>
  -#include <XPath/XPathExecutionContextDefault.hpp>
  -#include <XPath/XPathFactoryDefault.hpp>
  -#include <XPath/XPathProcessorImpl.hpp>
  -#include <XPath/XPathInit.hpp>
  +#include "ElementPrefixResolverProxy.hpp"
  +#include "XObjectFactoryDefault.hpp"
  +#include "XPathEnvSupportDefault.hpp"
  +#include "XPathConstructionContextDefault.hpp"
  +#include "XPathExecutionContextDefault.hpp"
  +#include "XPathFactoryDefault.hpp"
  +#include "XPathProcessorImpl.hpp"
  +#include "XPathInit.hpp"
   
   
   
  @@ -98,6 +99,7 @@
   XPathEvaluator::XPathEvaluator() :
        m_xobjectFactory(new XObjectFactoryDefault),
        m_xpathFactory(new XPathFactoryDefault),
  +     m_constructionContext(new XPathConstructionContextDefault),
        m_executionContext(new XPathExecutionContextDefault)
   
   {
  @@ -390,6 +392,7 @@
   
       theProcessor.initXPath(
                        *theXPath,
  +                     *m_constructionContext.get(),
                        XalanDOMString(xpathString),
                        prefixResolver);
   
  @@ -403,7 +406,14 @@
   {
        assert(theXPath != 0);
   
  -     return m_xpathFactory->returnObject(theXPath);
  +     const bool      theResult = m_xpathFactory->returnObject(theXPath);
  +
  +     if (m_xpathFactory->getInstanceCount() == 0)
  +     {
  +             m_constructionContext->reset();
  +     }
  +
  +     return theResult;
   }
   
   
  @@ -427,6 +437,7 @@
   
       theProcessor.initXPath(
                        theXPath,
  +                     *m_constructionContext.get(),
                        XalanDOMString(xpathString),
                        prefixResolver);
   
  
  
  
  1.5       +7 -3      xml-xalan/c/src/XPath/XPathEvaluator.hpp
  
  Index: XPathEvaluator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathEvaluator.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XPathEvaluator.hpp        5 Sep 2001 20:11:34 -0000       1.4
  +++ XPathEvaluator.hpp        31 Oct 2002 07:12:03 -0000      1.5
  @@ -65,7 +65,8 @@
   
   #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
   #include <XPath/XObjectFactory.hpp>
  -#include <XPath/XPathFactory.hpp>
  +#include <XPath/XPathFactoryDefault.hpp>
  +#include <XPath/XPathConstructionContextDefault.hpp>
   #include <XPath/XPathExecutionContextDefault.hpp>
   #endif
   
  @@ -81,7 +82,8 @@
   
   #if !defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
   class XObjectFactory;
  -class XPathFactory;
  +class XPathFactoryDefault;
  +class XPathConstructionContextDefault;
   class XPathExecutionContextDefault;
   #endif
   
  @@ -445,7 +447,9 @@
        // Data members...
        const XalanAutoPtr<XObjectFactory>                                      
m_xobjectFactory;
   
  -     const XalanAutoPtr<XPathFactory>                                        
m_xpathFactory;
  +     const XalanAutoPtr<XPathFactoryDefault>                         m_xpathFactory;
  +
  +     const XalanAutoPtr<XPathConstructionContextDefault>     m_constructionContext;
   
        const XalanAutoPtr<XPathExecutionContextDefault>        m_executionContext;
   };
  
  
  
  1.50      +12 -0     xml-xalan/c/src/XPath/XPathExecutionContext.hpp
  
  Index: XPathExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContext.hpp,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- XPathExecutionContext.hpp 21 Sep 2002 01:24:21 -0000      1.49
  +++ XPathExecutionContext.hpp 31 Oct 2002 07:12:03 -0000      1.50
  @@ -429,9 +429,21 @@
                MutableNodeRefList*             m_mutableNodeRefList;
        };
   
  +     /**
  +      * Get a cached string for temporary use.
  +      *
  +      * @return A reference to the string
  +      */
        virtual XalanDOMString&
        getCachedString() = 0;
   
  +     /**
  +      * Return a cached string.
  +      *
  +      * @param theString The string to release.
  +      *
  +      * @return true if the string was released successfully.
  +      */
        virtual bool
        releaseCachedString(XalanDOMString&             theString) = 0;
   
  
  
  
  1.8       +13 -9     xml-xalan/c/src/XPath/XPathProcessor.hpp
  
  Index: XPathProcessor.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessor.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XPathProcessor.hpp        12 Jul 2001 04:35:48 -0000      1.7
  +++ XPathProcessor.hpp        31 Oct 2002 07:12:03 -0000      1.8
  @@ -73,6 +73,7 @@
   class Locator;
   class PrefixResolver;
   class XPath;
  +class XPathConstructionContext;
   
   
   
  @@ -91,32 +92,35 @@
         * have to be done each time the expression is executed.
         *
         * @param pathObj        XPath object to be initialized
  +      * @param constructionContext The construction context
         * @param expression     expression that will be evaluated
         * @param resolver       prefix resolver to use
  -      * @param xobjectFactory factory class instance for XObjects
         * @param locator                the Locator to use for error report. May be 
null
         */
        virtual void
        initXPath(
  -                     XPath&                                  pathObj,
  -                     const XalanDOMString&   expression,
  -                     const PrefixResolver&   resolver,
  -                     const Locator*                  locator = 0) = 0;
  +                     XPath&                                          pathObj,
  +                     XPathConstructionContext&       constructionContext,
  +                     const XalanDOMString&           expression,
  +                     const PrefixResolver&           resolver,
  +                     const Locator*                          locator = 0) = 0;
   
        /**
         * Given a string, create an XSLT Match Pattern object.
         *
         * @param pathObj        XPath object to be initialized
  +      * @param constructionContext The construction context
         * @param expression     expression that will be evaluated
         * @param resolver       prefix resolver to use
         * @param locator                the Locator to use for error report. May be 
null
         */
        virtual void
        initMatchPattern(
  -                     XPath&                                  pathObj,
  -                     const XalanDOMString&   expression,
  -                     const PrefixResolver&   resolver,
  -                     const Locator*                  locator = 0) = 0;
  +                     XPath&                                          pathObj,
  +                     XPathConstructionContext&       constructionContext,
  +                     const XalanDOMString&           expression,
  +                     const PrefixResolver&           resolver,
  +                     const Locator*                          locator = 0) = 0;
   
        /**
         * Given a string, and a reference to a function object, install the
  
  
  
  1.63      +60 -139   xml-xalan/c/src/XPath/XPathProcessorImpl.cpp
  
  Index: XPathProcessorImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.cpp,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- XPathProcessorImpl.cpp    9 Oct 2002 16:49:17 -0000       1.62
  +++ XPathProcessorImpl.cpp    31 Oct 2002 07:12:03 -0000      1.63
  @@ -81,6 +81,7 @@
   
   #include "XalanQName.hpp"
   #include "XPathEnvSupport.hpp"
  +#include "XPathConstructionContext.hpp"
   #include "XPathExecutionContext.hpp"
   #include "XPathParserException.hpp"
   
  @@ -90,6 +91,7 @@
        m_token(),
        m_tokenChar(0),
        m_xpath(0),
  +     m_constructionContext(0),
        m_expression(0),
        m_prefixResolver(0),
        m_requireLiterals(false),
  @@ -109,18 +111,21 @@
   
   void
   XPathProcessorImpl::initXPath(
  -                     XPath&                                  pathObj,
  -                     const XalanDOMString&   expression,
  -                     const PrefixResolver&   prefixResolver,
  -                     const Locator*                  locator)
  +                     XPath&                                          pathObj,
  +                     XPathConstructionContext&       constructionContext,
  +                     const XalanDOMString&           expression,
  +                     const PrefixResolver&           resolver,
  +                     const Locator*                          locator)
   {
        m_requireLiterals = false;
   
        m_xpath = &pathObj;
   
  +     m_constructionContext = &constructionContext;
  +
        m_expression = &m_xpath->getExpression();
   
  -     m_prefixResolver = &prefixResolver;
  +     m_prefixResolver = &resolver;
   
        m_locator = locator;
   
  @@ -140,6 +145,7 @@
        }
   
        m_xpath = 0;
  +     m_constructionContext = 0;
        m_expression = 0;
        m_prefixResolver = 0;
        m_locator = 0;
  @@ -151,18 +157,21 @@
   
   void
   XPathProcessorImpl::initMatchPattern(
  -                     XPath&                                  pathObj,
  -                     const XalanDOMString&   expression,
  -                     const PrefixResolver&   prefixResolver,
  -                     const Locator*                  locator)
  +                     XPath&                                          pathObj,
  +                     XPathConstructionContext&       constructionContext,
  +                     const XalanDOMString&           expression,
  +                     const PrefixResolver&           resolver,
  +                     const Locator*                          locator)
   {
        m_isMatchPattern = true;
   
        m_xpath = &pathObj;
   
  +     m_constructionContext = &constructionContext;
  +
        m_expression = &m_xpath->getExpression();
   
  -     m_prefixResolver = &prefixResolver;
  +     m_prefixResolver = &resolver;
   
        m_locator = locator;
   
  @@ -187,6 +196,7 @@
        m_expression->shrink();
   
        m_xpath = 0;
  +     m_constructionContext = 0;
        m_expression = 0;
        m_prefixResolver = 0;
        m_locator = 0;
  @@ -199,6 +209,10 @@
   void
   XPathProcessorImpl::tokenize(const XalanDOMString&   pat)
   {
  +     assert(m_xpath != 0);
  +     assert(m_expression != 0);
  +     assert(m_constructionContext != 0);
  +
        m_expression->setCurrentPattern(pat);
   
        const int       nChars = length(pat);
  @@ -213,7 +227,9 @@
        // counted inside the m_patternMap.
        int nesting = 0;
   
  -     XalanDOMString  theToken;
  +     const XPathConstructionContext::GetAndReleaseCachedString       
theGuard(*m_constructionContext);
  +
  +     XalanDOMString&         theToken = theGuard.get();
   
        for(int i = 0; i < nChars; i++)
        {
  @@ -580,35 +596,40 @@
   {
        assert(m_prefixResolver != 0);
   
  -     const XalanDOMString    prefix(pat, startSubstring, posOfNSSep - 
startSubstring);
  +     const XPathConstructionContext::GetAndReleaseCachedString       
theGuard(*m_constructionContext);
  +
  +     XalanDOMString&         scratchString = theGuard.get();
  +
  +     // Get the prefix of the QName...
  +     scratchString.assign(pat, startSubstring, posOfNSSep - startSubstring);
   
  -     if (XalanQName::isValidNCName(prefix) == false)
  +     if (XalanQName::isValidNCName(scratchString) == false)
        {
  -             error(XalanDOMString("'") + prefix + XalanDOMString("' is not a valid 
NCName"));
  +             error(XalanDOMString("'") + scratchString + XalanDOMString("' is not a 
valid NCName"));
        }
   
        const XalanDOMString* const             uName =
  -                             m_prefixResolver->getNamespaceForPrefix(prefix);
  +                             m_prefixResolver->getNamespaceForPrefix(scratchString);
   
        if(uName == 0)
        {
                error(
                        TranscodeFromLocalCodePage("Unable to resolve prefix '") +
  -                     prefix +
  +                     scratchString +
                        TranscodeFromLocalCodePage("'."));
        }
        else if (length(*uName) == 0)
        {
                error(
                        TranscodeFromLocalCodePage("The prefix '") +
  -                     prefix +
  +                     scratchString +
                        TranscodeFromLocalCodePage("' is bound to a zero-length 
URI."));
        }
        else
        {
  -             m_namespaces[prefix] = *uName;
  +             m_namespaces[scratchString] = *uName;
   
  -             addToTokenQueue(prefix);
  +             addToTokenQueue(scratchString);
   
                addToTokenQueue(DOMServices::s_XMLNamespaceSeparatorString);
   
  @@ -619,17 +640,17 @@
                // here...
                if(posOfNSSep + 1 < posOfScan)
                {
  -                     const XalanDOMString    s(pat, posOfNSSep + 1, posOfScan - 
(posOfNSSep + 1));
  +                     scratchString.assign(pat, posOfNSSep + 1, posOfScan - 
(posOfNSSep + 1));
   
  -                     assert(length(s) > 0);
  +                     assert(length(scratchString) > 0);
   
  -                     if (XalanQName::isValidNCName(s) == false)
  +                     if (XalanQName::isValidNCName(scratchString) == false)
                        {
  -                             error(XalanDOMString("'") + s + XalanDOMString("' is 
not a valid NCName"));
  +                             error(XalanDOMString("'") + scratchString + 
XalanDOMString("' is not a valid NCName"));
                        }
                        else
                        {
  -                             addToTokenQueue(s);
  +                             addToTokenQueue(scratchString);
                        }
                }
        }
  @@ -668,40 +689,7 @@
   
   
   bool
  -XPathProcessorImpl::tokenIs(const char*              s) const
  -{
  -     const unsigned int      theTokenLength = length(m_token);
  -
  -     const unsigned int      theStringLength = XalanDOMString::length(s);
  -
  -     if (theTokenLength != theStringLength)
  -     {
  -             return false;
  -     }
  -     else
  -     {
  -             unsigned int    i = 0;
  -
  -             while(i < theStringLength)
  -             {
  -                     if (charAt(m_token, i ) != s[i])
  -                     {
  -                             break;
  -                     }
  -                     else
  -                     {
  -                             ++i;
  -                     }
  -             }
  -
  -             return i == theStringLength ? true : false;
  -     }
  -}
  -
  -
  -
  -bool
  -XPathProcessorImpl::tokenIs(char     c) const
  +XPathProcessorImpl::tokenIs(XalanDOMChar     c) const
   {
        return m_tokenChar == c ? true : false;
   }
  @@ -828,7 +816,7 @@
        const XObject* const    thePreviousToken =
                        m_expression->getPreviousToken();
   
  -     m_token = thePreviousToken == 0 ? XalanDOMString() : thePreviousToken->str();
  +     m_token = thePreviousToken == 0 ? s_emptyString : thePreviousToken->str();
   
        if(length(m_token) > 0)
        {
  @@ -866,7 +854,7 @@
   
   
   void
  -XPathProcessorImpl::consumeExpected(const char*      expected)
  +XPathProcessorImpl::consumeExpected(XalanDOMChar     expected)
   {
        if(tokenIs(expected) == true)
        {
  @@ -874,26 +862,11 @@
        }
        else
        {
  -             error(TranscodeFromLocalCodePage("Expected ") +
  -                       TranscodeFromLocalCodePage(expected) +
  -                       TranscodeFromLocalCodePage(", but found: ") +
  -                       m_token);
  -     }
  -}
  -
  -
  +             const XPathConstructionContext::GetAndReleaseCachedString       
theGuard(*m_constructionContext);
   
  -void
  -XPathProcessorImpl::consumeExpected(char     expected)
  -{
  -     if(tokenIs(expected) == true)
  -     {
  -             nextToken();
  -     }
  -     else
  -     {
  -             XalanDOMString  theMsg(TranscodeFromLocalCodePage("Expected "));
  +             XalanDOMString  theMsg = theGuard.get();
   
  +             append(theMsg, "Expected ");
                append(theMsg, expected);
                append(theMsg, ", but found: ");
                append(theMsg, m_token);
  @@ -909,7 +882,9 @@
                        const XalanDOMString&   msg,
                        XalanNode*                              /* sourceNode */) const
   {
  -     XalanDOMString  emsg;
  +     const XPathConstructionContext::GetAndReleaseCachedString       
theGuard(*m_constructionContext);
  +
  +     XalanDOMString&         emsg = theGuard.get();
   
        if (m_expression == 0)
        {
  @@ -1010,64 +985,6 @@
   }
   
   
  -#if 0
  -int
  -XPathProcessorImpl::getFunctionToken(const XalanDOMString&   key) const
  -{
  -     if (equals(key, s_commentString) == true)
  -     {
  -             return XPathExpression::eNODETYPE_COMMENT;
  -     }
  -     else if (equals(key, s_piString) == true)
  -     {
  -             return XPathExpression::eNODETYPE_PI;
  -     }
  -     else if (equals(key, s_nodeString) == true)
  -     {
  -             return XPathExpression::eNODETYPE_NODE;
  -     }
  -     else if (equals(key, s_textString) == true)
  -     {
  -             return XPathExpression::eNODETYPE_TEXT;
  -     }
  -     else
  -     {
  -             return -1;
  -     }
  -}
  -
  -
  -
  -XPathExpression::eOpCodes
  -XPathProcessorImpl::getNodeTypeToken(const XalanDOMString&   key) const
  -{
  -     if (equals(key, s_asteriskString) == true)
  -     {
  -             return XPathExpression::eNODETYPE_ANYELEMENT;
  -     }
  -     else if (equals(key, s_commentString) == true)
  -     {
  -             return XPathExpression::eNODETYPE_COMMENT;
  -     }
  -     else if (equals(key, s_piString) == true)
  -     {
  -             return XPathExpression::eNODETYPE_PI;
  -     }
  -     else if (equals(key, s_nodeString) == true)
  -     {
  -             return XPathExpression::eNODETYPE_NODE;
  -     }
  -     else if (equals(key, s_textString) == true)
  -     {
  -             return XPathExpression::eNODETYPE_TEXT;
  -     }
  -     else
  -     {
  -             return XPathExpression::eENDOP;
  -     }
  -}
  -#endif
  -
   
   void
   XPathProcessorImpl::Expr()
  @@ -2143,7 +2060,7 @@
        // If there is no prefix, we have to fake things out...
        if (lookahead(XalanUnicode::charColon, 1) == false)
        {
  -             m_expression->insertToken(XalanDOMString());
  +             m_expression->insertToken(s_emptyString);
   
                m_expression->pushCurrentTokenOnOpCodeMap();
   
  @@ -2189,7 +2106,11 @@
   
        if(isCurrentLiteral() == true)
        {
  -             const XalanDOMString    theArgument(m_token, 1, length(m_token) - 2);
  +             const XPathConstructionContext::GetAndReleaseCachedString       
theGuard(*m_constructionContext);
  +
  +             XalanDOMString&         theArgument = theGuard.get();
  +
  +             theArgument.assign(m_token, 1, length(m_token) - 2);
   
                m_expression->pushArgumentOnOpCodeMap(theArgument);
   
  
  
  
  1.24      +17 -25    xml-xalan/c/src/XPath/XPathProcessorImpl.hpp
  
  Index: XPathProcessorImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.hpp,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XPathProcessorImpl.hpp    5 Sep 2002 01:38:03 -0000       1.23
  +++ XPathProcessorImpl.hpp    31 Oct 2002 07:12:03 -0000      1.24
  @@ -118,17 +118,19 @@
   
        virtual void
        initXPath(
  -                     XPath&                                  pathObj,
  -                     const XalanDOMString&   expression,
  -                     const PrefixResolver&   prefixResolver,
  -                     const Locator*                  locator = 0);
  +                     XPath&                                          pathObj,
  +                     XPathConstructionContext&       constructionContext,
  +                     const XalanDOMString&           expression,
  +                     const PrefixResolver&           resolver,
  +                     const Locator*                          locator = 0);
   
        virtual void
        initMatchPattern(
  -                     XPath&                                  pathObj,
  -                     const XalanDOMString&   expression,
  -                     const PrefixResolver&   prefixResolver,
  -                     const Locator*                  locator = 0);
  +                     XPath&                                          pathObj,
  +                     XPathConstructionContext&       constructionContext,
  +                     const XalanDOMString&           expression,
  +                     const PrefixResolver&           resolver,
  +                     const Locator*                          locator = 0);
   
   private:
   
  @@ -237,15 +239,7 @@
         * if s is also null).
         */
        bool
  -     tokenIs(const char*             s) const;
  -
  -     /**
  -      * Check if m_token==s. If m_token is null, this won't throw
  -      * an exception, instead it just returns false (or true
  -      * if s is also null).
  -      */
  -     bool
  -     tokenIs(char    c) const;
  +     tokenIs(XalanDOMChar    c) const;
   
        /**
         * Lookahead of the current token in order to 
  @@ -344,14 +338,7 @@
         * isn't there.
         */
        void
  -     consumeExpected(const char*             expected);
  -
  -     /**
  -      * Consume an expected token, throwing an exception if it 
  -      * isn't there.
  -      */
  -     void
  -     consumeExpected(char    expected);
  +     consumeExpected(XalanDOMChar    expected);
   
        bool
        isCurrentLiteral() const;
  @@ -793,6 +780,11 @@
         * A pointer to the current XPath.
         */
        XPath*                                                  m_xpath;
  +
  +     /**
  +      * A pointer to the current XPathConstructionContext.
  +      */
  +     XPathConstructionContext*               m_constructionContext;
   
        /**
         * A pointer to the current XPath's expression.
  
  
  
  1.1                  xml-xalan/c/src/XPath/XPathConstructionContext.cpp
  
  Index: XPathConstructionContext.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  // Class header file...
  #include "XPathConstructionContext.hpp"
  
  
  
  XPathConstructionContext::XPathConstructionContext()
  {
  }
  
  
  
  XPathConstructionContext::~XPathConstructionContext()
  {
  }
  
  
  
  1.1                  xml-xalan/c/src/XPath/XPathConstructionContext.hpp
  
  Index: XPathConstructionContext.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * @author <a href="mailto:david_n_bertoni@;lotus.com">David N. Bertoni</a>
   */
  #if !defined(XPATHCONSTRUCTIONCONTEXT_HEADER_GUARD_1357924680)
  #define XPATHCONSTRUCTIONCONTEXT_HEADER_GUARD_1357924680
  
  
  
  // Base include file.  Must be first.
  #include <XPath/XPathDefinitions.hpp>
  
  
  
  #include <XalanDOM/XalanDOMString.hpp>
  
  
  
  //
  // An abstract class which provides support for constructing the internal
  // representation  of a stylesheet.
  //
  class XALAN_XPATH_EXPORT XPathConstructionContext
  {
  public:
  
        XPathConstructionContext();
  
        virtual
        ~XPathConstructionContext();
  
  
        /**
         * Reset the instance.  Any existing objects
         * created by the instance will be destroyed.
         */
        virtual void
        reset() = 0;
  
        /**
         * Get a pooled string given the source string.  If
         * the string already exists in the pool, no copy
         * will be made.  If not, a copy will be made and
         * kept for later use.
         *
         * @param theString The source string
         * @return a const reference to a pooled string.
         */
        virtual const XalanDOMString&
        getPooledString(const XalanDOMString&   theString) = 0;
  
        /**
         * Get a pooled string given the source character
         * array.  If the string already exists in the pool,
         * no copy will be made.  If not, a copy will be made
         * and kept for later use.
         *
         * @param theString The source character array
         * @param theLength The length of the character array
         * @return a const reference to a pooled string.
         */
        virtual const XalanDOMString&
        getPooledString(
                        const XalanDOMChar*                     theString,
                        XalanDOMString::size_type       theLength = 
XalanDOMString::npos) = 0;
  
        /**
         * Get a cached string for temporary use.
         *
         * @return A reference to the string
         */
        virtual XalanDOMString&
        getCachedString() = 0;
  
        /**
         * Return a cached string.
         *
         * @param theString The string to release.
         *
         * @return true if the string was released successfully.
         */
        virtual bool
        releaseCachedString(XalanDOMString&             theString) = 0;
  
        class GetAndReleaseCachedString
        {
        public:
  
                GetAndReleaseCachedString(XPathConstructionContext&             
theConstructionContext) :
                        m_constructionContext(&theConstructionContext),
                        m_string(&theConstructionContext.getCachedString())
                {
                }
  
                // Note non-const copy semantics...
                GetAndReleaseCachedString(GetAndReleaseCachedString&    theSource) :
                        m_constructionContext(theSource.m_constructionContext),
                        m_string(theSource.m_string)
                {
                        theSource.m_string = 0;
                }
  
                ~GetAndReleaseCachedString()
                {
                        if (m_string != 0)
                        {
                                m_constructionContext->releaseCachedString(*m_string);
                        }
                }
  
                XalanDOMString&
                get() const
                {
                        assert(m_string != 0);
  
                        return *m_string;
                }
  
                XPathConstructionContext&
                getConstructionContext() const
                {
                        return *m_constructionContext;
                }
  
        private:
  
                // Not implemented...
                GetAndReleaseCachedString&
                operator=(const GetAndReleaseCachedString&);
  
  
                // Data members...
                XPathConstructionContext*       m_constructionContext;
  
                XalanDOMString*                         m_string;
        };
  
  };
  
  
  
  #endif        // XPATHCONSTRUCTIONCONTEXT_HEADER_GUARD_1357924680
  
  
  
  1.1                  xml-xalan/c/src/XPath/XPathConstructionContextDefault.cpp
  
  Index: XPathConstructionContextDefault.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * @author <a href="mailto:david_n_bertoni@;lotus.com">David N. Bertoni</a>
   */
  
  #include "XPathConstructionContextDefault.hpp"
  
  
  
  XPathConstructionContextDefault::XPathConstructionContextDefault() :
        XPathConstructionContext(),
        m_stringPool(),
        m_stringCache()
  {
  }
  
  
  
  XPathConstructionContextDefault::~XPathConstructionContextDefault()
  {
        reset();
  }
  
  
  
  void
  XPathConstructionContextDefault::reset()
  {
        m_stringCache.reset();
  }
  
  
  
  const XalanDOMString&
  XPathConstructionContextDefault::getPooledString(const XalanDOMString&        
theString)
  {
        return m_stringPool.get(theString);
  }
  
  
  
  const XalanDOMString&
  XPathConstructionContextDefault::getPooledString(
                        const XalanDOMChar*                     theString,
                        XalanDOMString::size_type       theLength)
  {
        return m_stringPool.get(theString, theLength);
  }
  
  
  
  XalanDOMString&
  XPathConstructionContextDefault::getCachedString()
  {
        return m_stringCache.get();
  }
  
  
  
  bool
  XPathConstructionContextDefault::releaseCachedString(XalanDOMString&  theString)
  {
        return m_stringCache.release(theString);
  }
  
  
  
  1.1                  xml-xalan/c/src/XPath/XPathConstructionContextDefault.hpp
  
  Index: XPathConstructionContextDefault.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * @author <a href="mailto:david_n_bertoni@;lotus.com">David N. Bertoni</a>
   */
  #if !defined(XPATHCONSTRUCTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680)
  #define XPATHCONSTRUCTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
  
  
  
  // Base include file.  Must be first.
  #include <XPath/XPathDefinitions.hpp>
  
  
  
  #include <PlatformSupport/XalanDOMStringCache.hpp>
  #include <PlatformSupport/XalanDOMStringPool.hpp>
  
  
  
  // Base class header file...
  #include <XPath/XPathConstructionContext.hpp>
  
  
  
  /**
   *
   * An default implementation of an abtract class which provides support for
   * constructing the internal representation  of an XPath.
   *
   */
  class XALAN_XPATH_EXPORT XPathConstructionContextDefault : public 
XPathConstructionContext
  {
  public:
  
        /*
         * Construct an instance.
         */
        XPathConstructionContextDefault();
  
        virtual
        ~XPathConstructionContextDefault();
  
        virtual void
        reset();
  
        virtual const XalanDOMString&
        getPooledString(const XalanDOMString&   theString);
  
        virtual const XalanDOMString&
        getPooledString(
                        const XalanDOMChar*                     theString,
                        XalanDOMString::size_type       theLength = 
XalanDOMString::npos);
  
        virtual XalanDOMString&
        getCachedString();
  
        virtual bool
        releaseCachedString(XalanDOMString&             theString);
  
  private:
  
        XalanDOMStringPool              m_stringPool;
  
        XalanDOMStringCache             m_stringCache;
  };
  
  
  
  #endif        // XPATHCONSTRUCTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
  
  
  
  1.1                  xml-xalan/c/src/XPath/XalanQNameByValueAllocator.cpp
  
  Index: XalanQNameByValueAllocator.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  // Class header file.
  #include "XalanQNameByValueAllocator.hpp"
  
  
  
  XalanQNameByValueAllocator::XalanQNameByValueAllocator(size_type      theBlockCount) 
:
        m_allocator(theBlockCount)
  {
  }
  
  
  
  XalanQNameByValueAllocator::~XalanQNameByValueAllocator()
  {
  }
  
  
  
  XalanQNameByValueAllocator::data_type*
  XalanQNameByValueAllocator::create(const XalanQNameByValue&   theSource)
  {
        data_type* const        theBlock = m_allocator.allocateBlock();
        assert(theBlock != 0);
  
        data_type* const        theResult =
                new(theBlock) data_type(theSource);
  
        m_allocator.commitAllocation(theBlock);
  
        return theResult;
  }
  
  
  
  XalanQNameByValueAllocator::data_type*
  XalanQNameByValueAllocator::create(
                        const XalanDOMString&   theNamespaceURI,
                        const XalanDOMString&   theLocalPart)
  {
        data_type* const        theBlock = m_allocator.allocateBlock();
        assert(theBlock != 0);
  
        data_type* const        theResult =
                new(theBlock) data_type(theNamespaceURI, theLocalPart);
  
        m_allocator.commitAllocation(theBlock);
  
        return theResult;
  }
  
  
  
  XalanQNameByValueAllocator::data_type*
  XalanQNameByValueAllocator::create(
                        const XalanDOMString&           qname,
                        const NamespacesStackType&      namespaces,
                        const Locator*                          locator,
                        bool                                            fUseDefault)
  {
        data_type* const        theBlock = m_allocator.allocateBlock();
        assert(theBlock != 0);
  
        data_type* const        theResult =
                new(theBlock) data_type(qname, namespaces, locator, fUseDefault);
  
        m_allocator.commitAllocation(theBlock);
  
        return theResult;
  }
  
  
  
  XalanQNameByValueAllocator::data_type*
  XalanQNameByValueAllocator::create(
                        const XalanDOMChar*                     qname,
                        const NamespacesStackType&      namespaces,
                        const Locator*                          locator,
                        bool                                            fUseDefault)
  {
        data_type* const        theBlock = m_allocator.allocateBlock();
        assert(theBlock != 0);
  
        data_type* const        theResult =
                new(theBlock) data_type(qname, namespaces, locator, fUseDefault);
  
        m_allocator.commitAllocation(theBlock);
  
        return theResult;
  }
  
  
  
  XalanQNameByValueAllocator::data_type*
  XalanQNameByValueAllocator::create(
                        const XalanDOMString&   qname,
                        const XalanElement*             namespaceContext,
                        const XPathEnvSupport&  envSupport,
                        const DOMSupport&               domSupport,
                        const Locator*                  locator)
  {
        data_type* const        theBlock = m_allocator.allocateBlock();
        assert(theBlock != 0);
  
        data_type* const        theResult =
                new(theBlock) data_type(qname, namespaceContext, envSupport, 
domSupport, locator);
  
        m_allocator.commitAllocation(theBlock);
  
        return theResult;
  }
  
  
  
  XalanQNameByValueAllocator::data_type*
  XalanQNameByValueAllocator::create(
                        const XalanDOMString&   qname,
                        const PrefixResolver*   theResolver,
                        const Locator*                  locator)
  {
        data_type* const        theBlock = m_allocator.allocateBlock();
        assert(theBlock != 0);
  
        data_type* const        theResult =
                new(theBlock) data_type(qname, theResolver, locator);
  
        m_allocator.commitAllocation(theBlock);
  
        return theResult;
  }
  
  
  
  1.1                  xml-xalan/c/src/XPath/XalanQNameByValueAllocator.hpp
  
  Index: XalanQNameByValueAllocator.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  #if !defined(XALANQNAMEBYVALUEALLOCATOR_INCLUDE_GUARD_12455133)
  #define XALANQNAMEBYVALUEALLOCATOR_INCLUDE_GUARD_12455133
  
  
  
  // Base include file.  Must be first.
  #include <XPath/XPathDefinitions.hpp>
  
  
  
  #include <XPath/XalanQNameByValue.hpp>
  
  
  
  #include <PlatformSupport/ArenaAllocator.hpp>
  
  
  
  class XALAN_XPATH_EXPORT XalanQNameByValueAllocator
  {
  public:
  
        typedef XalanQNameByValue                                       data_type;
        typedef data_type::NamespacesStackType          NamespacesStackType;
  
  #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
        typedef ArenaBlock<data_type>                           ArenaBlockType;
        typedef ArenaAllocator<data_type,
                                                   ArenaBlockType>              
ArenaAllocatorType;
  #else
        typedef ArenaAllocator<data_type>                       ArenaAllocatorType;
  #endif
  
        typedef ArenaAllocatorType::size_type           size_type;
  
        /**
         * Construct an instance that will allocate blocks of the specified size.
         *
         * @param theBlockSize The block size.
         */
        XalanQNameByValueAllocator(size_type            theBlockCount);
  
        ~XalanQNameByValueAllocator();
        
        /**
         * Create an instance.
         *
         * @param theSource The source of the copy.
         *
         * @return A pointer to the new instance.
         */
        data_type*
        create(const XalanQNameByValue& theSource);
  
        /**
         * Create an instance.
         *
         * @param theNamespace namespace string
         * @param theLocalPart local part string
         *
         * @return A pointer to the new instance.
         */
        data_type*
        create(
                        const XalanDOMString&   theNamespaceURI,
                        const XalanDOMString&   theLocalPart);
  
        /**
         * Create an instance.
         *
         * @param qname       QName string
         * @param namespaces  namespace vector stack to use
         * @param locator     The Locator instance for error reporting, if any
         * @param fUseDefault If true, then elements with no prefix will have the 
default namespace URI, if there is one.
         *
         * @return A pointer to the new instance.
         */
        data_type*
        create(
                        const XalanDOMString&           qname,
                        const NamespacesStackType&      namespaces,
                        const Locator*                          locator = 0,
                        bool                                            fUseDefault = 
false);
  
        /**
         * Create an instance.
         *
         * @param qname       QName string
         * @param namespaces  namespace vector stack to use
         * @param locator     The Locator instance for error reporting, if any
         * @param fUseDefault If true, then elements with no prefix will have the 
default namespace URI, if there is one.
         *
         * @return A pointer to the new instance.
         */
        data_type*
        create(
                        const XalanDOMChar*                     qname,
                        const NamespacesStackType&      namespaces,
                        const Locator*                          locator = 0,
                        bool                                            fUseDefault = 
false);
  
        /**
         * Create an instance.
         *
         * @param qname            QName string
         * @param namespaceContext context object for namespace resolution
         * @param envSupport       XPathEnvSupport class instance
         * @param domSupport       DOMSupport class instance
         * @param locator          The Locator instance for error reporting, if any
         *
         * @return A pointer to the new instance.
         */
        data_type*
        create(
                        const XalanDOMString&   qname,
                        const XalanElement*             namespaceContext,
                        const XPathEnvSupport&  envSupport,
                        const DOMSupport&               domSupport,
                        const Locator*                  locator = 0);
  
        /**
         * Create an instance.
         *
         * @param qname       QName string
         * @param theResolver prefix resolver to use
         * @param locator     The Locator instance for error reporting, if any
         *
         * @return A pointer to the new instance.
         */
        data_type*
        create(
                        const XalanDOMString&   qname,
                        const PrefixResolver*   theResolver = 0,
                        const Locator*                  locator = 0);
  
        /**
         * Determine if an object is owned by the allocator...
         */
        bool
        ownsObject(const data_type*             theObject)
        {
                return m_allocator.ownsObject(theObject);
        }
  
        /**
         * Delete all objects from the allocator.        
         */     
        void
        reset()
        {
                m_allocator.reset();
        }
  
        /**
         * Get the number of ArenaBlocks currently allocated.
         *
         * @return The number of blocks.
         */
        size_type
        getBlockCount() const
        {
                return m_allocator.getBlockCount();
        }
  
        /**
         * Get size of an ArenaBlock, that is, the number
         * of objects in each block.
         *
         * @return The size of the block
         */
        size_type
        getBlockSize() const
        {
                return m_allocator.getBlockSize();
        }
  
  private:
  
        // Not implemented...
        XalanQNameByValueAllocator(const XalanQNameByValueAllocator&);
  
        XalanQNameByValueAllocator&
        operator=(const XalanQNameByValueAllocator&);
  
        // Data members...
        ArenaAllocatorType      m_allocator;
  };
  
  
  
  #endif        // XALANQNAMEBYVALUEALLOCATOR_INCLUDE_GUARD_12455133
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to