This was left out of previous commits
Broke getStringArray into 2 added strSItoDbl which converts a string with units into a double value
This commit is contained in:
parent
595630e399
commit
b739568620
4 changed files with 34 additions and 5 deletions
|
|
@ -618,9 +618,21 @@ namespace ctml {
|
|||
* v.
|
||||
*/
|
||||
void getStringArray(const XML_Node& node, vector<string>& v) {
|
||||
string val = node.value();
|
||||
getStringArray(val, v);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function interprets the value portion of an XML element
|
||||
* as a string. It then separates the string up into tokens
|
||||
* according to the location of white space.
|
||||
* The separate tokens are returned in the string vector,
|
||||
* v.
|
||||
*/
|
||||
void getStringArray(const std::string& oval, vector<string>& v) {
|
||||
std::string val(oval);
|
||||
string::size_type ibegin, iend;
|
||||
v.clear();
|
||||
string val = node.value();
|
||||
while (1 > 0) {
|
||||
ibegin = findFirstNotOfWS(val);
|
||||
//val.find_first_not_of(" \n\t");
|
||||
|
|
@ -640,10 +652,8 @@ namespace ctml {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void getFunction(const XML_Node& node, string& type, doublereal& xmin,
|
||||
doublereal& xmax, vector_fp& coeffs) {
|
||||
const XML_Node& c = node.child("floatArray");
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ namespace ctml {
|
|||
std::string nodeName = "floatArray");
|
||||
|
||||
void getStringArray(const Cantera::XML_Node& node, std::vector<std::string>& v);
|
||||
void getStringArray(const std::string& val, std::vector<std::string>& v);
|
||||
void getMap(const Cantera::XML_Node& node, std::map<std::string, std::string>& m);
|
||||
void getPairs(const Cantera::XML_Node& node, std::vector<std::string>& key,
|
||||
std::vector<std::string>& val);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "ctml.h"
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
|
|
@ -72,7 +74,7 @@ namespace Cantera {
|
|||
return std::string(" ");
|
||||
}
|
||||
|
||||
std::string lowercase(std::string s) {
|
||||
std::string lowercase(const std::string &s) {
|
||||
int n = static_cast<int>(s.size());
|
||||
std::string lc(s);
|
||||
for (int i = 0; i < n; i++) lc[i] = tolower(s[i]);
|
||||
|
|
@ -394,4 +396,19 @@ namespace Cantera {
|
|||
return rval;
|
||||
}
|
||||
|
||||
|
||||
doublereal strSItoDbl(const std::string& strSI) {
|
||||
std::vector<std::string> v;
|
||||
ctml::getStringArray(strSI, v);
|
||||
doublereal fp = 1.0;
|
||||
int n = v.size();
|
||||
if (n > 2 || n < 1) {
|
||||
throw CanteraError("strSItoDbl",
|
||||
"number of tokens is too high");
|
||||
} else if (n == 2) {
|
||||
fp = toSI(v[1]);
|
||||
}
|
||||
doublereal val = atofCheck(v[0].c_str());
|
||||
return (val * fp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Cantera {
|
|||
std::string int2str(int n);
|
||||
std::string stripws(std::string s);
|
||||
std::string stripnonprint(std::string s);
|
||||
std::string lowercase(std::string s);
|
||||
std::string lowercase(const std::string &s);
|
||||
void parseCompString(const std::string ss, compositionMap& x);
|
||||
void split(const std::string ss, std::vector<std::string>& w);
|
||||
int fillArrayFromString(const std::string& str, doublereal* a, char delim = ' ');
|
||||
|
|
@ -66,6 +66,7 @@ namespace Cantera {
|
|||
|
||||
int stripLTWScstring(char str[]);
|
||||
double atofCheck(const char *dptr);
|
||||
doublereal strSItoDbl(const std::string& strSI);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue