Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.9

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

XalanMemMgrHelper.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(XALANMEMMGRHELPER_HEADER_GUARD_1357924680)
00017 #define XALANMEMMGRHELPER_HEADER_GUARD_1357924680
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp>
00023 
00024 
00025 
00026 #include <xalanc/Include/XalanMemMgrAutoPtr.hpp>
00027 
00028 
00029 
00030 
00031 XALAN_CPP_NAMESPACE_BEGIN
00032 
00033 template <class Type>
00034 Type*
00035 cloneObjWithMemMgr(const Type& other, MemoryManagerType& theManager)
00036 {
00037 
00038     XalanMemMgrAutoPtr<Type, false> theGuard( theManager , (Type*)theManager.allocate(sizeof(Type)));
00039 
00040     Type* theResult = theGuard.get();
00041 
00042     new (theResult) Type(other, theManager);
00043 
00044     theGuard.release();
00045     
00046     return theResult;
00047 }
00048 
00049 
00050 
00051 template <class Type>
00052 Type*
00053 cloneObj(const Type& other, MemoryManagerType& theManager)
00054 {
00055 
00056     XalanMemMgrAutoPtr<Type, false> theGuard( theManager , (Type*)theManager.allocate(sizeof(Type)));
00057 
00058     Type* theResult = theGuard.get();
00059 
00060     new (theResult) Type(other);
00061 
00062     theGuard.release();
00063     
00064     return theResult;
00065 }
00066 
00067 template <class Type>
00068 class CreateObjFunctor
00069 {
00070 public:
00071     Type*
00072     operator()(MemoryManagerType& theManager)
00073     {
00074         
00075         XalanMemMgrAutoPtr<Type, false> theGuard( theManager , (Type*)theManager.allocate(sizeof(Type)));
00076         
00077         Type* theResult = theGuard.get();
00078         
00079         new (theResult) Type(theManager);
00080         
00081         theGuard.release();
00082         
00083         return theResult;
00084     }
00085 };
00086 
00087 template <class Type>
00088 void
00089 destroyObjWithMemMgr( Type* ptr, MemoryManagerType& theManager)
00090 {
00091     if( ptr == 0 )
00092         return;
00093 
00094     ptr->~Type();
00095 
00096     theManager.deallocate((void*)ptr);
00097 }
00098 
00099 
00100 
00101 XALAN_CPP_NAMESPACE_END
00102 
00103 
00104 
00105 #endif  // if !defined(XALANMEMMGRHELPER_HEADER_GUARD_1357924680)

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.9
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.