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
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #include <xercesc/dom/DOMNode.hpp>
00065 #include <xercesc/dom/DOMAttr.hpp>
00066 #include <xercesc/dom/DOMElement.hpp>
00067
00068 XERCES_CPP_NAMESPACE_BEGIN
00069
00070
00071
00072
00073
00074 template <class T> class StDOMNode {
00075 T* m_node;
00076
00077 static inline void INCREFCOUNT(T *x) { if (x != (T*)0) x->incRefCount(); }
00078 static inline void DECREFCOUNT(T *x) { if (x != (T*)0) x->decRefCount(); }
00079
00080 public:
00081 inline StDOMNode(T* node = (T*)0) : m_node(node) { INCREFCOUNT(m_node); }
00082 inline StDOMNode(const StDOMNode& stNode) : m_node(stNode.m_node) { INCREFCOUNT(m_node); }
00083 inline ~StDOMNode() { DECREFCOUNT(m_node); }
00084
00085 inline T* operator= (T *node)
00086 {
00087 if (m_node != node) {
00088 DECREFCOUNT(m_node);
00089 m_node = node;
00090 INCREFCOUNT(m_node);
00091 }
00092 return (m_node);
00093 }
00094
00095 inline bool operator!= (T* node) const { return (m_node != node); }
00096 inline bool operator== (T* node) const { return (m_node == node); }
00097
00098 inline T& operator* () { return (*m_node); }
00099 inline const T& operator* () const { return (*m_node); }
00100 inline T* operator-> () const { return (m_node); }
00101 inline operator T*() const { return (m_node); }
00102 inline void ClearNode() { operator=((T*)(0)); }
00103 };
00104
00105 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
00106 typedef StDOMNode<DOMNode> DOMNodeSPtr;
00107 #else
00108 typedef DOMNode* DOMNodeSPtr;
00109 #endif
00110
00111
00112
00113
00114
00115 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
00116 typedef StDOMNode<DOMAttr> DOMAttrSPtr;
00117 #else
00118 typedef DOMAttr* DOMAttrSPtr;
00119 #endif
00120
00121
00122
00123
00124
00125 #if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
00126 typedef StDOMNode<DOMElement> DOMElementSPtr;
00127 #else
00128 typedef DOMElement* DOMElementSPtr;
00129 #endif
00130
00131 XERCES_CPP_NAMESPACE_END
00132
00133 #endif
00134