source: NonGTP/Xerces/xerces/include/xercesc/dom/deprecated/NodeIDMap.hpp @ 358

Revision 358, 3.1 KB checked in by bittner, 19 years ago (diff)

xerces added

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