Xalan-C++ API Reference 1.12.0
XalanDOMStringPool.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#if !defined(XALANDOMSTRINGPOOL_HEADER_GUARD_1357924680)
19#define XALANDOMSTRINGPOOL_HEADER_GUARD_1357924680
20
21
22
23// Base include file. Must be first.
25
26
27
32
33
34
35namespace XALAN_CPP_NAMESPACE {
36
37
38
40{
41public:
42
43 enum { eDefaultBlockSize = 32,
44 eDefaultBucketCount = XalanDOMStringHashTable::eDefaultBucketCount,
45 eDefaultBucketSize = XalanDOMStringHashTable::eDefaultBucketSize };
46
48
50 typedef size_t bucket_count_type;
52
53 /**
54 * Create a string pool.
55 *
56 * @param theBlockSize The block size for the allocator.
57 * @param theBucketCount The number of buckets to use for the hash table. This should be a prime number for best results.
58 * @param theBucketSize The initial size of each bucket in the hash table.
59 */
60 explicit
62 MemoryManager& theManager,
63 block_size_type theBlockSize = eDefaultBlockSize,
64 bucket_count_type theBucketCount = eDefaultBucketCount,
65 bucket_size_type theBucketSize = eDefaultBucketSize);
66
67 static XalanDOMStringPool*
69 MemoryManager& theManager,
70 block_size_type theBlockSize = eDefaultBlockSize,
71 bucket_count_type theBucketCount = eDefaultBucketCount,
72 bucket_size_type theBucketSize = eDefaultBucketSize);
73
74
75 virtual
77
78 /**
79 * Clear the pool.
80 *
81 */
82 virtual void
84
85 /**
86 * Get the number of strings in the pool
87 *
88 * @return the size of the pool.
89 */
90 virtual size_t
91 size() const;
92
93 /**
94 * Get a pooled string. If the string is not pooled, it is added.
95 *
96 * @param theString The string to pool.
97 * @return a const reference to the pooled string.
98 */
99 virtual const XalanDOMString&
101
102 /**
103 * Get a pooled string. If the string is not pooled, it is added.
104 *
105 * @param theString The string to pool.
106 * @param theLength The length of the string. If XalanDOMString::npos, the string is assumed to be null-terminated.
107 * @return a const reference to the pooled string.
108 */
109 virtual const XalanDOMString&
111 const XalanDOMChar* theString,
112 XalanDOMString::size_type theLength = XalanDOMString::npos);
113
114 /**
115 * Get a reference to the pool's hash table. Useful for diagnostic
116 * purposes.
117 *
118 * @return a const reference to the hash table.
119 */
122 {
123 return m_hashTable;
124 }
125
126 MemoryManager&
128 {
129 return m_hashTable.getMemoryManager();
130 }
131
132 const MemoryManager&
134 {
135 return m_hashTable.getMemoryManager();
136 }
137
138private:
139
140 // Not implemented, for now...
142
144 operator=(const XalanDOMStringPool&);
145
146 bool
147 operator==(const XalanDOMStringPool&) const;
148
149 // Data members...
150 AllocatorType m_stringAllocator;
151
152 size_t m_stringCount;
153
154 XalanDOMStringHashTable m_hashTable;
155
156 static const XalanDOMString s_emptyString;
157};
158
159
160
161}
162
163
164
165#endif // !defined(XALANDOMSTRINGPOOL_HEADER_GUARD_1357924680)
#define XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
ArenaAllocatorType::size_type size_type
virtual void clear()
Clear the pool.
const XalanDOMStringHashTable & getHashTable() const
Get a reference to the pool's hash table.
virtual size_t size() const
Get the number of strings in the pool.
XalanDOMStringAllocator AllocatorType
static XalanDOMStringPool * create(MemoryManager &theManager, block_size_type theBlockSize=eDefaultBlockSize, bucket_count_type theBucketCount=eDefaultBucketCount, bucket_size_type theBucketSize=eDefaultBucketSize)
XalanDOMStringPool(MemoryManager &theManager, block_size_type theBlockSize=eDefaultBlockSize, bucket_count_type theBucketCount=eDefaultBucketCount, bucket_size_type theBucketSize=eDefaultBucketSize)
Create a string pool.
virtual const XalanDOMString & get(const XalanDOMString &theString)
Get a pooled string.
virtual const XalanDOMString & get(const XalanDOMChar *theString, XalanDOMString::size_type theLength=XalanDOMString::npos)
Get a pooled string.
const MemoryManager & getMemoryManager() const
XalanDOMStringHashTable::bucket_size_type bucket_size_type
AllocatorType::size_type block_size_type
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)