00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 00019 #if !defined(XALANALLOCATOR_INCLUDE_GUARD_1357924680) 00020 #define XALANALLOCATOR_INCLUDE_GUARD_1357924680 00021 00022 00023 00024 #include <cstddef> 00025 00026 00027 00028 XALAN_CPP_NAMESPACE_BEGIN 00029 00030 00031 00032 template <class Type> 00033 class XalanAllocator 00034 { 00035 public: 00036 typedef size_t size_type; 00037 typedef ptrdiff_t difference_type; 00038 typedef Type* pointer; 00039 typedef const Type* const_pointer; 00040 typedef Type& reference; 00041 typedef const Type& const_reference; 00042 typedef Type value_type; 00043 00044 00045 XalanAllocator(MemoryManager& theManager) : 00046 m_memoryManager(theManager) 00047 { 00048 } 00049 00050 00051 ~XalanAllocator() 00052 { 00053 } 00054 00055 MemoryManager& 00056 getMemoryManager() 00057 { 00058 return m_memoryManager; 00059 } 00060 00061 pointer 00062 address(reference x) const 00063 { 00064 return &x; 00065 } 00066 00067 const_pointer 00068 address(const_reference x) const 00069 { 00070 return &x; 00071 } 00072 00073 pointer 00074 allocate( 00075 size_type size, 00076 const void* /* hint */ = 0) 00077 { 00078 return (pointer)m_memoryManager.allocate(size * sizeof(Type)); 00079 } 00080 00081 void 00082 deallocate( 00083 pointer p, 00084 size_type /* n */) 00085 { 00086 if( p == 0 ) 00087 { 00088 return; 00089 } 00090 00091 m_memoryManager.deallocate(p); 00092 } 00093 00094 size_type 00095 max_size() const 00096 { 00097 return ~0; 00098 } 00099 00100 void 00101 construct( 00102 pointer p, 00103 const Type& val) 00104 { 00105 new (p) Type(val); 00106 } 00107 00108 void 00109 destroy(pointer p) 00110 { 00111 p->Type::~Type(); 00112 } 00113 00114 private: 00115 XalanAllocator(const XalanAllocator<Type>&); 00116 00117 XalanAllocator<Type>& 00118 operator=(const XalanAllocator<Type>&); 00119 00120 MemoryManager& m_memoryManager; 00121 }; 00122 00123 00124 00125 XALAN_CPP_NAMESPACE_END 00126 00127 00128 00129 #endif // XALANALLOCATOR_INCLUDE_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|