namespace xmltooling {\r
\r
/**\r
+ * RAII wrapper for DOM Documents.\r
+ */\r
+ class XMLTOOL_API DocumentJanitor\r
+ {\r
+ MAKE_NONCOPYABLE(DocumentJanitor);\r
+ DOMDocument* m_doc;\r
+ public:\r
+ DocumentJanitor(DOMDocument* doc) : m_doc(doc) {}\r
+ \r
+ ~DocumentJanitor() {\r
+ if (m_doc)\r
+ m_doc->release();\r
+ }\r
+ \r
+ /**\r
+ * Returns any document held by this object and releases it to the caller.\r
+ * \r
+ * @return the document held or NULL\r
+ */\r
+ DOMDocument* release() {\r
+ DOMDocument* ret=m_doc;\r
+ m_doc=NULL;\r
+ return ret;\r
+ }\r
+ };\r
+ \r
+ /**\r
* A helper class for working with W3C DOM objects. \r
*/\r
class XMLTOOL_API XMLHelper\r