From 7ba644997815a3545f62060b66b8b75a1ededefe Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Mon, 5 Jan 2009 23:33:44 +0000 Subject: [PATCH] Finished low lvl doxygen commenting XML_Node object --- Cantera/src/base/ct2ctml.cpp | 1 + Cantera/src/base/ctml.cpp | 2 + Cantera/src/base/stringUtils.cpp | 1 + Cantera/src/base/xml.cpp | 26 +++++--- Cantera/src/base/xml.h | 84 ++++++++++++++++++++----- Cantera/src/oneD/Domain1D.h | 1 + Cantera/src/thermo/VPSSMgr_Water_HKFT.h | 1 - 7 files changed, 90 insertions(+), 26 deletions(-) diff --git a/Cantera/src/base/ct2ctml.cpp b/Cantera/src/base/ct2ctml.cpp index a4877353a..49c53a551 100644 --- a/Cantera/src/base/ct2ctml.cpp +++ b/Cantera/src/base/ct2ctml.cpp @@ -25,6 +25,7 @@ #include #include #include "ctml.h" +#include "global.h" using namespace std; diff --git a/Cantera/src/base/ctml.cpp b/Cantera/src/base/ctml.cpp index 55a040ecc..b85aaa6ed 100755 --- a/Cantera/src/base/ctml.cpp +++ b/Cantera/src/base/ctml.cpp @@ -22,9 +22,11 @@ #define CTML_VERSION_1_4_1 +#include "global.h" #include #include + using namespace std; using namespace Cantera; diff --git a/Cantera/src/base/stringUtils.cpp b/Cantera/src/base/stringUtils.cpp index 7e14f00a6..1962fbc0a 100755 --- a/Cantera/src/base/stringUtils.cpp +++ b/Cantera/src/base/stringUtils.cpp @@ -18,6 +18,7 @@ #include "ct_defs.h" #include "ctexceptions.h" +#include "global.h" #include #include #include diff --git a/Cantera/src/base/xml.cpp b/Cantera/src/base/xml.cpp index 2cf24f90a..8cdc95581 100755 --- a/Cantera/src/base/xml.cpp +++ b/Cantera/src/base/xml.cpp @@ -30,7 +30,8 @@ using namespace std; #include "xml.h" - +#include "global.h" +#include "stringUtils.h" #include #define XML_INDENT 4 @@ -406,7 +407,7 @@ namespace Cantera { * * @param comment Content of the comment */ - void XML_Node::addComment(const std::string comment) { + void XML_Node::addComment(const std::string &comment) { addChild("comment", comment); } @@ -437,7 +438,7 @@ namespace Cantera { * * @return Returns a reference to the added node */ - XML_Node& XML_Node::addChild(const std::string sname) { + XML_Node& XML_Node::addChild(const std::string &sname) { XML_Node *xxx = new XML_Node(sname, this); m_children.push_back(xxx); m_nchildren = static_cast(m_children.size()); @@ -456,7 +457,7 @@ namespace Cantera { * @param value Value of the XML_Node - string * @return Returns a reference to the created child XML_Node object */ - XML_Node& XML_Node::addChild(const std::string name, const std::string value) { + XML_Node& XML_Node::addChild(const std::string &name, const std::string &value) { XML_Node& c = addChild(name); c.addValue(value); return c; @@ -477,7 +478,7 @@ namespace Cantera { * * @return Returns a reference to the created child XML_Node object */ - XML_Node& XML_Node::addChild(const std::string name, const doublereal value, + XML_Node& XML_Node::addChild(const std::string &name, const doublereal value, const std::string fmt) { XML_Node& c = addChild(name); c.addValue(value, fmt); @@ -510,7 +511,7 @@ namespace Cantera { * * @param val string Value that the node will be assigned */ - void XML_Node::addValue(const std::string val) { + void XML_Node::addValue(const std::string &val) { m_value = val; if (m_name == "comment") m_iscomment = true; } @@ -567,7 +568,7 @@ namespace Cantera { * @param cname Name of the child node of the current * node, for which you want the value */ - std::string XML_Node::value(const std::string cname) const { + std::string XML_Node::value(const std::string &cname) const { return child(cname).value(); } @@ -743,7 +744,7 @@ namespace Cantera { * * If the condition is not true, an exception is thrown */ - void XML_Node::_require(const std::string a, const std::string v) const { + void XML_Node::_require(const std::string &a, const std::string &v) const { if (hasAttrib(a)) { if (attrib(a) == v) return; } @@ -1269,8 +1270,13 @@ namespace Cantera { } } - - + XML_Node& XML_Node::root() const { + return *m_root; + } + + void XML_Node::setRoot(const XML_Node& root) { + m_root = const_cast(&root); + } XML_Node * findXMLPhase(XML_Node *root, const std::string &idtarget) { diff --git a/Cantera/src/base/xml.h b/Cantera/src/base/xml.h index 4fe124df9..927310d8d 100755 --- a/Cantera/src/base/xml.h +++ b/Cantera/src/base/xml.h @@ -17,7 +17,6 @@ #include "ctexceptions.h" #include "ct_defs.h" -#include "stringUtils.h" #include "global.h" @@ -133,8 +132,11 @@ namespace Cantera { /*! * Class XML_Node is a tree-based representation of the contents of an XML file. * + * There are routines for adding to the tree. * + * There are routines for querying and searching the tree. * + * Additionally, there are routines for writing the tree out to an output file. * */ class XML_Node { @@ -174,7 +176,7 @@ namespace Cantera { * * @param comment Content of the comment */ - void addComment(const std::string comment); + void addComment(const std::string &comment); //! Add a child node to the current node /*! @@ -197,7 +199,7 @@ namespace Cantera { * * @return Returns a reference to the added node */ - XML_Node& addChild(const std::string sname); + XML_Node& addChild(const std::string &sname); //! Add a child node to the current xml node, and at the //! same time add a value to the child @@ -209,7 +211,7 @@ namespace Cantera { * @param value Value of the XML_Node - string * @return Returns a reference to the created child XML_Node object */ - XML_Node& addChild(const std::string name, const std::string value); + XML_Node& addChild(const std::string &name, const std::string &value); //! Add a child node to the current xml node, and at the //! same time add a formatted value to the child @@ -226,7 +228,7 @@ namespace Cantera { * * @return Returns a reference to the created child XML_Node object */ - XML_Node& addChild(const std::string name, const doublereal value, + XML_Node& addChild(const std::string &name, const doublereal value, const std::string fmt="%g"); //! Remove a child from this node's list of children @@ -244,7 +246,7 @@ namespace Cantera { * * @param val string Value that the node will be assigned */ - void addValue(const std::string val); + void addValue(const std::string &val); //! Modify the value for the current node /*! @@ -274,7 +276,7 @@ namespace Cantera { * @param cname Name of the child node to the current * node, for which you want the value */ - std::string value(const std::string cname) const; + std::string value(const std::string &cname) const; //! Overloaded parenthesis operator with one augment //! returns the value of an XML child node as a string @@ -446,7 +448,7 @@ namespace Cantera { * * If the condition is not true, an exception is thrown */ - void _require(const std::string a, const std::string v) const; + void _require(const std::string &a, const std::string &v) const; //! This routine carries out a recursive search for an XML node based //! on both the xml element name and the attribute ID. @@ -577,8 +579,18 @@ namespace Cantera { */ void write(std::ostream& s, const int level = 0) const; - XML_Node& root() const { return *m_root; } - void setRoot(XML_Node& root) { m_root = &root; } + //! Return the root of the current XML_Node tree + /*! + * Returns a reference to the root of the current + * XML tree + */ + XML_Node& root() const; + + //! Set the root XML_Node value within the current node + /*! + * @param root Value of the root XML_Node. + */ + void setRoot(const XML_Node& root); //! Main routine to create an tree-like representation of an XML file /*! @@ -661,10 +673,38 @@ namespace Cantera { */ std::string m_value; + //! Map containing an index between the node name and the + //! pointer to the node + /*! + * m_childindex[node.name()] = XML_Node *pointer + * + * This object helps to speed up searches + */ std::map m_childindex; + + //! Storage of attributes for a node + /*! + * m_attribs[attribName] = attribValue + */ std::map m_attribs; + + //! Pointer to the parent XML_Node for the current node + /*! + * Note, the top node has a parent value of 0 + */ XML_Node* m_parent; + + //! Pointer to the root XML_Node for the current node + /*! + * Note, the top node has a root value equal to itself + */ XML_Node* m_root; + + //! Lock for this node + /*! + * Currently, unimplemented functionality. If locked, + * it means you can't delete this node. + */ bool m_locked; //! Vector of pointers to child nodes @@ -672,14 +712,28 @@ namespace Cantera { //! Number of children of this node int m_nchildren; - bool m_iscomment; - int m_linenum; - + //! True if the current node is a comment node + bool m_iscomment; + + //! the member data m_linenum + /*! + * Currently, unimplemented functionality + */ + int m_linenum; }; - - XML_Node * findXMLPhase(XML_Node* root, const std::string &id); + //! Search an XML_Node tree for a named phase XML_Node + /*! + * Search for a phase Node matching a name. + * + * @param root Starting XML_Node* pointer for the search + * @param phaseName Name of the phase to search for + * + * @return Returns the XML_Node pointer if the phase is found. + * If the phase is not found, it returns 0 + */ + XML_Node * findXMLPhase(XML_Node* root, const std::string &phaseName); } diff --git a/Cantera/src/oneD/Domain1D.h b/Cantera/src/oneD/Domain1D.h index cd06abeda..0b470aad2 100644 --- a/Cantera/src/oneD/Domain1D.h +++ b/Cantera/src/oneD/Domain1D.h @@ -14,6 +14,7 @@ #include "xml.h" +#include "stringUtils.h" #include "ctexceptions.h" #include "refine.h" diff --git a/Cantera/src/thermo/VPSSMgr_Water_HKFT.h b/Cantera/src/thermo/VPSSMgr_Water_HKFT.h index 6f9c61d2c..365f23553 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_HKFT.h +++ b/Cantera/src/thermo/VPSSMgr_Water_HKFT.h @@ -8,7 +8,6 @@ */ /* - * * $Revision$ * $Date$ */