From f52b57986dd92d91dc13bd8906c3b72c5d76cffa Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Fri, 22 Aug 2008 14:50:52 +0000 Subject: [PATCH] house cleaning and docs: -> got rid of m_n. I could not see that it was used anywhere. --- Cantera/src/base/xml.cpp | 8 ++-- Cantera/src/base/xml.h | 79 ++++++++++++++++++++++++++-------------- 2 files changed, 54 insertions(+), 33 deletions(-) diff --git a/Cantera/src/base/xml.cpp b/Cantera/src/base/xml.cpp index 9596ee2dc..23aa3c8e0 100755 --- a/Cantera/src/base/xml.cpp +++ b/Cantera/src/base/xml.cpp @@ -294,10 +294,10 @@ namespace Cantera { ////////////////////////// XML_Node ///////////////////////////////// - XML_Node::XML_Node(string nm, XML_Node* p, int n) + XML_Node::XML_Node(string nm, XML_Node* p) : m_name(nm), m_value(""), m_parent(p), m_locked(false), m_nchildren(0), - m_n(n), m_iscomment(false) { + m_iscomment(false) { if (!p) m_root = this; else m_root = &p->root(); } @@ -308,7 +308,6 @@ namespace Cantera { m_parent(0), m_locked(false), m_nchildren(0), - m_n(0), m_iscomment(false) { right.copy(this); @@ -363,8 +362,7 @@ namespace Cantera { } XML_Node& XML_Node::addChild(string name) { - int n = static_cast(m_children.size()); - XML_Node *xxx = new XML_Node(name, this, n); + XML_Node *xxx = new XML_Node(name, this); m_children.push_back(xxx); m_nchildren = static_cast(m_children.size()); m_childindex[name] = m_children.back(); diff --git a/Cantera/src/base/xml.h b/Cantera/src/base/xml.h index 5440d4e79..55457c8b2 100755 --- a/Cantera/src/base/xml.h +++ b/Cantera/src/base/xml.h @@ -1,6 +1,5 @@ /** * @file xml.h - * * Classes providing support for XML data files. These classes * implement only those aspects of XML required to read, write, and * manipulate CTML data files. @@ -33,27 +32,27 @@ namespace Cantera { - /** - * Class XML_Reader is designed for internal use. - */ - class XML_Reader { - public: - XML_Reader(std::istream& input) : m_s(input), m_line(0) {} + /** + * Class XML_Reader is designed for internal use. + */ + class XML_Reader { + public: + XML_Reader(std::istream& input) : m_s(input), m_line(0) {} - std::istream& m_s; - int m_line; + std::istream& m_s; + int m_line; - void getchr(char& ch); - std::string strip(const std::string& aline); - std::string inquotes(const std::string& aline); + void getchr(char& ch); + std::string strip(const std::string& aline); + std::string inquotes(const std::string& aline); - int findQuotedString(const std::string& aline, std::string &rstring); + int findQuotedString(const std::string& aline, std::string &rstring); - void parseTag(std::string line, std::string& name, - std::map& attribs); - std::string readTag(std::map& attribs); - std::string readValue(); - }; + void parseTag(std::string line, std::string& name, + std::map& attribs); + std::string readTag(std::map& attribs); + std::string readValue(); + }; ////////////////////////// XML_Node ///////////////////////////////// @@ -61,14 +60,19 @@ namespace Cantera { class XML_Node { public: - XML_Node(std::string nm = "--", XML_Node* p = 0, int n = 0); + XML_Node(std::string nm = "--", XML_Node* p = 0); XML_Node(const XML_Node &right); + + //! Assignment operator for XML trees + /*! + * @param right XML tree to copy + */ XML_Node& operator=(const XML_Node &right); virtual ~XML_Node(); - void addComment(std::string comment); + void addComment(std::string comment); XML_Node& addChild(XML_Node& node); XML_Node& addChild(std::string name); XML_Node& addChild(std::string name, std::string value); @@ -92,15 +96,21 @@ namespace Cantera { std::string operator()() const { return m_value; } std::string operator()(std::string loc) const { return value(loc); } - /** - * The operator[] is overloaded to provide a lookup capability - * on attributes for the current XML element. - * + + //! The operator[] is overloaded to provide a lookup capability + //! on attributes for the current XML element. + /*! * For example * xmlNode["id"] * will return the value of the attribute "id" for the current * XML element. It will return the blank std::string if there isn't * an attribute with that name. + * + * @param attr attribute string to look up + * + * @return Returns a string representing the value of the attribute + * within the XML node. If there is no attribute + * with the given name, it returns the null string. */ std::string operator[](std::string attr) const { return attrib(attr); @@ -150,7 +160,6 @@ namespace Cantera { */ std::string id() const; - int number() const { return m_n; } XML_Node& child(int n) const { return *m_children[n]; } std::vector& children() { return m_children; } @@ -201,9 +210,22 @@ namespace Cantera { * For example, if we were in the XML_Node where * * - * Then, this string would be equal to "phase" + * Then, this string would be equal to "phase". "dim" and "id" + * are attributes of the XML_Node. */ std::string m_name; + + //! Value of the xml node + /*! + * This is the string contents of the XML node. For + * example. The xml node named eps: + * + * + * valueString + * + * + * has a m_value string containing "valueString". + */ std::string m_value; std::map m_childindex; std::map m_attribs; @@ -211,8 +233,9 @@ namespace Cantera { XML_Node* m_root; bool m_locked; std::vector m_children; - int m_nchildren; - int m_n; + + //! Number of children of this node + int m_nchildren; bool m_iscomment; int m_linenum; };