diff --git a/Cantera/src/base/xml.cpp b/Cantera/src/base/xml.cpp index 8aa6afe53..2ea75093c 100644 --- a/Cantera/src/base/xml.cpp +++ b/Cantera/src/base/xml.cpp @@ -835,15 +835,29 @@ namespace Cantera { const std::vector& XML_Node::children() const { return m_children; } - - // return the number of children + //===================================================================================================================== + // Return the number of children /* - * + * @param discardComments Bool indicating whether we should ignore comments in the count. defaults to false */ - int XML_Node::nChildren() const { + int XML_Node::nChildren(const bool discardComments) const { + if (discardComments) { + int count = 0; + for (int i = 0; i < m_nchildren; i++) { + XML_Node *xc = m_children[i]; + if (!(xc->isComment())) { + count++; + } + } + return count; + } return m_nchildren; } - + //===================================================================================================================== + bool XML_Node::isComment() const { + return m_iscomment; + } + //===================================================================================================================== // Require that the current xml node have an attribute named // by the first argument, a, and that this attribute have the // the string value listed in the second argument, v. diff --git a/Cantera/src/base/xml.h b/Cantera/src/base/xml.h index f3063ba9f..3be1378a3 100644 --- a/Cantera/src/base/xml.h +++ b/Cantera/src/base/xml.h @@ -472,12 +472,16 @@ namespace Cantera { */ const std::vector& children() const; - //! return the number of children + //! Return the number of children /*! - * + * @param discardComments If true comments are discarded when adding up the number of children. + * Defaults to false. */ - int nChildren() const; + int nChildren(bool discardComments = false) const; + //! Boolean function indicating whether a comment + bool isComment() const; + //! Require that the current xml node have an attribute named //! by the first argument, a, and that this attribute have the //! the string value listed in the second argument, v.