MCPcopy Create free account
hub / github.com/Cantera/cantera / fpValueCheck

Function fpValueCheck

src/base/stringUtils.cpp:130–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128}
129
130double fpValueCheck(const string& val)
131{
132 string str = ba::trim_copy(val);
133 if (str.empty()) {
134 throw CanteraError("fpValueCheck", "string has zero length");
135 }
136 int numDot = 0;
137 int numExp = 0;
138 char ch;
139 int istart = 0;
140 ch = str[0];
141 if (ch == '+' || ch == '-') {
142 if (str.size() == 1) {
143 throw CanteraError("fpValueCheck", "string '{}' ends in '{}'", val, ch);
144 }
145 istart = 1;
146 }
147 for (size_t i = istart; i < str.size(); i++) {
148 ch = str[i];
149 if (isdigit(ch)) {
150 } else if (ch == '.') {
151 numDot++;
152 if (numDot > 1) {
153 throw CanteraError("fpValueCheck",
154 "string '{}' has more than one decimal point.", val);
155 }
156 if (numExp > 0) {
157 throw CanteraError("fpValueCheck",
158 "string '{}' has decimal point in exponent", val);
159 }
160 } else if (ch == 'e' || ch == 'E' || ch == 'd' || ch == 'D') {
161 numExp++;
162 str[i] = 'E';
163 if (numExp > 1) {
164 throw CanteraError("fpValueCheck",
165 "string '{}' has more than one exp char", val);
166 } else if (i == str.size() - 1) {
167 throw CanteraError("fpValueCheck", "string '{}' ends in '{}'", val, ch);
168 }
169 ch = str[i+1];
170 if (ch == '+' || ch == '-') {
171 if (i + 1 == str.size() - 1) {
172 throw CanteraError("fpValueCheck",
173 "string '{}' ends in '{}'", val, ch);
174 }
175 i++;
176 }
177 } else {
178 throw CanteraError("fpValueCheck", "Trouble processing string '{}'", str);
179 }
180 }
181 return fpValue(str);
182}
183
184void tokenizeString(const string& in_val, vector<string>& v)
185{

Callers 5

parseCompStringFunction · 0.85
UnitsMethod · 0.85
split_unitFunction · 0.85
setupMu0Function · 0.85
parseReactionEquationFunction · 0.85

Calls 4

CanteraErrorClass · 0.85
fpValueFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by 1

setupMu0Function · 0.68