197{
198
199 std::string expr = expr_mod;
200 std::string::size_type start_index = 0;
201 std::string::size_type end_index = 0;
202 while(true)
203 {
204 start_index = expr.find('[', start_index);
205 if(start_index == std::string::npos) break;
206 std::string::size_type boundary_index = expr.find(']', start_index);
207 expr.replace(start_index,1,1,'_');
208 end_index = expr.find(',', start_index);
209 if(end_index != std::string::npos && end_index < boundary_index)
210 {
211 start_index++;
212 std::string var1 = expr.substr(start_index, end_index-start_index);
214 std::stringstream ss1;
215 std::string str1;
216 ss1 << eval1;
217 ss1 >> str1;
218 expr.replace(start_index, end_index-start_index, str1, 0, str1.size());
219 }
220 else
221 {
222 end_index = boundary_index;
223 if(end_index != std::string::npos)
224 {
225 start_index++;
226 std::string var1 = expr.substr(start_index, end_index-start_index);
228 std::stringstream ss1;
229 std::string str1;
230 ss1 << eval1;
231 ss1 >> str1;
232 expr.replace(start_index, end_index-start_index, str1, 0, str1.size());
233 }
234 }
235 }
236 start_index = 0;
237 end_index = 0;
238 while(true)
239 {
240 start_index = expr.find(',', start_index);
241 if(start_index == std::string::npos) break;
242 expr.replace(start_index,1,1,'_');
243 end_index = expr.find(']', start_index);
244 start_index++;
245 std::string var2 = expr.substr(start_index, end_index-start_index);
247 std::stringstream ss2;
248 std::string str2;
249 ss2 << eval2;
250 ss2 >> str2;
251 expr.replace(start_index, end_index-start_index, str2, 0, str2.size());
252 }
253 start_index = 0;
254 end_index = 0;
255 while(true)
256 {
257 start_index = expr.find(']', start_index);
258 if(start_index == std::string::npos) break;
259 expr.replace(start_index,1,1,'_');
260 }
262 if(
m_calc.status() != HepTool::Evaluator::OK )
263 {
264 std::cerr << expr << std::endl;
265 for (
int i=0;
i<
m_calc.error_position();
i++)
266 {
267 std::cerr << "-";
268 }
269 std::cerr << "^\a" << std::endl;
271 std::cerr << std::endl;
272 }
274}
double EvaluateString(const std::string &str)