From 022dc34cf2c539eb8b3d1bf6028044fa81fad7d5 Mon Sep 17 00:00:00 2001
From: Tinny Ng <tng@apache.org>
Date: Wed, 31 Jul 2002 20:38:52 +0000
Subject: [PATCH] [Bug 11338] missing const keyword for DOMNodeList methods.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174088 13f79535-47bb-0310-9956-ffa450edef68
---
 doc/html/ApacheDOMC++BindingL2.html          | 4 ++--
 doc/html/ApacheDOMC++BindingL3.html          | 4 ++--
 src/xercesc/dom/DOMNodeList.hpp              | 4 ++--
 src/xercesc/dom/impl/DOMDeepNodeListImpl.cpp | 8 ++++++--
 src/xercesc/dom/impl/DOMDeepNodeListImpl.hpp | 5 +++--
 src/xercesc/dom/impl/DOMNodeListImpl.cpp     | 4 ++--
 src/xercesc/dom/impl/DOMNodeListImpl.hpp     | 4 ++--
 7 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/doc/html/ApacheDOMC++BindingL2.html b/doc/html/ApacheDOMC++BindingL2.html
index ab63e6cbb..17c0bb032 100644
--- a/doc/html/ApacheDOMC++BindingL2.html
+++ b/doc/html/ApacheDOMC++BindingL2.html
@@ -1158,7 +1158,7 @@ DOMNodeList</font></font>
 
 <td><font face="Courier New,Courier"><font size=-1>DOMNode*</font></font></td>
 
-<td><font face="Courier New,Courier"><font size=-1>item(XMLSize_t index)
+<td><font face="Courier New,Courier"><font size=-1>item(XMLSize_t index) const
 = 0;</font></font></td>
 </tr>
 
@@ -1169,7 +1169,7 @@ DOMNodeList</font></font>
 
 <td><font face="Courier New,Courier"><font size=-1>XMLSize_t</font></font></td>
 
-<td><font face="Courier New,Courier"><font size=-1>getLength() = 0;</font></font></td>
+<td><font face="Courier New,Courier"><font size=-1>getLength() const = 0;</font></font></td>
 </tr>
 
 <tr ALIGN=LEFT VALIGN=TOP>
diff --git a/doc/html/ApacheDOMC++BindingL3.html b/doc/html/ApacheDOMC++BindingL3.html
index 98e562d1f..e8e8deabb 100644
--- a/doc/html/ApacheDOMC++BindingL3.html
+++ b/doc/html/ApacheDOMC++BindingL3.html
@@ -1649,7 +1649,7 @@ DOMNodeList</font></font>
 
 <td><font face="Courier New,Courier"><font size=-1>DOMNode*</font></font></td>
 
-<td><font face="Courier New,Courier"><font size=-1>item(XMLSize_t index)
+<td><font face="Courier New,Courier"><font size=-1>item(XMLSize_t index) const
 = 0;</font></font></td>
 </tr>
 
@@ -1660,7 +1660,7 @@ DOMNodeList</font></font>
 
 <td><font face="Courier New,Courier"><font size=-1>XMLSize_t</font></font></td>
 
-<td><font face="Courier New,Courier"><font size=-1>getLength() = 0;</font></font></td>
+<td><font face="Courier New,Courier"><font size=-1>getLength() const = 0;</font></font></td>
 </tr>
 
 <tr ALIGN=LEFT VALIGN=TOP>
diff --git a/src/xercesc/dom/DOMNodeList.hpp b/src/xercesc/dom/DOMNodeList.hpp
index cee9a0292..3112757b0 100644
--- a/src/xercesc/dom/DOMNodeList.hpp
+++ b/src/xercesc/dom/DOMNodeList.hpp
@@ -123,7 +123,7 @@ public:
      *   index.
      * @since DOM Level 1
      */
-    virtual DOMNode  *item(XMLSize_t index) = 0;
+    virtual DOMNode  *item(XMLSize_t index) const = 0;
 
     /**
      * Returns the number of nodes in the list.
@@ -131,7 +131,7 @@ public:
      * The range of valid child node indices is 0 to <code>length-1</code> inclusive.
      * @since DOM Level 1
      */
-    virtual XMLSize_t getLength() = 0;
+    virtual XMLSize_t getLength() const = 0;
     //@}
 };
 
