Xerces-C++ 3.2.4

StDOMNode.hpp
Go to the documentation of this file.
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$
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_STDOMNODE_HPP)
23#define XERCESC_INCLUDE_GUARD_STDOMNODE_HPP
24
25#include <xercesc/dom/DOMNode.hpp>
26#include <xercesc/dom/DOMAttr.hpp>
27#include <xercesc/dom/DOMElement.hpp>
28
29 XERCES_CPP_NAMESPACE_BEGIN
30
31/* This class is a smart pointer implementation over DOMNode interface and
32** classes derived from it. It takes care of reference counting automatically.
33** Reference counting is optional so use of this class is experimental.
34*/
35 template <class T> class StDOMNode {
36 T* m_node;
37
38 static inline void INCREFCOUNT(T *x) { if (x != (T*)0) x->incRefCount(); }
39 static inline void DECREFCOUNT(T *x) { if (x != (T*)0) x->decRefCount(); }
40
41 public:
42 inline StDOMNode(T* node = (T*)0) : m_node(node) { INCREFCOUNT(m_node); }
43 inline StDOMNode(const StDOMNode& stNode) : m_node(stNode.m_node) { INCREFCOUNT(m_node); }
44 inline ~StDOMNode() { DECREFCOUNT(m_node); }
45
46 inline T* operator= (T *node)
47 {
48 if (m_node != node) {
49 DECREFCOUNT(m_node);
50 m_node = node;
51 INCREFCOUNT(m_node);
52 }
53 return (m_node);
54 }
55
56 inline bool operator!= (T* node) const { return (m_node != node); }
57 inline bool operator== (T* node) const { return (m_node == node); }
58
59 inline T& operator* () { return (*m_node); }
60 inline const T& operator* () const { return (*m_node); }
61 inline T* operator-> () const { return (m_node); }
62 inline operator T*() const { return (m_node); }
63 inline void ClearNode() { operator=((T*)(0)); }
64};
65
66#if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
67 typedef StDOMNode<DOMNode> DOMNodeSPtr;
68#else
69 typedef DOMNode* DOMNodeSPtr;
70#endif
71
72/* StDOMNode is a smart pointer implementation over DOMNode interface and
73** classes derived from it. It takes care of reference counting automatically.
74** Reference counting is optional so use of this class is experimental.
75*/
76#if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
77 typedef StDOMNode<DOMAttr> DOMAttrSPtr;
78#else
79 typedef DOMAttr* DOMAttrSPtr;
80#endif
81
82/* StDOMNode is a smart pointer implementation over DOMNode interface and
83** classes derived from it. It takes care of reference counting automatically.
84** Reference counting is optional so use of this class is experimental.
85*/
86#if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
87 typedef StDOMNode<DOMElement> DOMElementSPtr;
88#else
89 typedef DOMElement* DOMElementSPtr;
90#endif
91
92 XERCES_CPP_NAMESPACE_END
93
94#endif
95
DOMAttr.hpp
DOMElement.hpp
DOMNode.hpp
DOMElementSPtr
DOMElement * DOMElementSPtr
Definition: StDOMNode.hpp:89
DOMAttrSPtr
DOMAttr * DOMAttrSPtr
Definition: StDOMNode.hpp:79
DOMNodeSPtr
DOMNode * DOMNodeSPtr
Definition: StDOMNode.hpp:69
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
DOMAttr
The DOMAttr class refers to an attribute of an XML element.
Definition: DOMAttr.hpp:57
DOMElement
By far the vast majority of objects (apart from text) that authors encounter when traversing a docume...
Definition: DOMElement.hpp:66
DOMNode
The DOMNode interface is the primary datatype for the entire Document Object Model.
Definition: DOMNode.hpp:139
StDOMNode
Definition: StDOMNode.hpp:35
StDOMNode::operator!=
bool operator!=(T *node) const
Definition: StDOMNode.hpp:56
StDOMNode::operator->
T * operator->() const
Definition: StDOMNode.hpp:61
StDOMNode::operator=
T * operator=(T *node)
Definition: StDOMNode.hpp:46
StDOMNode::operator==
bool operator==(T *node) const
Definition: StDOMNode.hpp:57
StDOMNode::ClearNode
void ClearNode()
Definition: StDOMNode.hpp:63
StDOMNode::StDOMNode
StDOMNode(const StDOMNode &stNode)
Definition: StDOMNode.hpp:43
StDOMNode::operator*
T & operator*()
Definition: StDOMNode.hpp:59
StDOMNode::~StDOMNode
~StDOMNode()
Definition: StDOMNode.hpp:44
StDOMNode::StDOMNode
StDOMNode(T *node=(T *) 0)
Definition: StDOMNode.hpp:42