Xerces-C++ 3.2.5
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
28
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*/
35template <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
41public:
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)
68#else
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)
78#else
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)
88#else
90#endif
91
93
94#endif
95
DOMElement * DOMElementSPtr
Definition StDOMNode.hpp:89
DOMAttr * DOMAttrSPtr
Definition StDOMNode.hpp:79
DOMNode * DOMNodeSPtr
Definition StDOMNode.hpp:69
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
The DOMAttr class refers to an attribute of an XML element.
Definition DOMAttr.hpp:57
By far the vast majority of objects (apart from text) that authors encounter when traversing a docume...
Definition DOMElement.hpp:66
The DOMNode interface is the primary datatype for the entire Document Object Model.
Definition DOMNode.hpp:139
Definition StDOMNode.hpp:35
bool operator!=(T *node) const
Definition StDOMNode.hpp:56
T * operator->() const
Definition StDOMNode.hpp:61
T * operator=(T *node)
Definition StDOMNode.hpp:46
bool operator==(T *node) const
Definition StDOMNode.hpp:57
void ClearNode()
Definition StDOMNode.hpp:63
StDOMNode(const StDOMNode &stNode)
Definition StDOMNode.hpp:43
T & operator*()
Definition StDOMNode.hpp:59
~StDOMNode()
Definition StDOMNode.hpp:44
StDOMNode(T *node=(T *) 0)
Definition StDOMNode.hpp:42