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(XALANDOMSTRINGALLOCATOR_INCLUDE_GUARD_12455133) 00020 #define XALANDOMSTRINGALLOCATOR_INCLUDE_GUARD_12455133 00021 00022 00023 00024 // Base include file. Must be first. 00025 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00026 00027 00028 00029 #include <xalanc/PlatformSupport/ArenaAllocator.hpp> 00030 00031 00032 00033 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00034 00035 00036 00037 XALAN_CPP_NAMESPACE_BEGIN 00038 00039 00040 00041 class XALAN_PLATFORMSUPPORT_EXPORT XalanDOMStringAllocator 00042 { 00043 public: 00044 00045 typedef XalanDOMString data_type; 00046 typedef data_type::size_type data_type_size_type; 00047 00048 #if defined(XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS) 00049 typedef ArenaBlock<data_type> ArenaBlockType; 00050 00051 typedef ArenaAllocator<data_type, 00052 ArenaBlockType> ArenaAllocatorType; 00053 #else 00054 typedef ArenaAllocator<data_type> ArenaAllocatorType; 00055 #endif 00056 00057 typedef ArenaAllocatorType::size_type size_type; 00058 00059 enum { eDefaultBlockSize = 32 }; 00060 00061 00062 /** 00063 * Construct an instance that will allocate in blocks of the specified size. 00064 * 00065 * @param theBlockSize The block size. 00066 */ 00067 XalanDOMStringAllocator(MemoryManager& theManager, size_type theBlockCount); 00068 00069 ~XalanDOMStringAllocator(); 00070 00071 /** 00072 * Create a XalanDOMString object. 00073 * 00074 * @return pointer to the new instance 00075 */ 00076 data_type* 00077 create(); 00078 00079 /** 00080 * Create a XalanDOMString object. 00081 * 00082 * @param theString A pointer to a character string 00083 * @param theCount The number of characters in the string, or npos if the string is null-terminated. 00084 * 00085 * @return pointer to the new instance 00086 */ 00087 data_type* 00088 create( 00089 const char* theString, 00090 #if defined(_MSC_VER) && (_MSC_VER <= 1300) 00091 // $$$ ToDo: Some strange bug in MSVC++ complains when using data_type::npos here. 00092 data_type_size_type theCount = data_type_size_type(-1)); 00093 #else 00094 data_type_size_type theCount = data_type_size_type(data_type::npos)); 00095 #endif 00096 00097 /** 00098 * Copy constructor 00099 * 00100 * @param theSource The source string for the copy 00101 * @param theStartPosition The position to start in the source string. 00102 * @param theCount The number of characters to copy from the source string. 00103 * 00104 * @return pointer to the new instance 00105 */ 00106 data_type* 00107 create( 00108 const data_type& theSource, 00109 data_type_size_type theStartPosition = 0, 00110 data_type_size_type theCount = data_type_size_type(data_type::npos)); 00111 00112 /** 00113 * Create a XalanDOMString object. 00114 * 00115 * @param theString A pointer to a wide character string 00116 * @param theCount The number of characters in the string, or npos if the string is null-terminated. 00117 * 00118 * @return pointer to the new instance 00119 */ 00120 data_type* 00121 create( 00122 const XalanDOMChar* theString, 00123 data_type_size_type theCount = data_type_size_type(data_type::npos)); 00124 00125 /** 00126 * Create a XalanDOMString object. 00127 * 00128 * @param theCount the size of the string 00129 * @param theChar the character used to initialize the string 00130 * 00131 * @return pointer to the new instance 00132 */ 00133 data_type* 00134 create( 00135 data_type_size_type theCount, 00136 XalanDOMChar theChar); 00137 00138 /** 00139 * Determine if an object is owned by the allocator... 00140 */ 00141 bool 00142 ownsObject(const data_type* theObject) 00143 { 00144 return m_allocator.ownsObject(theObject); 00145 } 00146 00147 /** 00148 * Delete all instance objects from allocator. 00149 */ 00150 void 00151 reset() 00152 { 00153 m_allocator.reset(); 00154 } 00155 00156 /** 00157 * Get the number of ArenaBlocks currently allocated. 00158 * 00159 * @return The number of blocks. 00160 */ 00161 size_type 00162 getBlockCount() const 00163 { 00164 return m_allocator.getBlockCount(); 00165 } 00166 00167 /** 00168 * Get size of an ArenaBlock, that is, the number 00169 * of objects in each block. 00170 * 00171 * @return The size of the block 00172 */ 00173 size_type 00174 getBlockSize() const 00175 { 00176 return m_allocator.getBlockSize(); 00177 } 00178 00179 /** 00180 * Get a reference to the MemoryManager instance 00181 * for this instance. 00182 * 00183 * @return A reference to the MemoryManager instance. 00184 */ 00185 MemoryManager& 00186 getMemoryManager() 00187 { 00188 return m_allocator.getMemoryManager(); 00189 } 00190 00191 /** 00192 * Get a reference to the MemoryManager instance 00193 * for this instance. 00194 * 00195 * @return A reference to the MemoryManager instance. 00196 */ 00197 const MemoryManager& 00198 getMemoryManager() const 00199 { 00200 return m_allocator.getMemoryManager(); 00201 } 00202 00203 private: 00204 00205 // Not implemented... 00206 XalanDOMStringAllocator(const XalanDOMStringAllocator&); 00207 00208 XalanDOMStringAllocator& 00209 operator=(const XalanDOMStringAllocator&); 00210 00211 // Data members... 00212 ArenaAllocatorType m_allocator; 00213 }; 00214 00215 00216 00217 XALAN_CPP_NAMESPACE_END 00218 00219 00220 00221 #endif // XALANDOMSTRINGALLOCATOR_INCLUDE_GUARD_12455133
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|