]> git.saurik.com Git - wxWidgets.git/commitdiff
Apply patch [ 1554736 ] wxXmlDocument::DetachRoot
authorRobert Roebling <robert@roebling.de>
Sat, 9 Sep 2006 11:35:32 +0000 (11:35 +0000)
committerRobert Roebling <robert@roebling.de>
Sat, 9 Sep 2006 11:35:32 +0000 (11:35 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/xmldocument.tex
include/wx/xml/xml.h

index d42bda0f8d4335ac3f92ecad009af5eb20a436b9..c99bdae67c66e341aa95a6332681a4d5a7446b8a 100644 (file)
@@ -92,6 +92,17 @@ Copy constructor.
 
 Virtual destructor. Frees the document root node.
 
+
+\membersection{wxXmlDocument::DetachRoot}\label{wxxmldocumentdetachroot}
+
+\func{wxXmlNode*}{DetachRoot}{\void}
+
+Detaches the document root node and returns it. The document root node will be set to \NULL
+and thus \helpref{IsOk}{wxxmldocumentisok} will return \false after calling this function.
+
+Note that the caller is reponsible for deleting the returned node in order to avoid memory leaks.
+
+
 \membersection{wxXmlDocument::GetEncoding}\label{wxxmldocumentgetencoding}
 
 \constfunc{wxString}{GetEncoding}{\void}
@@ -173,6 +184,8 @@ Sets the enconding of the file which will be used to save the document.
 \func{void}{SetRoot}{\param{wxXmlNode* }{node}}
 
 Sets the root node of this document. Deletes previous root node.
+Use \helpref{DetachRoot}{wxxmlnodedetachroot} and then SetRoot if you want to
+replace the root node without deleting the old document tree.
 
 \membersection{wxXmlDocument::SetVersion}\label{wxxmldocumentsetversion}
 
index 1d7aa31dcdb8d09360d5f25e5b9c241892d3b925..10ebf5ce3cee9e9431fb1580c4907c0aafb59554 100644 (file)
@@ -208,6 +208,7 @@ public:
     wxString GetFileEncoding() const { return m_fileEncoding; }
 
     // Write-access methods:
+    wxXmlNode *DetachRoot() { wxXmlNode *old=m_root; m_root=NULL; return old; }
     void SetRoot(wxXmlNode *node) { wxDELETE(m_root); m_root = node; }
     void SetVersion(const wxString& version) { m_version = version; }
     void SetFileEncoding(const wxString& encoding) { m_fileEncoding = encoding; }