Version: 8.3.0
Cstr2d.hxx File Reference
Include dependency graph for Cstr2d.hxx:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

YACSBASES_EXPORT double Cstr2d (const char *s)
 replacement for atof witch does not work everywhere More...
 

Function Documentation

YACSBASES_EXPORT double Cstr2d ( const char *  s)

replacement for atof witch does not work everywhere

When using xml parser (parser.cxx) from YACSGui_XMLDriver (in GUI context), instruction like double d = atof(content); where content = "0.8" gives d = 0 . the same binary code called from outside GUI context works fine...

Definition at line 34 of file Cstr2d.cxx.

Referenced by YACS::ENGINE::convertToYacsDouble< XMLImpl, xmlDocPtr, xmlNodePtr, IMPLOUT, TOUT >::convert(), and YACS::doubletypeParser::post().

35 {
36  std::istringstream ss(s);
37  double d;
38  if (!(ss >> d))
39  {
40  std::stringstream msg;
41  msg << "problem in conversion from string to double: " << s ;
42  throw YACS::Exception(msg.str());
43  }
44  return d;
45 }