Fix integer sign/size warnings in XML-related functions

This commit is contained in:
Ray Speth 2014-02-21 19:08:40 +00:00
parent 6f8da1a27e
commit 0392147540
4 changed files with 11 additions and 3 deletions

View file

@ -212,7 +212,7 @@ void addFloatArray(Cantera::XML_Node& node, const std::string& titleString,
* parameter. The default is the special double,
* Cantera::Undef, which means to ignore the entry.
*/
void addNamedFloatArray(Cantera::XML_Node& parentNode, const std::string& name, const int n,
void addNamedFloatArray(Cantera::XML_Node& parentNode, const std::string& name, const size_t n,
const doublereal* const vals, const std::string units = "",
const std::string type = "",
const doublereal minval = Cantera::Undef,

View file

@ -280,6 +280,9 @@ public:
void addAttribute(const std::string& attrib, const doublereal value,
const std::string& fmt="%g");
//! Add an unsigned integer attribute
void addAttribute(const std::string& attrib, size_t value);
//! The operator[] is overloaded to provide a lookup capability
//! on attributes for the current XML element.
/*!

View file

@ -95,13 +95,13 @@ void addFloatArray(Cantera::XML_Node& node, const std::string& title, const size
}
}
void addNamedFloatArray(Cantera::XML_Node& node, const std::string& name, const int n,
void addNamedFloatArray(Cantera::XML_Node& node, const std::string& name, const size_t n,
const doublereal* const vals, const std::string units,
const std::string type, const doublereal minval,
const doublereal maxval)
{
std::string v = "";
for (int i = 0; i < n; i++) {
for (size_t i = 0; i < n; i++) {
v += fp2str(vals[i],FP_Format);
if (i == n-1) {
v += "\n";

View file

@ -501,6 +501,11 @@ void XML_Node::addAttribute(const std::string& attrib_,
m_attribs[attrib_] = fp2str(value_, fmt);
}
void XML_Node::addAttribute(const std::string& attrib_, const size_t value_)
{
m_attribs[attrib_] = int2str(value_);
}
std::string XML_Node::operator[](const std::string& attr) const
{
return attrib(attr);