Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

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

XObjectFactory.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #if !defined(XOBJECTFACTORY_HEADER_GUARD_1357924680)
00017 #define XOBJECTFACTORY_HEADER_GUARD_1357924680
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/XPath/XPathDefinitions.hpp>
00023 
00024 
00025 
00026 #include <algorithm>
00027 #include <cassert>
00028 
00029 
00030 #include <xalanc/XPath/XObject.hpp>
00031 #include <xalanc/XPath/XPathExecutionContext.hpp>
00032 
00033 
00034 
00035 XALAN_CPP_NAMESPACE_BEGIN
00036 
00037 
00038 
00039 class XalanNode;
00040 class MutableNodeRefList;
00041 class NodeRefListBase;
00042 class XObject;
00043 class XObjectPtr;
00044 class XToken;
00045 
00046 
00047 
00051 class XALAN_XPATH_EXPORT XObjectFactory
00052 {
00053 public:
00054 
00055     typedef XPathExecutionContext::BorrowReturnMutableNodeRefList   BorrowReturnMutableNodeRefList;
00056     typedef XPathExecutionContext::GetAndReleaseCachedString        GetAndReleaseCachedString;
00057 
00058 
00059     XObjectFactory(MemoryManagerType& theManager);
00060 
00061     virtual
00062     ~XObjectFactory();
00063 
00064 
00065     MemoryManagerType&
00066     getMemoryManager()
00067     {
00068         return m_memoryManager;
00069     }
00070 
00077     bool
00078     returnObject(XObject*   theXObject)
00079     {
00080         return doReturnObject(theXObject);
00081     }
00082 
00087     virtual void
00088     reset() = 0;
00089 
00096     virtual const XObjectPtr
00097     createBoolean(bool  theValue) = 0;
00098 
00105     virtual const XObjectPtr
00106     createNodeSet(BorrowReturnMutableNodeRefList&   theValue) = 0;
00107 
00114     virtual const XObjectPtr
00115     createNodeSet(XalanNode*    theValue) = 0;
00116 
00123     virtual const XObjectPtr
00124     createNull() = 0;
00125 
00132     virtual const XObjectPtr
00133     createNumber(double     theValue) = 0;
00134 
00143     virtual const XObjectPtr
00144     createNumber(const XToken&  theValue) = 0;
00145 
00152     virtual const XObjectPtr
00153     createString(const XalanDOMString&  theValue) = 0;
00154 
00161     virtual const XObjectPtr
00162     createString(const XalanDOMChar*    theValue) = 0;
00163 
00171     virtual const XObjectPtr
00172     createString(
00173             const XalanDOMChar*     theValue,
00174             unsigned int            theLength) = 0;
00175 
00184     virtual const XObjectPtr
00185     createString(const XToken&  theValue) = 0;
00186 
00196     virtual const XObjectPtr
00197     createStringReference(const XalanDOMString&     theValue) = 0;
00198 
00207     virtual const XObjectPtr
00208     createStringAdapter(const XObjectPtr&   theValue) = 0;
00209 
00216     virtual const XObjectPtr
00217     createString(GetAndReleaseCachedString&     theValue) = 0;
00218 
00225     virtual const XObjectPtr
00226     createUnknown(const XalanDOMString&     theValue) = 0;
00227 
00233 #if defined(XALAN_NO_STD_NAMESPACE)
00234     struct DeleteXObjectFunctor : public unary_function<XObject*, void>
00235 #else
00236     struct DeleteXObjectFunctor : public std::unary_function<XObject*, void>
00237 #endif
00238     {
00239     public:
00240 
00241         DeleteXObjectFunctor(
00242             XObjectFactory&     theFactoryInstance,
00243             bool                fInReset = false) :
00244             m_factoryInstance(theFactoryInstance),
00245             m_fInReset(fInReset)
00246         {
00247         }
00248 
00249         result_type
00250         operator()(argument_type    theXObject) const
00251         {
00252             if (m_fInReset == true)
00253             {
00254                 m_factoryInstance.doReturnObject(
00255                     theXObject,
00256                     true);
00257             }
00258             else
00259             {
00260                 m_factoryInstance.returnObject(theXObject);
00261             }
00262         }
00263 
00264     private:
00265 
00266         XObjectFactory&     m_factoryInstance;
00267 
00268         const bool          m_fInReset;
00269     };
00270 
00271     friend struct DeleteXObjectFunctor;
00272 
00273 protected:
00274 
00280     XObject::eObjectType
00281     getRealType(const XObject&  theXObject) const
00282     {
00283         return theXObject.getRealType();
00284     }
00285 
00291     void
00292     deleteObject(const XObject*     theXObject) const
00293     {
00294         if( theXObject!= 0)
00295         {
00296             XObject*    theTmpXObject = const_cast<XObject*>(theXObject);
00297             MemoryManagerType& theManager = const_cast<MemoryManagerType&>(m_memoryManager);
00298 
00299             theTmpXObject->~XObject();
00300 
00301             theManager.deallocate((void*)theTmpXObject);
00302         }
00303     
00304     }
00305 
00312 
00313     virtual bool
00314     doReturnObject(
00315             XObject*    theXObject,
00316             bool        fInReset = false) = 0;
00317 
00318 private:
00319 
00320     // Not implemented...
00321     XObjectFactory(const XObjectFactory&);
00322 
00323     XObjectFactory&
00324     operator=(const XObjectFactory&);
00325 
00326     bool
00327     operator==(const XObjectFactory&) const;
00328 
00329     MemoryManagerType& m_memoryManager;
00330 };
00331 
00332 
00333 
00334 XALAN_CPP_NAMESPACE_END
00335 
00336 
00337 
00338 #endif  // XOBJECTFACTORY_HEADER_GUARD_1357924680

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo