source: icXML/icXML-devel/src/xercesc/dom/StDOMNode.hpp @ 6297

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

Original Xerces files with import mods for icxercesc

File size: 3.1 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: StDOMNode.hpp 570480 2007-08-28 16:36:34Z amassari $
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
29XERCES_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*/
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)
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
92XERCES_CPP_NAMESPACE_END
93
94#endif
95
Note: See TracBrowser for help on using the repository browser.