Xalan-C++ API Reference 1.12.0
XalanDOMStringReusableAllocator.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(XALANDOMSTRINGREUSABLEALLOCATOR_INCLUDE_GUARD_12455133)
20#define XALANDOMSTRINGREUSABLEALLOCATOR_INCLUDE_GUARD_12455133
21
22
23
24// Base include file. Must be first.
26
27
28
30
31
32
34
35
36
37namespace XALAN_CPP_NAMESPACE {
38
39
40
42{
43public:
44
47
48#if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS)
50
53#else
55#endif
56
58
59 enum { eDefaultBlockSize = 32 };
60
61
62 /**
63 * Construct an instance that will allocate in blocks of the specified size.
64 *
65 * @param theBlockSize The block size.
66 */
68
70
71 /**
72 * Create a XalanDOMString object.
73 *
74 * @return reference to the new instance
75 */
78
79 /**
80 * Create a XalanDOMString object.
81 *
82 * @param theString A pointer to a character string
83 * @param theCount The number of characters in the string, or npos if the string is null-terminated.
84 *
85 * @return reference to the new instance
86 */
89 const char* theString,
90#if defined(_MSC_VER) && (_MSC_VER <= 1300)
91 // $$$ ToDo: Some strange bug in MSVC++ complains when using data_type::npos here.
93#else
95#endif
96
97 /**
98 * Copy constructor
99 *
100 * @param theSource The source string for the copy
101 * @param theStartPosition The position to start in the source string.
102 * @param theCount The number of characters to copy from the source string.
103 *
104 * @return reference to the new instance
105 */
106 data_type&
108 const data_type& theSource,
111
112 /**
113 * Create a XalanDOMString object.
114 *
115 * @param theString A pointer to a wide character string
116 * @param theCount The number of characters in the string, or npos if the string is null-terminated.
117 *
118 * @return reference to the new instance
119 */
120 data_type&
122 const XalanDOMChar* theString,
124
125 /**
126 * Create a XalanDOMString object.
127 *
128 * @param theCount the size of the string
129 * @param theChar the character used to initialize the string
130 *
131 * @return reference to the new instance
132 */
133 data_type&
137
138 /*
139 * Destroy a XalanDOMString object.
140 *
141 */
142 bool
144 {
145 return m_allocator.destroyObject(&theDOMString);
146 }
147
148 /**
149 * Determine if an object is owned by the allocator...
150 */
151 bool
153 {
154 return m_allocator.ownsObject(theObject);
155 }
156
157 /**
158 * Delete all instance objects from allocator.
159 */
160 void
162 {
163 m_allocator.reset();
164 }
165
166 /**
167 * Get the number of ArenaBlocks currently allocated.
168 *
169 * @return The number of blocks.
170 */
173 {
174 return m_allocator.getBlockCount();
175 }
176
177 /**
178 * Get size of an ArenaBlock, that is, the number
179 * of objects in each block.
180 *
181 * @return The size of the block
182 */
185 {
186 return m_allocator.getBlockSize();
187 }
188
189 /**
190 * Get a reference to the MemoryManager instance
191 * for this instance.
192 *
193 * @return A reference to the MemoryManager instance.
194 */
195 MemoryManager&
197 {
198 return m_allocator.getMemoryManager();
199 }
200
201 /**
202 * Get a reference to the MemoryManager instance
203 * for this instance.
204 *
205 * @return A reference to the MemoryManager instance.
206 */
207 const MemoryManager&
209 {
210 return m_allocator.getMemoryManager();
211 }
212
213private:
214
215 // Not implemented...
217
219 operator=(const XalanDOMStringReusableAllocator&);
220
221 // Data members...
222 ArenaAllocatorType m_allocator;
223};
224
225
226
227}
228
229
230
231#endif // XALANDOMSTRINGREUSABLEALLOCATOR_INCLUDE_GUARD_12455133
#define XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
data_type & create(data_type_size_type theCount, XalanDOMChar theChar)
Create a XalanDOMString object.
data_type & create(const char *theString, data_type_size_type theCount=data_type_size_type(data_type::npos))
Create a XalanDOMString object.
void reset()
Delete all instance objects from allocator.
bool ownsObject(const data_type *theObject)
Determine if an object is owned by the allocator...
data_type & create()
Create a XalanDOMString object.
data_type & create(const XalanDOMChar *theString, data_type_size_type theCount=data_type_size_type(data_type::npos))
Create a XalanDOMString object.
XalanDOMStringReusableAllocator(MemoryManager &theManager, size_type theBlockCount)
Construct an instance that will allocate in blocks of the specified size.
data_type & create(const data_type &theSource, data_type_size_type theStartPosition=0, data_type_size_type theCount=data_type_size_type(data_type::npos))
Copy constructor.
ReusableArenaAllocator< data_type > ArenaAllocatorType
const MemoryManager & getMemoryManager() const
Get a reference to the MemoryManager instance for this instance.
size_type getBlockSize() const
Get size of an ArenaBlock, that is, the number of objects in each block.
MemoryManager & getMemoryManager()
Get a reference to the MemoryManager instance for this instance.
size_type getBlockCount() const
Get the number of ArenaBlocks currently allocated.
void reset(MemoryManager *theManager=0, Type *thePointer=0)
size_t size_type
Definition XalanMap.hpp:46