Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/xercesc/dom/StDOMNode.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_STDOMNODE_HPP)
0023 #define XERCESC_INCLUDE_GUARD_STDOMNODE_HPP
0024 
0025 #include <xercesc/dom/DOMNode.hpp>
0026 #include <xercesc/dom/DOMAttr.hpp>
0027 #include <xercesc/dom/DOMElement.hpp>
0028 
0029 XERCES_CPP_NAMESPACE_BEGIN
0030 
0031 /* This class is a smart pointer implementation over DOMNode interface and
0032 ** classes derived from it. It takes care of reference counting automatically.
0033 ** Reference counting is optional so use of this class is experimental.
0034 */
0035 template <class T> class StDOMNode {
0036     T* m_node;
0037 
0038     static inline void INCREFCOUNT(T *x) { if (x != (T*)0) x->incRefCount(); }
0039     static inline void DECREFCOUNT(T *x) { if (x != (T*)0) x->decRefCount(); }
0040 
0041 public:
0042     inline StDOMNode(T* node = (T*)0) : m_node(node) { INCREFCOUNT(m_node); }
0043     inline StDOMNode(const StDOMNode& stNode) : m_node(stNode.m_node) { INCREFCOUNT(m_node); }
0044     inline ~StDOMNode() { DECREFCOUNT(m_node); }
0045 
0046     inline T* operator= (T *node)
0047     {
0048         if (m_node != node) {
0049             DECREFCOUNT(m_node);
0050             m_node = node;
0051             INCREFCOUNT(m_node);
0052         }
0053         return (m_node);
0054     }
0055 
0056     inline bool operator!= (T* node) const { return (m_node != node); }
0057     inline bool operator== (T* node) const { return (m_node == node); }
0058 
0059     inline T& operator* () { return (*m_node); }
0060     inline const T& operator* () const { return (*m_node); }
0061     inline T* operator-> () const { return (m_node); }
0062     inline operator T*() const { return (m_node); }
0063     inline void ClearNode() { operator=((T*)(0)); }
0064 };
0065 
0066 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
0067     typedef StDOMNode<DOMNode> DOMNodeSPtr;
0068 #else
0069     typedef DOMNode* DOMNodeSPtr;
0070 #endif
0071 
0072 /* StDOMNode is a smart pointer implementation over DOMNode interface and
0073 ** classes derived from it. It takes care of reference counting automatically.
0074 ** Reference counting is optional so use of this class is experimental.
0075 */
0076 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
0077     typedef StDOMNode<DOMAttr> DOMAttrSPtr;
0078 #else
0079     typedef DOMAttr* DOMAttrSPtr;
0080 #endif
0081 
0082 /* StDOMNode is a smart pointer implementation over DOMNode interface and
0083 ** classes derived from it. It takes care of reference counting automatically.
0084 ** Reference counting is optional so use of this class is experimental.
0085 */
0086 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
0087     typedef StDOMNode<DOMElement> DOMElementSPtr;
0088 #else
0089     typedef DOMElement* DOMElementSPtr;
0090 #endif
0091 
0092 XERCES_CPP_NAMESPACE_END
0093 
0094 #endif
0095