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.
This commit is contained in:
parent
16c8a59ca5
commit
2b5befcf6b
2 changed files with 32 additions and 2 deletions
|
|
@ -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<int>(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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue