Ignore:
Timestamp:
Aug 30, 2006, 10:49:45 AM (15 years ago)
Author:
Markus Ringnér
Message:

Fixes #98

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/c++_tools/utility/utility.cc

    r570 r609  
    3838    std::stringstream ss(s);
    3939    double a;
    40     return (ss>>a);
     40    ss>>a;
     41    if(ss.fail())
     42      return false;
     43    // Check that nothing is left on stream
     44    std::string b;
     45    ss >> b;
     46    return (b.size() ? false : true);
    4147  }
    4248 
     
    4551    std::stringstream ss(s);
    4652    float a;
    47     return (ss>>a);
     53    ss>>a;
     54    if(ss.fail())
     55      return false;
     56    // Check that nothing is left on stream
     57    std::string b;
     58    ss >> b;
     59    return (b.size() ? false : true);
    4860  }
    4961
     
    5264    std::stringstream ss(s);
    5365    int a;
    54     return (ss>>a);
     66    ss >> a;
     67    if(ss.fail())
     68      return false;
     69    // Check that nothing is left on stream
     70    std::string b;
     71    ss >> b;
     72    return (b.size() ? false : true);
    5573  }
    5674
     
    6179    ss >> s2; // to trim surrounding whitespaces
    6280    to_lower(s2);
     81    // Check that nothing is left on stream
     82    std::string s3;
     83    ss >> s3;
     84    if(s3.size())
     85      return false;
    6386    std::string nan("nan");
    6487    return (nan==s2);
Note: See TracChangeset for help on using the changeset viewer.