From b84664267b274dddb87823cb69d4dc5561781b76 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Fri, 2 Jul 2004 14:39:29 +0000 Subject: [PATCH] static_cast to eliminate VC++ warning messages. --- Cantera/src/ReactionPath.h | 14 ++++++++------ Cantera/src/importCTML.cpp | 30 +++++++++++++++--------------- Cantera/src/stringUtils.cpp | 12 ++++++------ 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/Cantera/src/ReactionPath.h b/Cantera/src/ReactionPath.h index 4de70cb83..dbaa397d4 100755 --- a/Cantera/src/ReactionPath.h +++ b/Cantera/src/ReactionPath.h @@ -65,7 +65,7 @@ namespace Cantera { /// Total number of paths to or from this node - int nPaths() const { return m_paths.size(); } + int nPaths() const { return static_cast(m_paths.size()); } /// add a path to or from this node void addPath(Path* path); @@ -122,7 +122,9 @@ namespace Cantera { void setFlow(doublereal v) { m_total = v; } /// Number of reactions contributing to this path - int nReactions() { return m_rxn.size(); } + int nReactions() { + return static_cast(m_rxn.size()); + } /// Map from reaction number to flow from that reaction in this path. const rxn_path_map& reactionMap() { return m_rxn; } @@ -173,8 +175,8 @@ namespace Cantera { SpeciesNode* node(int k) { return m_nodes[k]; } Path* path(int k1, int k2) { return m_paths[k1][k2]; } Path* path(int n) { return m_pathlist[n]; } - int nPaths() { return m_pathlist.size(); } - int nNodes() { return m_nodes.size(); } + int nPaths() { return static_cast(m_pathlist.size()); } + int nNodes() { return static_cast(m_nodes.size()); } void addNode(int k, string nm, doublereal x = 0.0); @@ -186,11 +188,11 @@ namespace Cantera { void include(string name) { m_include.push_back(name); } void exclude(string name) { m_exclude.push_back(name); } void include(vector& names) { - int n = names.size(); + int n = static_cast(names.size()); for (int i = 0; i < n; i++) m_include.push_back(names[i]); } void exclude(vector& names) { - int n = names.size(); + int n = static_cast(names.size()); for (int i = 0; i < n; i++) m_exclude.push_back(names[i]); } vector& included() { return m_include; } diff --git a/Cantera/src/importCTML.cpp b/Cantera/src/importCTML.cpp index 1e62c234e..a354e71fa 100755 --- a/Cantera/src/importCTML.cpp +++ b/Cantera/src/importCTML.cpp @@ -348,7 +348,7 @@ namespace Cantera { vector key, val; getPairs(rg, key, val); - int ns = key.size(); + int ns = static_cast(key.size()); /* * Loop over each of the pairs and process them @@ -400,7 +400,7 @@ namespace Cantera { if (rp == 1 && rxn.hasChild("order")) { vector ord; rxn.getChildren("order",ord); - int norder = ord.size(); + int norder = static_cast(ord.size()); int loc; doublereal forder; for (int nn = 0; nn < norder; nn++) { @@ -504,7 +504,7 @@ namespace Cantera { thermo_t& surfphase, ReactionData& rdata) { vector cov; node.getChildren("coverage", cov); - int k, nc = cov.size(); + int k, nc = static_cast(cov.size()); doublereal e; string spname; if (nc > 0) { @@ -529,7 +529,7 @@ namespace Cantera { vector p; getStringArray(f,p); vector_fp c; - int np = p.size(); + int np = static_cast(p.size()); for (int n = 0; n < np; n++) { c.push_back(fpValue(p[n])); } @@ -556,7 +556,7 @@ namespace Cantera { vector key, val; getPairs(eff, key, val); - int ne = key.size(); + int ne = static_cast(key.size()); string nm; string phse = kin.thermo(0).id(); int n, k; @@ -781,7 +781,7 @@ namespace Cantera { XML_Node* db = 0; vector sparrays; phase.getChildren("speciesArray", sparrays); - int jsp, nspa = sparrays.size(); + int jsp, nspa = static_cast(sparrays.size()); vector dbases; vector_int sprule(nspa,0); @@ -846,14 +846,14 @@ namespace Cantera { // Get the array of species name strings. vector spnames; getStringArray(species, spnames); - int nsp = spnames.size(); + int nsp = static_cast(spnames.size()); // if 'all' is specified, then add all species // defined in this database to the phase if (nsp == 1 && spnames[0] == "all") { vector allsp; db->getChildren("species",allsp); - nsp = allsp.size(); + nsp = static_cast(allsp.size()); spnames.resize(nsp); for (int nn = 0; nn < nsp; nn++) { spnames[nn] = (*allsp[nn])["name"]; @@ -992,7 +992,7 @@ next: else eqn = ""; - eqlen = eqn.size(); + eqlen = static_cast(eqn.size()); for (nn = 0; nn < eqlen; nn++) { if (eqn[nn] == '[') eqn[nn] = '<'; if (eqn[nn] == ']') eqn[nn] = '>'; @@ -1080,7 +1080,7 @@ next: for (nn = 0; nn < np; nn++) { rxnstoich[rdata.products[nn]+1] += rdata.pstoich[nn]; } - int nrxns = _reactiondata.size(); + int nrxns = static_cast(_reactiondata.size()); for (nn = 0; nn < nrxns; nn++) { if ((int(rdata.reactants.size()) == _nr[nn]) && (rdata.reactionType == _typ[nn])) { @@ -1168,7 +1168,7 @@ next: * end result being purely additive. */ p.getChildren("reactionArray",rarrays); - int na = rarrays.size(); + int na = static_cast(rarrays.size()); if (na == 0) return false; for (int n = 0; n < na; n++) { /* @@ -1212,11 +1212,11 @@ next: */ vector incl; rxns.getChildren("include",incl); - int ninc = incl.size(); + int ninc = static_cast(incl.size()); vector allrxns; rdata->getChildren("reaction",allrxns); - nrxns = allrxns.size(); + nrxns = static_cast(allrxns.size()); // if no 'include' directive, then include all reactions if (ninc == 0) { for (i = 0; i < nrxns; i++) { @@ -1328,8 +1328,8 @@ next: } phase_ids.push_back(default_phase); - int np = phase_ids.size(); - int nt = th.size(); + int np = static_cast(phase_ids.size()); + int nt = static_cast(th.size()); // for each referenced phase, attempt to find its id among those // phases specified. diff --git a/Cantera/src/stringUtils.cpp b/Cantera/src/stringUtils.cpp index ca2a70880..76b424a23 100755 --- a/Cantera/src/stringUtils.cpp +++ b/Cantera/src/stringUtils.cpp @@ -37,7 +37,7 @@ namespace Cantera { } string lowercase(string s) { - int n = s.size(); + int n = static_cast(s.size()); string lc(s); for (int i = 0; i < n; i++) lc[i] = tolower(s[i]); return lc; @@ -49,7 +49,7 @@ namespace Cantera { string stripws(string s) { int i; bool sempty = true; - int n = s.size(); + int n = static_cast(s.size()); string ss = ""; for (i = 0; i < n; i++) { if (s[i] != ' ' && isprint(s[i])) { @@ -66,7 +66,7 @@ namespace Cantera { */ string stripnonprint(string s) { int i; - int n = s.size(); + int n = static_cast(s.size()); string ss = ""; for (i = 0; i < n; i++) { if (isprint(s[i])) { @@ -82,11 +82,11 @@ namespace Cantera { */ void parseCompString(const string ss, compositionMap& x) { string s = ss; - int icolon, ibegin, iend; + string::size_type icolon, ibegin, iend; string name, num, nm; do { ibegin = s.find_first_not_of(", ;\n\t"); - if (ibegin >= 0) { + if (ibegin != string::npos) { s = s.substr(ibegin,s.size()); icolon = s.find(':'); iend = s.find_first_of(", ;\n\t"); @@ -115,7 +115,7 @@ namespace Cantera { } int fillArrayFromString(const string& str, doublereal* a, char delim) { - int iloc; + string::size_type iloc; int count = 0; string num, s; s = str;