Changeset 917 for trunk/yat/utility/utility.cc
 Timestamp:
 Sep 30, 2007, 3:26:36 AM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/utility.cc
r865 r917 39 39 bool is_double(const std::string& s) 40 40 { 41 if (is_nan(s)  is_equal(s, "inf")  is_equal(s, "inf")) 42 return true; 41 43 std::stringstream ss(s); 42 44 double a; … … 50 52 } 51 53 54 55 bool is_equal(std::string s, std::string other) 56 { 57 std::stringstream ss(s); 58 std::string s2; 59 ss >> s2; // to trim surrounding whitespaces 60 to_lower(s2); 61 // Check that nothing is left on stream 62 std::string s3; 63 ss >> s3; 64 if(s3.size()) 65 return false; 66 return (other==s2); 67 } 68 69 52 70 bool is_float(const std::string& s) 53 71 { 72 if (is_nan(s)  is_equal(s, "inf")  is_equal(s, "inf")) 73 return true; 54 74 std::stringstream ss(s); 55 75 float a; … … 63 83 } 64 84 85 65 86 bool is_int(const std::string& s) 66 87 { 88 if (is_nan(s)  is_equal(s, "inf")  is_equal(s, "inf")) 89 return true; 67 90 std::stringstream ss(s); 68 91 int a; … … 78 101 bool is_nan(const std::string& s) 79 102 { 80 std::stringstream ss(s); 81 std::string s2; 82 ss >> s2; // to trim surrounding whitespaces 83 to_lower(s2); 84 // Check that nothing is left on stream 85 std::string s3; 86 ss >> s3; 87 if(s3.size()) 88 return false; 89 std::string nan("nan"); 90 return (nan==s2); 103 return is_equal(s, "nan"); 91 104 } 92 105
Note: See TracChangeset
for help on using the changeset viewer.