diff --git a/src/xercesc/dom/impl/DOMDeepNodeListImpl.cpp b/src/xercesc/dom/impl/DOMDeepNodeListImpl.cpp
index 6aaf5080b..2efb62054 100644
--- a/src/xercesc/dom/impl/DOMDeepNodeListImpl.cpp
+++ b/src/xercesc/dom/impl/DOMDeepNodeListImpl.cpp
@@ -105,7 +105,7 @@ DOMDeepNodeListImpl::~DOMDeepNodeListImpl()
 {
 }
 
-XMLSize_t DOMDeepNodeListImpl::getLength()
+XMLSize_t DOMDeepNodeListImpl::getLength() const
 {
     // Reset cache to beginning of list
     item(0);
@@ -116,6 +116,10 @@ XMLSize_t DOMDeepNodeListImpl::getLength()
 }
 
 
+DOMNode *DOMDeepNodeListImpl::item(XMLSize_t index) const
+{
+    return ((DOMDeepNodeListImpl*)this)->cacheItem(index);
+}
 
 // Start from the first child and count forward, 0-based. index>length-1
 // should return 0.
@@ -127,7 +131,7 @@ XMLSize_t DOMDeepNodeListImpl::getLength()
 // irrelevant ones.  Doing so in a really useful manner would seem
 // to involve a tree-walk in its own right, or maintaining our data
 // in a parallel tree.
-DOMNode *DOMDeepNodeListImpl::item(XMLSize_t index)
+DOMNode *DOMDeepNodeListImpl::cacheItem(XMLSize_t index)
 {
     XMLSize_t currentIndexPlus1 = fCurrentIndexPlus1;
     DOMNode *currentNode = fCurrentNode;
diff --git a/src/xercesc/dom/impl/DOMDeepNodeListImpl.hpp b/src/xercesc/dom/impl/DOMDeepNodeListImpl.hpp
index c5046242f..accfbf106 100644
--- a/src/xercesc/dom/impl/DOMDeepNodeListImpl.hpp
+++ b/src/xercesc/dom/impl/DOMDeepNodeListImpl.hpp
@@ -96,8 +96,9 @@ public:
 	                    const XMLCh *namespaceURI,
                        const XMLCh *localName);
     virtual          ~DOMDeepNodeListImpl();
-    virtual XMLSize_t getLength();
-    virtual DOMNode*  item(XMLSize_t index);
+    virtual XMLSize_t getLength() const;
+    virtual DOMNode*  item(XMLSize_t index) const;
+    DOMNode*  cacheItem(XMLSize_t index);
 
 private:
     DOMNode*          nextMatchingElementAfter(DOMNode *current);
diff --git a/src/xercesc/dom/impl/DOMNodeListImpl.cpp b/src/xercesc/dom/impl/DOMNodeListImpl.cpp
index e6536b0e3..cfdeeb048 100644
--- a/src/xercesc/dom/impl/DOMNodeListImpl.cpp
+++ b/src/xercesc/dom/impl/DOMNodeListImpl.cpp
@@ -79,7 +79,7 @@ DOMNodeListImpl:: ~DOMNodeListImpl()
 
 
 
-XMLSize_t DOMNodeListImpl::getLength(){
+XMLSize_t DOMNodeListImpl::getLength() const{
     XMLSize_t count = 0;
     if (fNode) {
         DOMNode *node = castToParentImpl(fNode)->fFirstChild;
@@ -94,7 +94,7 @@ XMLSize_t DOMNodeListImpl::getLength(){
 
 
 
-DOMNode *DOMNodeListImpl::item(XMLSize_t index){
+DOMNode *DOMNodeListImpl::item(XMLSize_t index) const{
     if (fNode) {
         DOMNode *node = castToParentImpl(fNode)->fFirstChild;
         for(XMLSize_t i=0; i<index && node!=0; ++i)
diff --git a/src/xercesc/dom/impl/DOMNodeListImpl.hpp b/src/xercesc/dom/impl/DOMNodeListImpl.hpp
index 2cfa81f4f..4ab3dbfa3 100644
--- a/src/xercesc/dom/impl/DOMNodeListImpl.hpp
+++ b/src/xercesc/dom/impl/DOMNodeListImpl.hpp
@@ -98,8 +98,8 @@ private:
 public:
     DOMNodeListImpl(DOMNode *node);
     virtual             ~DOMNodeListImpl();
-    virtual DOMNode *  item(XMLSize_t index);
-    virtual XMLSize_t getLength();
+    virtual DOMNode *  item(XMLSize_t index) const;
+    virtual XMLSize_t getLength() const;
 };
 
 #endif
-- 
GitLab