source: icXML/icXML-devel/src/xercesc/dom/impl/DOMXPathResultImpl.cpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

File size: 3.7 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#include "DOMXPathResultImpl.hpp"
19#include <xercesc/dom/DOMNode.hpp>
20#include <xercesc/dom/DOMXPathException.hpp>
21
22XERCES_CPP_NAMESPACE_BEGIN
23
24DOMXPathResultImpl::DOMXPathResultImpl(ResultType type,
25                                       MemoryManager* const manager)
26    : fType(type),
27      fMemoryManager(manager),
28      fIndex (0)
29{
30    fSnapshot = new (fMemoryManager) RefVectorOf<DOMNode>(13, false, fMemoryManager);
31}
32
33DOMXPathResultImpl::~DOMXPathResultImpl()
34{
35    delete fSnapshot;
36}
37
38//
39//
40DOMXPathResult::ResultType DOMXPathResultImpl::getResultType() const
41{
42    return fType;
43}
44
45const DOMTypeInfo* DOMXPathResultImpl::getTypeInfo() const
46{
47    throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
48}
49
50bool DOMXPathResultImpl::isNode() const
51{
52    throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
53}
54
55bool DOMXPathResultImpl::getBooleanValue() const
56{
57    throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
58}
59
60int DOMXPathResultImpl::getIntegerValue() const
61{
62    throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
63}
64
65double DOMXPathResultImpl::getNumberValue() const
66{
67    throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
68}
69
70const XMLCh* DOMXPathResultImpl::getStringValue() const
71{
72    throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
73}
74
75DOMNode* DOMXPathResultImpl::getNodeValue() const
76{
77  if(fType == ANY_UNORDERED_NODE_TYPE || fType == FIRST_ORDERED_NODE_TYPE)
78  {
79    return fSnapshot->size() > 0 ? fSnapshot->elementAt(0) : 0;
80  }
81  else if (fType==UNORDERED_NODE_SNAPSHOT_TYPE || fType==ORDERED_NODE_SNAPSHOT_TYPE)
82  {
83    return fIndex < fSnapshot->size() ? fSnapshot->elementAt(fIndex) : 0;
84  }
85  else
86    throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
87}
88
89bool DOMXPathResultImpl::iterateNext()
90{
91    throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
92}
93
94bool DOMXPathResultImpl::getInvalidIteratorState() const
95{
96    throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
97}
98
99bool DOMXPathResultImpl::snapshotItem(XMLSize_t index)
100{
101    if(fType==UNORDERED_NODE_SNAPSHOT_TYPE || fType==ORDERED_NODE_SNAPSHOT_TYPE)
102    {
103        fIndex = index;
104        return fIndex < fSnapshot->size();
105    }
106    else
107      throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
108}
109
110XMLSize_t DOMXPathResultImpl::getSnapshotLength() const
111{
112    if(fType==UNORDERED_NODE_SNAPSHOT_TYPE || fType==ORDERED_NODE_SNAPSHOT_TYPE)
113        return fSnapshot->size();
114    else
115        throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
116}
117
118void DOMXPathResultImpl::release()
119{
120    DOMXPathResultImpl* me = this;
121    delete me;
122}
123
124//
125//
126void DOMXPathResultImpl::reset(ResultType type)
127{
128    fType = type;
129    fSnapshot->removeAllElements();
130    fIndex = 0;
131}
132
133void DOMXPathResultImpl::addResult(DOMNode* node)
134{
135    fSnapshot->addElement(node);
136}
137
138XERCES_CPP_NAMESPACE_END
Note: See TracBrowser for help on using the repository browser.