static_cast to eliminate VC++ warnings.

This commit is contained in:
Harry Moffat 2004-07-02 17:21:39 +00:00
parent a62b420e26
commit e5fa6790da
4 changed files with 30 additions and 26 deletions

View file

@ -64,7 +64,7 @@ namespace ckr {
}
void Reaction::write(ostream& s) const {
int nl = lines.size();
int nl = static_cast<int>(lines.size());
for (int nn = 0; nn < nl; nn++) {
s << lines[nn] << endl;
}
@ -111,10 +111,10 @@ namespace ckr {
double Reaction::stoichCoefficient(const string& s) const {
int k;
int nr = reactants.size();
int nr = static_cast<int>(reactants.size());
for (k = 0; k < nr; k++)
if (reactants[k].name == s) return -reactants[k].number;
int np = products.size();
int np = static_cast<int>(products.size());
for (k = 0; k < np; k++)
if (products[k].name == s) return products[k].number;
return 0.0;
@ -125,8 +125,8 @@ double Reaction::stoichCoefficient(const string& s) const {
* @todo could be made faster
*/
bool Reaction::operator==(const Reaction& r) const {
int nr = reactants.size();
int np = products.size();
int nr = static_cast<int>(reactants.size());
int np = static_cast<int>(products.size());
if (int(r.reactants.size()) != nr ||
int(r.products.size()) != np || r.thirdBody != thirdBody) return false;
@ -148,7 +148,7 @@ bool Reaction::operator==(const Reaction& r) const {
if (coeffs[nm] == 0.0) return false;
coeffs[nm] /= products[jp].number;
}
int nc = coeffs.size();
int nc = static_cast<int>(coeffs.size());
vector<double> ratios;
getMapValues(coeffs, ratios);

View file

@ -32,7 +32,7 @@ bool match(const string& s1, const string& s2)
/// remove all white space from string s.
void removeWhiteSpace(string& s) {
string r;
int ssize = s.size();
int ssize = static_cast<int>(s.size());
for (int n = 0; n < ssize; n++) if (s[n] != ' '
&& s[n] != '\t' && s[n] != '\n') r += s[n];
s = r;
@ -76,7 +76,7 @@ void getTokens(string& s, int n, vector<string>& toks, char delim) {
}
toks.clear();
int nt = tokk.size();
int nt = static_cast<int>(tokk.size());
string t = "";
for (int i = 0; i < nt; i++) {
if (tokk[i][0] == '/') t += tokk[i];
@ -97,25 +97,25 @@ void getTokens(string& s, int n, vector<string>& toks, char delim) {
* false otherwise.
*/
bool extractSlashData(string& s, string& name, string& data) {
int slen = s.size();
int n = s.find_first_of("/");
if (n >= 0 && n < slen) {
int m;
for (m = n+1; m < slen; m++) if (s[m] == '/') break;
if (m < slen) {
int slen = static_cast<int>(s.size());
string::size_type n = s.find_first_of("/");
if (n != string::npos && (static_cast<int>(n) < slen)) {
int m;
for (m = static_cast<int>(n)+1; m < slen; m++) if (s[m] == '/') break;
if (m < slen) {
data = s.substr(n+1,m-n-1);
name = s.substr(0,n);
removeWhiteSpace(name);
s = s.substr(m+1,1000);
return true;
}
else {
}
else {
name = s;
removeWhiteSpace(name);
data = "";
s = "";
return false;
}
}
}
else {
name = s;
@ -133,7 +133,7 @@ bool extractSlashData(string& s, string& name, string& data) {
*/
string capitalize(const string& word) {
string cap = word;
int n = word.size();
int n = static_cast<int>(word.size());
if (n > 0) {
cap[0] = toupper(word[0]);
for (int m = 1; m < n; m++) {

View file

@ -67,7 +67,7 @@ namespace ckr {
cerr << "could not open " << outfile << endl;
return false;
}
int nel = ck.elements.size();
int nel = static_cast<int>(ck.elements.size());
int n;
// write header information
@ -83,7 +83,7 @@ namespace ckr {
for (n = 0; n < nel; n++) fout << ck.elements[n];
fout << "END" << endl;
int nsp = species.size();
int nsp = static_cast<int>(species.size());
fout << "SPECIES" << endl;
for (n = 0; n < nsp; n++) {
fout << ck.species[ species[n] ].name << " ";
@ -91,10 +91,10 @@ namespace ckr {
}
fout << "END" << endl;
fout << "REACTIONS" << endl;
int nrxns = reactions.size();
int nrxns = static_cast<int>(reactions.size());
for (n = 0; n < nrxns; n++) {
vector<string>& lines = ck.reactions[reactions[n]].lines;
int nl = lines.size();
int nl = static_cast<int>(lines.size());
for (int j = 0; j < nl; j++) fout << lines[j] << endl;
}
fout.close();

View file

@ -50,7 +50,9 @@ namespace ckr {
<< ", " << c[2] << ", " << c[3] << ")" << endl;
}
else {
for (size_t n = 0; n < c.size(); n++) log << c[n] << ", "; log << endl;
for (ct::ctvector_fp::size_t n = 0; n < c.size(); n++) {
log << c[n] << ", "; log << endl;
}
log << "###### ERROR ##### incorrect number of parameters" << endl;
return false;
}
@ -68,7 +70,9 @@ namespace ckr {
<< ")" << endl;
}
else {
for (size_t n = 0; n < c.size(); n++) log << c[n] << ", "; log << endl;
for (ct::ctvector_fp::size_t n = 0; n < c.size(); n++) {
log << c[n] << ", "; log << endl;
}
log << "##### ERROR ##### incorrect number of parameters" << endl;
return false;
}
@ -150,8 +154,8 @@ namespace ckr {
*/
string reactionEquation(const Reaction& r) {
string s = "";
int nr = r.reactants.size();
int np = r.products.size();
int nr = static_cast<int>(r.reactants.size());
int np = static_cast<int>(r.products.size());
int k;
double m;
char buf[20];