Doxygen updates
This commit is contained in:
parent
3bd378733a
commit
8a740e53d8
3 changed files with 74 additions and 33 deletions
|
|
@ -31,17 +31,17 @@ namespace Cantera {
|
||||||
* Convert a floating point number to a std::string using sprintf.
|
* Convert a floating point number to a std::string using sprintf.
|
||||||
*/
|
*/
|
||||||
std::string fp2str(double x, std::string fmt) {
|
std::string fp2str(double x, std::string fmt) {
|
||||||
char buf[30];
|
char buf[64];
|
||||||
int n = SNPRINTF(buf, 30, fmt.c_str(), x);
|
int n = SNPRINTF(buf, 63, fmt.c_str(), x);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
buf[29] = '\0';
|
buf[63] = '\0';
|
||||||
return std::string(buf);
|
return std::string(buf);
|
||||||
}
|
}
|
||||||
return std::string(" ");
|
return std::string(" ");
|
||||||
}
|
}
|
||||||
std::string fp2str(double x) {
|
std::string fp2str(double x) {
|
||||||
char buf[30];
|
char buf[64];
|
||||||
int n = SNPRINTF(buf, 30, "%g" , x);
|
int n = SNPRINTF(buf, 64, "%g" , x);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
buf[29] = '\0';
|
buf[29] = '\0';
|
||||||
return std::string(buf);
|
return std::string(buf);
|
||||||
|
|
|
||||||
|
|
@ -525,9 +525,34 @@ namespace Cantera {
|
||||||
* Default is "%g" Must be less than 63 chars
|
* Default is "%g" Must be less than 63 chars
|
||||||
*/
|
*/
|
||||||
void XML_Node::addValue(const doublereal val, const std::string fmt) {
|
void XML_Node::addValue(const doublereal val, const std::string fmt) {
|
||||||
char buf[64];
|
m_value = stripws(fp2str(val, fmt));
|
||||||
sprintf(buf, fmt.c_str(), val);
|
}
|
||||||
m_value = stripws(buf);
|
|
||||||
|
// Add or modify an attribute of the current node
|
||||||
|
/*
|
||||||
|
* This functions fills in the m_value field of the current node
|
||||||
|
* with a string value
|
||||||
|
*
|
||||||
|
* @param attrib String name for the attribute to be assigned
|
||||||
|
* @param value String value that the attribute will have
|
||||||
|
*/
|
||||||
|
void XML_Node::addAttribute(const std::string attrib, const std::string value) {
|
||||||
|
m_attribs[attrib] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add or modify an attribute to the double, value
|
||||||
|
/*
|
||||||
|
* This functions fills in the attribute field, named attrib,
|
||||||
|
* with the double value, value. A formatting string is used.
|
||||||
|
*
|
||||||
|
* @param attrib String name for the attribute to be assigned
|
||||||
|
* @param value double Value that the node will be assigned
|
||||||
|
* @param fmt Format of the printf string conversion of the double.
|
||||||
|
* Default is "%g".
|
||||||
|
*/
|
||||||
|
void XML_Node::addAttribute(const std::string attrib,
|
||||||
|
const doublereal value, const std::string fmt) {
|
||||||
|
m_attribs[attrib] = fp2str(value, fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The operator[] is overloaded to provide a lookup capability
|
// The operator[] is overloaded to provide a lookup capability
|
||||||
|
|
@ -545,7 +570,7 @@ namespace Cantera {
|
||||||
* within the XML node. If there is no attribute
|
* within the XML node. If there is no attribute
|
||||||
* with the given name, it returns the null string.
|
* with the given name, it returns the null string.
|
||||||
*/
|
*/
|
||||||
std::string XML_Node::operator[](std::string attr) const {
|
std::string XML_Node::operator[](const std::string attr) const {
|
||||||
return attrib(attr);
|
return attrib(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -671,14 +696,6 @@ namespace Cantera {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void XML_Node::addAttribute(string attrib, string value) {
|
|
||||||
m_attribs[attrib] = value;
|
|
||||||
}
|
|
||||||
void XML_Node::addAttribute(string attrib, double value, string fmt) {
|
|
||||||
m_attribs[attrib] = fp2str(value, fmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void XML_Node::writeHeader(ostream& s) {
|
void XML_Node::writeHeader(ostream& s) {
|
||||||
s << "<?xml version=\"1.0\"?>" << endl;
|
s << "<?xml version=\"1.0\"?>" << endl;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -229,22 +229,28 @@ namespace Cantera {
|
||||||
*/
|
*/
|
||||||
void addValue(const doublereal val, const std::string fmt="%g");
|
void addValue(const doublereal val, const std::string fmt="%g");
|
||||||
|
|
||||||
void addAttribute(std::string attrib, std::string value);
|
//! Add or modify an attribute of the current node
|
||||||
void addAttribute(std::string attrib, double value, std::string fmt="%g");
|
/*!
|
||||||
void writeHeader(std::ostream& s);
|
* This functions fills in the m_value field of the current node
|
||||||
std::string value() const { return m_value; }
|
* with a string value
|
||||||
std::string value(std::string loc) const { return child(loc).value(); }
|
*
|
||||||
void setLineNumber(int n) {m_linenum = n;}
|
* @param attrib String name for the attribute to be assigned
|
||||||
int lineNumber() const {return m_linenum;}
|
* @param value String value that the attribute will have
|
||||||
doublereal fp_value() const {
|
*/
|
||||||
return std::atof(m_value.c_str());
|
void addAttribute(const std::string attrib, const std::string value);
|
||||||
}
|
|
||||||
integer int_value() const {
|
|
||||||
return std::atoi(m_value.c_str());
|
|
||||||
}
|
|
||||||
std::string operator()() const { return m_value; }
|
|
||||||
std::string operator()(std::string loc) const { return value(loc); }
|
|
||||||
|
|
||||||
|
//! Add or modify an attribute to the double, value
|
||||||
|
/*!
|
||||||
|
* This functions fills in the attribute field, named attrib,
|
||||||
|
* with the double value, value. A formatting string is used.
|
||||||
|
*
|
||||||
|
* @param attrib String name for the attribute to be assigned
|
||||||
|
* @param value double Value that the node will be assigned
|
||||||
|
* @param fmt Format of the printf string conversion of the double.
|
||||||
|
* Default is "%g".
|
||||||
|
*/
|
||||||
|
void addAttribute(const std::string attrib, const double value,
|
||||||
|
const std::string fmt="%g");
|
||||||
|
|
||||||
//! The operator[] is overloaded to provide a lookup capability
|
//! The operator[] is overloaded to provide a lookup capability
|
||||||
//! on attributes for the current XML element.
|
//! on attributes for the current XML element.
|
||||||
|
|
@ -261,7 +267,7 @@ namespace Cantera {
|
||||||
* within the XML node. If there is no attribute
|
* within the XML node. If there is no attribute
|
||||||
* with the given name, it returns the null string.
|
* with the given name, it returns the null string.
|
||||||
*/
|
*/
|
||||||
std::string operator[](std::string attr) const;
|
std::string operator[](const std::string attr) const;
|
||||||
|
|
||||||
//! Function returns the value of an attribute
|
//! Function returns the value of an attribute
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -278,8 +284,25 @@ namespace Cantera {
|
||||||
*/
|
*/
|
||||||
std::string attrib(const std::string attr) const;
|
std::string attrib(const std::string attr) const;
|
||||||
|
|
||||||
|
void writeHeader(std::ostream& s);
|
||||||
|
std::string value() const { return m_value; }
|
||||||
|
std::string value(std::string loc) const { return child(loc).value(); }
|
||||||
|
void setLineNumber(int n) {m_linenum = n;}
|
||||||
|
int lineNumber() const {return m_linenum;}
|
||||||
|
doublereal fp_value() const {
|
||||||
|
return std::atof(m_value.c_str());
|
||||||
|
}
|
||||||
|
integer int_value() const {
|
||||||
|
return std::atoi(m_value.c_str());
|
||||||
|
}
|
||||||
|
std::string operator()() const { return m_value; }
|
||||||
|
std::string operator()(std::string loc) const { return value(loc); }
|
||||||
|
|
||||||
|
|
||||||
std::map<std::string,std::string>& attribs() { return m_attribs; }
|
std::map<std::string,std::string>& attribs() { return m_attribs; }
|
||||||
|
|
||||||
XML_Node* parent() const { return m_parent; }
|
XML_Node* parent() const { return m_parent; }
|
||||||
|
|
||||||
XML_Node* setParent(XML_Node* p) { m_parent = p; return p; }
|
XML_Node* setParent(XML_Node* p) { m_parent = p; return p; }
|
||||||
|
|
||||||
//! Tests whether the current node has a child node with a particular name
|
//! Tests whether the current node has a child node with a particular name
|
||||||
|
|
@ -382,6 +405,7 @@ namespace Cantera {
|
||||||
* has a m_value string containing "valueString".
|
* has a m_value string containing "valueString".
|
||||||
*/
|
*/
|
||||||
std::string m_value;
|
std::string m_value;
|
||||||
|
|
||||||
std::map<std::string, XML_Node*> m_childindex;
|
std::map<std::string, XML_Node*> m_childindex;
|
||||||
std::map<std::string, std::string> m_attribs;
|
std::map<std::string, std::string> m_attribs;
|
||||||
XML_Node* m_parent;
|
XML_Node* m_parent;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue