]> SALOME platform Git repositories - modules/yacs.git/blob - src/bases/Cstr2d.cxx
Salome HOME
copy tag mergefrom_BR_V0_1_CC_Salome_04oct07
[modules/yacs.git] / src / bases / Cstr2d.cxx
1
2 #include "Cstr2d.hxx"
3 #include "Exception.hxx"
4
5 #include <iostream>
6 #include <sstream>
7
8 //! replacement for atof witch does not work everywhere
9 /*!
10  * When using xml parser (parser.cxx) from YACSGui_XMLDriver (in GUI context),
11  * instruction like double d = atof(content); where content = "0.8"
12  * gives d = 0 .
13  * the same binary code called from outside GUI context works fine...
14  */ 
15  
16 double Cstr2d(const char* s)
17 {
18   std::istringstream ss(s);
19   double d;
20   if (!(ss >> d))
21     {
22       std::stringstream msg;
23       msg << "problem in conversion from string to double: " << s ;
24       throw YACS::Exception::Exception(msg.str());
25     }
26   return d;
27 }