You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by jp...@locus.apache.org on 2000/06/28 19:51:42 UTC
cvs commit: xml-xerces/c/src/dom DocumentImpl.cpp DocumentImpl.hpp NodeImpl.cpp
jpolast 00/06/28 10:51:41
Modified: c/src/dom DocumentImpl.cpp DocumentImpl.hpp NodeImpl.cpp
Log:
update to store userData in a hashtable attached to
the document instead of a pointer on every node.
Revision Changes Path
1.26 +29 -3 xml-xerces/c/src/dom/DocumentImpl.cpp
Index: DocumentImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DocumentImpl.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- DocumentImpl.cpp 2000/06/02 00:45:42 1.25
+++ DocumentImpl.cpp 2000/06/28 17:51:37 1.26
@@ -55,7 +55,7 @@
*/
/*
- * $Id: DocumentImpl.cpp,v 1.25 2000/06/02 00:45:42 andyh Exp $
+ * $Id: DocumentImpl.cpp,v 1.26 2000/06/28 17:51:37 jpolast Exp $
*/
//
@@ -88,8 +88,8 @@
#include "NodeIteratorImpl.hpp"
#include "NodeIDMap.hpp"
#include "DOM_Document.hpp"
+#include <util/HashPtr.hpp>
-
DocumentImpl::DocumentImpl()
: ParentNode(this)
{
@@ -99,6 +99,7 @@
iterators = 0L;
treeWalkers = 0L;
fNodeIDMap = 0;
+ userData = 0;
};
@@ -119,6 +120,7 @@
iterators = 0;
treeWalkers = 0;
fNodeIDMap = 0;
+ userData = 0;
}
void DocumentImpl::setDocumentType(DocumentTypeImpl *doctype)
@@ -157,6 +159,8 @@
delete treeWalkers;
}
+ if (userData)
+ delete userData;
delete namePool;
// Do not delete docType and docElement pointers here.
@@ -742,4 +746,26 @@
int p=parent->getNodeType();
int ch = child->getNodeType();
return (kidOK[p] & 1<<ch) != 0;
-};
+}
+
+void DocumentImpl::setUserData(NodeImpl* n, void* data)
+{
+ if (!userData)
+ userData = new RefHashTableOf<void>(29, false, new HashPtr());
+ userData->put((void*)n,data);
+}
+
+void* DocumentImpl::getUserData(NodeImpl* n)
+{
+ return userData->get((void*)n);
+}
+
+void* DocumentImpl::getUserData()
+{
+ return getUserData(this);
+}
+
+void DocumentImpl::setUserData(void* val)
+{
+ setUserData(this, val);
+};
1.19 +7 -1 xml-xerces/c/src/dom/DocumentImpl.hpp
Index: DocumentImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/DocumentImpl.hpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- DocumentImpl.hpp 2000/05/13 03:51:17 1.18
+++ DocumentImpl.hpp 2000/06/28 17:51:37 1.19
@@ -58,7 +58,7 @@
*/
/*
- * $Id: DocumentImpl.hpp,v 1.18 2000/05/13 03:51:17 andyh Exp $
+ * $Id: DocumentImpl.hpp,v 1.19 2000/06/28 17:51:37 jpolast Exp $
*/
//
@@ -119,6 +119,7 @@
NodeIterators *iterators;
TreeWalkers *treeWalkers;
+ RefHashTableOf<void> *userData;
friend class NodeIteratorImpl;
friend class TreeWalkerImpl;
friend class DOMParser;
@@ -161,7 +162,12 @@
static NodeIteratorImpl* createNodeIterator(DOM_Node root, unsigned long whatToShow, DOM_NodeFilter* filter, bool entityReferenceExpansion);
static TreeWalkerImpl* createTreeWalker(DOM_Node root, unsigned long whatToShow, DOM_NodeFilter* filter, bool entityReferenceExpansion);
virtual XMLDeclImpl* createXMLDecl(const DOMString& version, const DOMString& encoding, const DOMString& standalone);
+ virtual void* getUserData();
+ virtual void setUserData(void* value);
+ // helper functions to prevent storing userdata pointers on every node.
+ virtual void setUserData(NodeImpl* n, void* data);
+ virtual void* getUserData(NodeImpl* n);
//Introduced in DOM Level 2
virtual NodeImpl *importNode(NodeImpl *source, bool deep);
1.27 +14 -14 xml-xerces/c/src/dom/NodeImpl.cpp
Index: NodeImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/dom/NodeImpl.cpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- NodeImpl.cpp 2000/05/16 18:56:40 1.26
+++ NodeImpl.cpp 2000/06/28 17:51:38 1.27
@@ -55,7 +55,7 @@
*/
/*
- * $Id: NodeImpl.cpp,v 1.26 2000/05/16 18:56:40 andyh Exp $
+ * $Id: NodeImpl.cpp,v 1.27 2000/06/28 17:51:38 jpolast Exp $
*/
// This class doesn't support having any children, and implements the behavior
@@ -290,7 +290,7 @@
void *NodeImpl::getUserData()
{
- return userData;
+ return getOwnerDocument()->getUserData(this);
};
@@ -368,18 +368,18 @@
}
- void NodeImpl::setUserData(void * val)
- {
- userData = val;
- };
-
-
-
- DOMString NodeImpl::toString()
- {
- return DOMString("[")+getNodeName()+": "+getNodeValue()+"]";
- // return getNodeName();
- };
+void NodeImpl::setUserData(void * val)
+{
+ getOwnerDocument()->setUserData(this, val);
+};
+
+
+
+DOMString NodeImpl::toString()
+{
+ return DOMString("[")+getNodeName()+": "+getNodeValue()+"]";
+ // return getNodeName();
+};
//Introduced in DOM Level 2