Version: 9.16.0
Cstr2d.cxx File Reference
#include "Cstr2d.hxx"
#include "Exception.hxx"
#include <iostream>
#include <sstream>
Include dependency graph for Cstr2d.cxx:

Go to the source code of this file.

Functions

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

Function Documentation

◆ Cstr2d()

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.

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}

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