Xalan-C++ API Reference 1.12.0
XalanAllocator.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#if !defined(XALANALLOCATOR_INCLUDE_GUARD_1357924680)
20#define XALANALLOCATOR_INCLUDE_GUARD_1357924680
21
22
23
24#include <cstddef>
25
26
27
28namespace XALAN_CPP_NAMESPACE {
29
30
31
32template <class Type>
34{
35public:
36 typedef size_t size_type;
38 typedef Type* pointer;
39 typedef const Type* const_pointer;
40 typedef Type& reference;
41 typedef const Type& const_reference;
43
44
45 XalanAllocator(MemoryManager& theManager) :
46 m_memoryManager(theManager)
47 {
48 }
49
50
52 {
53 }
54
55 MemoryManager&
57 {
58 return m_memoryManager;
59 }
60
61 pointer
63 {
64 return &x;
65 }
66
67 const_pointer
69 {
70 return &x;
71 }
72
73 pointer
75 size_type size,
76 const void* /* hint */ = 0)
77 {
78 return (pointer)m_memoryManager.allocate(size * sizeof(Type));
79 }
80
81 void
83 pointer p,
84 size_type /* n */)
85 {
86 if( p == 0 )
87 {
88 return;
89 }
90
91 m_memoryManager.deallocate(p);
92 }
93
95 max_size() const
96 {
97 return ~0;
98 }
99
100 void
102 pointer p,
103 const Type& val)
104 {
105 new (p) Type(val);
106 }
107
108 void
110 {
111 p->Type::~Type();
112 }
113
114private:
116
118 operator=(const XalanAllocator<Type>&);
119
120 MemoryManager& m_memoryManager;
121};
122
123
124
125}
126
127
128
129#endif // XALANALLOCATOR_INCLUDE_GUARD_1357924680
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
pointer address(reference x) const
size_type max_size() const
pointer allocate(size_type size, const void *=0)
const_pointer address(const_reference x) const
XalanAllocator(MemoryManager &theManager)
void deallocate(pointer p, size_type)
void construct(pointer p, const Type &val)
MemoryManager & getMemoryManager()
size_t size_type
Definition XalanMap.hpp:46