Added a clear() function to the xml object. This will wipe

out the current level and everything below it.
This commit is contained in:
Harry Moffat 2009-10-11 21:34:06 +00:00
parent 5fd13d3591
commit d503c55864
2 changed files with 29 additions and 1 deletions

View file

@ -482,6 +482,27 @@ namespace Cantera {
}
}
void XML_Node::clear() {
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_value.clear();
m_childindex.clear();
m_attribs.clear();
m_children.clear();
m_nchildren = 0;
m_iscomment = false;
m_linenum = 0;
}
// Add a child node to the current node containing a comment
/*
* Child node will have the name, "comment".

View file

@ -380,6 +380,13 @@ namespace Cantera {
*/
std::string attrib(const std::string & attr) const;
//! Clear the current node and everything under it
/*!
* The value, attributes and children are all zeroed. The name and the
* parent information is kept.
*/
void clear();
private:
//! Returns a changeable value of the attributes map for the current node
/*!
@ -644,7 +651,7 @@ namespace Cantera {
//! into the destination XML_Node tree, doing a complete copy
//! as we go.
/*!
* Note this is a const function becuase the current XML_Node and
* Note this is a const function because the current XML_Node and
* its children isn't altered by this operation.
*
* @param node_dest This is the XML node to receive the information