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(XSTRINGCACHEDALLOCATOR_INCLUDE_GUARD_1357924680) 00020 #define XSTRINGCACHEDALLOCATOR_INCLUDE_GUARD_1357924680 00021 00022 00023 00024 // Base include file. Must be first. 00025 #include <xalanc/XPath/XPathDefinitions.hpp> 00026 00027 00028 00029 #include <xalanc/XPath/XStringCached.hpp> 00030 00031 00032 00033 #include <xalanc/PlatformSupport/ReusableArenaAllocator.hpp> 00034 00035 00036 00037 XALAN_CPP_NAMESPACE_BEGIN 00038 00039 00040 00041 class XALAN_XPATH_EXPORT XStringCachedAllocator 00042 { 00043 public: 00044 00045 typedef XStringCached string_type; 00046 00047 typedef string_type::GetCachedString GetCachedString; 00048 00049 typedef ReusableArenaAllocator<string_type> ArenaAllocatorType; 00050 typedef ArenaAllocatorType::size_type size_type; 00051 00052 /** 00053 * Construct an instance that will allocate blocks of the specified size. 00054 * 00055 * @param theBlockSize The block size. 00056 */ 00057 XStringCachedAllocator( 00058 MemoryManager& theManager, 00059 size_type theBlockCount); 00060 00061 ~XStringCachedAllocator(); 00062 00063 /** 00064 * Create an XString object from a cached string. 00065 * 00066 * @param theXObject The source cached string 00067 * 00068 * @return a pointer to the new XStringCached instance. 00069 */ 00070 string_type* 00071 createString(GetCachedString& theValue); 00072 00073 00074 /** 00075 * Delete an XStringCached object from allocator. 00076 */ 00077 bool 00078 destroy(string_type* theString); 00079 00080 /** 00081 * Determine if an object is owned by the allocator... 00082 */ 00083 bool 00084 ownsObject(const string_type* theObject) 00085 { 00086 return m_allocator.ownsObject(theObject); 00087 } 00088 00089 /** 00090 * Delete all XStringCached objects from allocator. 00091 */ 00092 void 00093 reset(); 00094 00095 /** 00096 * Get size of an ArenaBlock, that is, the number 00097 * of objects in each block. 00098 * 00099 * @return The size of the block 00100 */ 00101 size_type 00102 getBlockCount() const 00103 { 00104 return m_allocator.getBlockCount(); 00105 } 00106 00107 /** 00108 * Get the number of ArenaBlocks currently allocated. 00109 * 00110 * @return The number of blocks. 00111 */ 00112 size_type 00113 getBlockSize() const 00114 { 00115 return m_allocator.getBlockSize(); 00116 } 00117 00118 private: 00119 00120 // Not implemented... 00121 XStringCachedAllocator(const XStringCachedAllocator&); 00122 00123 XStringCachedAllocator& 00124 operator=(const XStringCachedAllocator&); 00125 00126 // Data members... 00127 ArenaAllocatorType m_allocator; 00128 }; 00129 00130 00131 00132 XALAN_CPP_NAMESPACE_END 00133 00134 00135 00136 #endif // XSTRINGCACHEDALLOCATOR_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 |
|