Changeset 270


Ignore:
Timestamp:
Apr 13, 2005, 3:37:14 PM (16 years ago)
Author:
Peter
Message:

bug fixes

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/stl_utility.cc

    r266 r270  
    6767  bool read_to_double(std::istream& is, std::vector<double>& vec)
    6868  {
     69    vec.resize(0);
    6970    std::vector<std::string> vec_str;
    7071    if (read_to_string(is,vec_str)){
     
    7475                    << " is not a number." << std::endl;
    7576        }
    76         vec.push_back(atoi(vec_str[i].c_str()));
     77        vec.push_back(atof(vec_str[i].c_str()));
    7778      }
    7879      return true;
     
    8485  bool read_to_int(std::istream& is, std::vector<int>& vec)
    8586  {
     87    vec.resize(0);
    8688    std::vector<std::string> vec_str;
    8789    if (read_to_string(is,vec_str)){
     
    101103  bool read_to_string(std::istream& is, std::vector<std::string>& vec)
    102104  {
     105    vec.resize(0);
    103106    std::string s;
    104107    if (getline(is, s, '\n')){
  • trunk/src/stl_utility.h

    r263 r270  
    4242  /// @return true if string is a number
    4343  ///
    44   bool is_float(std::string&);
     44  bool is_float(const std::string&);
    4545
    4646  ///
     
    4848  /// first one that may be '+' or '-'
    4949  ///
    50   bool is_int(std::string&);
     50  bool is_int(const std::string&);
    5151
    5252  ///
    5353  /// Function reading from istream to vector of doubles. Function
    54   /// reads the line until next '\n'. The line is splitted with
    55   /// respect to whitespaces and push_backed into the vector.
     54  /// reads the line until next '\\n'. The line is splitted with
     55  /// respect to whitespaces and push_backed into the vector. The
     56  /// vector is emptied before the reading starts.
    5657  ///
    5758  /// @return false if end of stream
     
    6162  ///
    6263  /// Function reading from istream to vector of ints. Function
    63   /// reads the line until next '\n'. The line is splitted with
    64   /// respect to whitespaces and push_backed into the vector.
     64  /// reads the line until next '\\n'. The line is splitted with
     65  /// respect to whitespaces and push_backed into the vector. The
     66  /// vector is emptied before the reading starts.
    6567  ///
    6668  /// @return false if end of stream
     
    7072  ///
    7173  /// Function reading from istream to vector of strings. Function
    72   /// reads the line until next '\n'. The line is splitted with
    73   /// respect to whitespaces and push_backed into the vector.
     74  /// reads the line until next '\\n'. The line is splitted with
     75  /// respect to whitespaces and push_backed into the vector. The
     76  /// vector is emptied before the reading starts.
    7477  ///
    7578  /// @return false if end of stream
Note: See TracChangeset for help on using the changeset viewer.