00001 #ifndef DOMSPtr_HEADER_GUARD_
00002 #define DOMSPtr_HEADER_GUARD_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <xercesc/dom/DOMNode.hpp>
00025 #include <xercesc/dom/DOMAttr.hpp>
00026 #include <xercesc/dom/DOMElement.hpp>
00027
00028 XERCES_CPP_NAMESPACE_BEGIN
00029
00030
00031
00032
00033
00034 template <class T> class StDOMNode {
00035 T* m_node;
00036
00037 static inline void INCREFCOUNT(T *x) { if (x != (T*)0) x->incRefCount(); }
00038 static inline void DECREFCOUNT(T *x) { if (x != (T*)0) x->decRefCount(); }
00039
00040 public:
00041 inline StDOMNode(T* node = (T*)0) : m_node(node) { INCREFCOUNT(m_node); }
00042 inline StDOMNode(const StDOMNode& stNode) : m_node(stNode.m_node) { INCREFCOUNT(m_node); }
00043 inline ~StDOMNode() { DECREFCOUNT(m_node); }
00044
00045 inline T* operator= (T *node)
00046 {
00047 if (m_node != node) {
00048 DECREFCOUNT(m_node);
00049 m_node = node;
00050 INCREFCOUNT(m_node);
00051 }
00052 return (m_node);
00053 }
00054
00055 inline bool operator!= (T* node) const { return (m_node != node); }
00056 inline bool operator== (T* node) const { return (m_node == node); }
00057
00058 inline T& operator* () { return (*m_node); }
00059 inline const T& operator* () const { return (*m_node); }
00060 inline T* operator-> () const { return (m_node); }
00061 inline operator T*() const { return (m_node); }
00062 inline void ClearNode() { operator=((T*)(0)); }
00063 };
00064
00065 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
00066 typedef StDOMNode<DOMNode> DOMNodeSPtr;
00067 #else
00068 typedef DOMNode* DOMNodeSPtr;
00069 #endif
00070
00071
00072
00073
00074
00075 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
00076 typedef StDOMNode<DOMAttr> DOMAttrSPtr;
00077 #else
00078 typedef DOMAttr* DOMAttrSPtr;
00079 #endif
00080
00081
00082
00083
00084
00085 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
00086 typedef StDOMNode<DOMElement> DOMElementSPtr;
00087 #else
00088 typedef DOMElement* DOMElementSPtr;
00089 #endif
00090
00091 XERCES_CPP_NAMESPACE_END
00092
00093 #endif
00094