From 2b5befcf6b3b2288d9f539b91208a9787f114183 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Sat, 2 Jun 2007 00:02:19 +0000 Subject: [PATCH] Wrote a valid copy constructor and assignment operator for XML_Node, and made them public. It turns out the Cabinet.h routines needed these. Previously, they were using the compiler default routines, which was a bug. Now, they are using explicit routines. Note, these new routines have not been checked. However, they do have the chance of being correct. --- Cantera/src/base/xml.cpp | 30 ++++++++++++++++++++++++++++++ Cantera/src/base/xml.h | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Cantera/src/base/xml.cpp b/Cantera/src/base/xml.cpp index 0bb3f9c69..c906811fe 100755 --- a/Cantera/src/base/xml.cpp +++ b/Cantera/src/base/xml.cpp @@ -301,6 +301,36 @@ namespace Cantera { else m_root = &p->root(); } + XML_Node::XML_Node(const XML_Node &right) : + m_name(""), + m_value(""), + m_parent(0), + m_locked(false), + m_nchildren(0), + m_n(0), + m_iscomment(false) + { + right.copy(this); + } + + + XML_Node & XML_Node::operator=(const XML_Node &right) + { + if (&right != this) { + int n = static_cast(m_children.size()); + for (int i = 0; i < n; i++) { + if (m_children[i]) { + if (m_children[i]->parent() == this) { + delete m_children[i]; + m_children[i] = 0; + } + } + } + m_children.resize(0); + right.copy(this); + } + return *this; + } diff --git a/Cantera/src/base/xml.h b/Cantera/src/base/xml.h index c77f78898..ca88ceda8 100755 --- a/Cantera/src/base/xml.h +++ b/Cantera/src/base/xml.h @@ -62,11 +62,11 @@ namespace Cantera { public: XML_Node(std::string nm = "--", XML_Node* p = 0, int n = 0); - private: + XML_Node(const XML_Node &right); XML_Node& operator=(const XML_Node &right); - public: + virtual ~XML_Node(); void addComment(std::string comment); XML_Node& addChild(XML_Node& node);