[2674] | 1 | #ifndef NodeIDMap_HEADER_GUARD_ |
---|
| 2 | #define NodeIDMap_HEADER_GUARD_ |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
| 6 | * contributor license agreements. See the NOTICE file distributed with |
---|
| 7 | * this work for additional information regarding copyright ownership. |
---|
| 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
| 9 | * (the "License"); you may not use this file except in compliance with |
---|
| 10 | * the License. You may obtain a copy of the License at |
---|
| 11 | * |
---|
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
| 13 | * |
---|
| 14 | * Unless required by applicable law or agreed to in writing, software |
---|
| 15 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
| 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
| 17 | * See the License for the specific language governing permissions and |
---|
| 18 | * limitations under the License. |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | // |
---|
| 23 | // This file is part of the internal implementation of the C++ XML DOM. |
---|
| 24 | // It should NOT be included or used directly by application programs. |
---|
| 25 | // |
---|
| 26 | // Applications should include the file <xercesc/dom/deprecated/DOM.hpp> for the entire |
---|
| 27 | // DOM API, or DOM_*.hpp for individual DOM classes, where the class |
---|
| 28 | // name is substituded for the *. |
---|
| 29 | // |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | // |
---|
| 35 | // Class NodeIDMap is a hash table that is used in the implementation of |
---|
| 36 | // of DOM_Document::getElementsByID(). |
---|
| 37 | // |
---|
| 38 | // Why Yet Another HashTable implementation? Becuase it can be significantly |
---|
| 39 | // smaller when tuned for this exact usage, and the generic RefHashTableOf |
---|
| 40 | // from the xerces utils project is not a paricularly good fit. |
---|
| 41 | // |
---|
| 42 | #include <xercesc/util/PlatformUtils.hpp> |
---|
| 43 | |
---|
| 44 | XERCES_CPP_NAMESPACE_BEGIN |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | class AttrImpl; |
---|
| 48 | class DOMString; |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | class NodeIDMap : public XMemory { |
---|
| 52 | public: |
---|
| 53 | |
---|
| 54 | // Create a new hash table, sized to hold "initialSize" |
---|
| 55 | NodeIDMap(int initialSize, |
---|
| 56 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
| 57 | // Entries. It will automatically grow if need be. |
---|
| 58 | |
---|
| 59 | virtual ~NodeIDMap(); |
---|
| 60 | |
---|
| 61 | private: |
---|
| 62 | NodeIDMap(const NodeIDMap &other); // No copy, assignement, comparison. |
---|
| 63 | NodeIDMap &operator = (const NodeIDMap &other); |
---|
| 64 | bool operator == (const NodeIDMap &other); |
---|
| 65 | |
---|
| 66 | public: |
---|
| 67 | void add(AttrImpl *attr); // Add the specified attribute to the table. |
---|
| 68 | void remove(AttrImpl *other); // Remove the specified attribute. |
---|
| 69 | // Does nothing if the node is not in the table. |
---|
| 70 | AttrImpl *find(const DOMString &ID); // Find the attribute node in the table with this ID |
---|
| 71 | |
---|
| 72 | private: |
---|
| 73 | void growTable(); |
---|
| 74 | |
---|
| 75 | private: |
---|
| 76 | AttrImpl **fTable; |
---|
| 77 | unsigned int fSizeIndex; // Index of the current table size in the |
---|
| 78 | // array of possible table sizes. |
---|
| 79 | unsigned int fSize; // The current size of the table array |
---|
| 80 | // (number of slots, not bytes.) |
---|
| 81 | unsigned int fNumEntries; // The number of entries used. |
---|
| 82 | unsigned int fMaxEntries; // The max number of entries to use before |
---|
| 83 | // growing the table. |
---|
| 84 | MemoryManager* fMemoryManager; |
---|
| 85 | |
---|
| 86 | }; |
---|
| 87 | |
---|
| 88 | XERCES_CPP_NAMESPACE_END |
---|
| 89 | |
---|
| 90 | #endif |
---|