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  

XalanAllocator.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 
00017 #if !defined(XALANALLOCATOR_INCLUDE_GUARD_1357924680)
00018 #define XALANALLOCATOR_INCLUDE_GUARD_1357924680
00019 
00020 
00021 
00022 #include <cstddef>
00023 
00024 
00025 
00026 XALAN_CPP_NAMESPACE_BEGIN
00027 
00028 
00029 
00030 template <class Type>
00031 class XalanAllocator
00032 {
00033 public:
00034     typedef size_t          size_type;
00035     typedef ptrdiff_t       difference_type;
00036     typedef Type*           pointer;
00037     typedef const Type*     const_pointer;
00038     typedef Type&           reference;
00039     typedef const Type&     const_reference;
00040     typedef Type            value_type;
00041 
00042     
00043     XalanAllocator(MemoryManagerType&      theManager) :
00044         m_memoryManager(theManager)
00045     {
00046     }
00047 
00048 
00049     ~XalanAllocator()
00050     {
00051     }
00052     
00053     MemoryManagerType&
00054     getMemoryManager()
00055     {
00056         return m_memoryManager;
00057     }
00058     
00059     pointer
00060     address(reference   x) const
00061     {
00062         return &x;
00063     }
00064 
00065     const_pointer
00066     address(const_reference     x) const
00067     {
00068         return &x;
00069     }
00070 
00071     pointer
00072     allocate(
00073             size_type       size,
00074             const void*     /* hint */ = 0)
00075     {
00076         return (pointer)m_memoryManager.allocate(size * sizeof(Type));
00077     }
00078 
00079     void
00080     deallocate(
00081                 pointer     p,
00082                 size_type   /* n */)
00083     {
00084         if( p == 0 )
00085         {
00086             return;
00087         }
00088 
00089         m_memoryManager.deallocate(p);
00090     }
00091 
00092     size_type
00093     max_size() const
00094     {
00095         return ~0;
00096     }
00097 
00098     void
00099     construct(
00100             pointer         p,
00101             const Type&     val)
00102     {
00103         new (p) Type(val);
00104     }
00105 
00106     void
00107     destroy(pointer     p)
00108     {
00109         p->Type::~Type();
00110     }
00111     
00112 private:
00113     XalanAllocator(const XalanAllocator<Type>&);
00114     
00115     XalanAllocator<Type>&
00116     operator=(const XalanAllocator<Type>&);
00117     
00118     MemoryManagerType&      m_memoryManager;
00119 };
00120 
00121 
00122 
00123 XALAN_CPP_NAMESPACE_END
00124 
00125 
00126 
00127 #endif  // XALANALLOCATOR_INCLUDE_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