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 #if !defined(XALANDOMSTRINGPOOL_HEADER_GUARD_1357924680) 00019 #define XALANDOMSTRINGPOOL_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/PlatformSupport/PlatformSupportDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/PlatformSupport/ArenaAllocator.hpp> 00029 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00030 #include <xalanc/PlatformSupport/XalanDOMStringAllocator.hpp> 00031 #include <xalanc/PlatformSupport/XalanDOMStringHashTable.hpp> 00032 00033 00034 00035 XALAN_CPP_NAMESPACE_BEGIN 00036 00037 00038 00039 class XALAN_PLATFORMSUPPORT_EXPORT XalanDOMStringPool 00040 { 00041 public: 00042 00043 enum { eDefaultBlockSize = 32, 00044 eDefaultBucketCount = XalanDOMStringHashTable::eDefaultBucketCount, 00045 eDefaultBucketSize = XalanDOMStringHashTable::eDefaultBucketSize }; 00046 00047 typedef XalanDOMStringAllocator AllocatorType; 00048 00049 typedef AllocatorType::size_type block_size_type; 00050 typedef size_t bucket_count_type; 00051 typedef XalanDOMStringHashTable::bucket_size_type bucket_size_type; 00052 00053 /** 00054 * Create a string pool. 00055 * 00056 * @param theBlockSize The block size for the allocator. 00057 * @param theBucketCount The number of buckets to use for the hash table. This should be a prime number for best results. 00058 * @param theBucketSize The initial size of each bucket in the hash table. 00059 */ 00060 explicit 00061 XalanDOMStringPool( 00062 MemoryManager& theManager, 00063 block_size_type theBlockSize = eDefaultBlockSize, 00064 bucket_count_type theBucketCount = eDefaultBucketCount, 00065 bucket_size_type theBucketSize = eDefaultBucketSize); 00066 00067 static XalanDOMStringPool* 00068 create( 00069 MemoryManager& theManager, 00070 block_size_type theBlockSize = eDefaultBlockSize, 00071 bucket_count_type theBucketCount = eDefaultBucketCount, 00072 bucket_size_type theBucketSize = eDefaultBucketSize); 00073 00074 00075 virtual 00076 ~XalanDOMStringPool(); 00077 00078 /** 00079 * Clear the pool. 00080 * 00081 */ 00082 virtual void 00083 clear(); 00084 00085 /** 00086 * Get the number of strings in the pool 00087 * 00088 * @return the size of the pool. 00089 */ 00090 virtual size_t 00091 size() const; 00092 00093 /** 00094 * Get a pooled string. If the string is not pooled, it is added. 00095 * 00096 * @param theString The string to pool. 00097 * @return a const reference to the pooled string. 00098 */ 00099 virtual const XalanDOMString& 00100 get(const XalanDOMString& theString); 00101 00102 /** 00103 * Get a pooled string. If the string is not pooled, it is added. 00104 * 00105 * @param theString The string to pool. 00106 * @param theLength The length of the string. If XalanDOMString::npos, the string is assumed to be null-terminated. 00107 * @return a const reference to the pooled string. 00108 */ 00109 virtual const XalanDOMString& 00110 get( 00111 const XalanDOMChar* theString, 00112 XalanDOMString::size_type theLength = XalanDOMString::npos); 00113 00114 /** 00115 * Get a reference to the pool's hash table. Useful for diagnostic 00116 * purposes. 00117 * 00118 * @return a const reference to the hash table. 00119 */ 00120 const XalanDOMStringHashTable& 00121 getHashTable() const 00122 { 00123 return m_hashTable; 00124 } 00125 00126 MemoryManager& 00127 getMemoryManager() 00128 { 00129 return m_hashTable.getMemoryManager(); 00130 } 00131 00132 const MemoryManager& 00133 getMemoryManager() const 00134 { 00135 return m_hashTable.getMemoryManager(); 00136 } 00137 00138 private: 00139 00140 // Not implemented, for now... 00141 XalanDOMStringPool(const XalanDOMStringPool&); 00142 00143 XalanDOMStringPool& 00144 operator=(const XalanDOMStringPool&); 00145 00146 bool 00147 operator==(const XalanDOMStringPool&) const; 00148 00149 // Data members... 00150 AllocatorType m_stringAllocator; 00151 00152 size_t m_stringCount; 00153 00154 XalanDOMStringHashTable m_hashTable; 00155 00156 static const XalanDOMString s_emptyString; 00157 }; 00158 00159 00160 00161 XALAN_CPP_NAMESPACE_END 00162 00163 00164 00165 #endif // !defined(XALANDOMSTRINGPOOL_HEADER_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 |
|