source: icXML/icXML-devel/src/xercesc/dom/impl/DOMChildNode.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: 2.5 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/*
19 * $Id: DOMChildNode.cpp 471747 2006-11-06 14:31:56Z amassari $
20 */
21
22// This class only adds the ability to have siblings
23
24#include <xercesc/util/XercesDefs.hpp>
25#include "DOMNodeImpl.hpp"
26#include "DOMChildNode.hpp"
27#include "DOMCasts.hpp"
28
29XERCES_CPP_NAMESPACE_BEGIN
30
31
32DOMChildNode::DOMChildNode()
33{
34    this->previousSibling  = 0;
35    this->nextSibling  = 0;
36}
37
38// This only makes a shallow copy, cloneChildren must also be called for a
39// deep clone
40DOMChildNode::DOMChildNode(const DOMChildNode &)
41{
42    // Need to break the association w/ original siblings and parent
43    this->previousSibling = 0;
44    this->nextSibling = 0;
45}
46
47DOMChildNode::~DOMChildNode() {
48}
49
50
51DOMNode * DOMChildNode::getNextSibling() const {
52    return nextSibling;
53}
54
55//
56//  Note:  for getParentNode and getPreviousSibling(), below, an
57//         extra paramter "thisNode" is required.  This is because there
58//         is no way to cast from a DOMChildNode pointer back to the
59//         DOMNodeImpl that it is part of.  Our "this" may or may not
60//         be preceded by a fParent in the object layout, and there's no
61//         practical way to tell, so we just take an extra parameter instead.
62
63DOMNode * DOMChildNode::getParentNode(const DOMNode *thisNode) const
64{
65    // if we have an owner, ownerNode is our parent, otherwise it's
66    // our ownerDocument and we don't have a parent
67    DOMNodeImpl *thisNodeImpl = castToNodeImpl(thisNode);
68    return thisNodeImpl->isOwned() ? thisNodeImpl->fOwnerNode : 0;
69}
70
71DOMNode * DOMChildNode::getPreviousSibling(const DOMNode *thisNode) const {
72    // if we are the firstChild, previousSibling actually refers to our
73    // parent's lastChild, but we hide that
74    return castToNodeImpl(thisNode)->isFirstChild() ? 0 : previousSibling;
75}
76
77XERCES_CPP_NAMESPACE_END
78
Note: See TracBrowser for help on using the repository browser.