Finished low lvl doxygen commenting XML_Node object

This commit is contained in:
Harry Moffat 2009-01-05 23:33:44 +00:00
parent aad776eba7
commit 7ba6449978
7 changed files with 90 additions and 26 deletions

View file

@ -25,6 +25,7 @@
#include <cstdlib>
#include <time.h>
#include "ctml.h"
#include "global.h"
using namespace std;

View file

@ -22,9 +22,11 @@
#define CTML_VERSION_1_4_1
#include "global.h"
#include <cctype>
#include <cstring>
using namespace std;
using namespace Cantera;

View file

@ -18,6 +18,7 @@
#include "ct_defs.h"
#include "ctexceptions.h"
#include "global.h"
#include <cstdio>
#include <cstring>
#include <cstdlib>

View file

@ -30,7 +30,8 @@
using namespace std;
#include "xml.h"
#include "global.h"
#include "stringUtils.h"
#include <ctype.h>
#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<int>(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<XML_Node*>(&root);
}
XML_Node * findXMLPhase(XML_Node *root,
const std::string &idtarget) {

View file

@ -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<std::string, XML_Node*> m_childindex;
//! Storage of attributes for a node
/*!
* m_attribs[attribName] = attribValue
*/
std::map<std::string, std::string> 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);
}

View file

@ -14,6 +14,7 @@
#include "xml.h"
#include "stringUtils.h"
#include "ctexceptions.h"
#include "refine.h"

View file

@ -8,7 +8,6 @@
*/
/*
*
* $Revision$
* $Date$
*/