Changeset 917
- Timestamp:
- Sep 30, 2007, 3:26:36 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEWS
r907 r917 4 4 5 5 Version 0.4 (released DATE) 6 7 - is_double(), is_int(), and is_float() return true also when string 8 is a nan or int. 9 - add_values function in Averagers replaced by iterator interface 6 10 7 11 A complete list of closed tickets can be found here [[br]] -
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 -
trunk/yat/utility/utility.h
r916 r917 48 48 bool is_double(const std::string&); 49 49 50 /** 51 @return true if string \a s fulfills regular expression \verbatim 52 ^\w* \endverbatim \a other \verbaim \w*$ \endverbatim (case 53 insensitive) 54 */ 55 bool is_equal(std::string s, std::string other); 50 56 51 57 ///
Note: See TracChangeset
for help on using the changeset viewer.