GME  13
DOMNodeListImpl.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: DOMNodeListImpl.cpp 671894 2008-06-26 13:29:21Z borisk $
00020  */
00021 
00022 
00023 #include <xercesc/util/XercesDefs.hpp>
00024 #include "DOMNodeListImpl.hpp"
00025 #include "DOMCasts.hpp"
00026 
00027 XERCES_CPP_NAMESPACE_BEGIN
00028 
00029 
00030 // revisit
00031 //   this implementation is too stupid - needs a cache of some kind.
00032 //
00033 
00034 DOMNodeListImpl::DOMNodeListImpl(DOMParentNode *node)
00035 :   fNode(node)
00036 {
00037 }
00038 
00039 
00040 DOMNodeListImpl:: ~DOMNodeListImpl()
00041 {
00042 }
00043 
00044 
00045 
00046 XMLSize_t DOMNodeListImpl::getLength() const{
00047     XMLSize_t count = 0;
00048     if (fNode) {
00049         DOMNode *node = fNode->fFirstChild;
00050         while(node != 0){
00051             ++count;
00052             node = castToChildImpl(node)->nextSibling;
00053         }
00054     }
00055 
00056     return count;
00057 }
00058 
00059 
00060 
00061 DOMNode *DOMNodeListImpl::item(XMLSize_t index) const{
00062     if (fNode) {
00063         DOMNode *node = fNode->fFirstChild;
00064         for(XMLSize_t i=0; i<index && node!=0; ++i)
00065             node = castToChildImpl(node)->nextSibling;
00066         return node;
00067     }
00068     return 0;
00069 }
00070 
00071 
00072 XERCES_CPP_NAMESPACE_END