* Checks if string is a float * decimal_point: defaults to '.' */
| 394 | * decimal_point: defaults to '.' |
| 395 | */ |
| 396 | bool Helper::isFloat(const std::string& s, char decimal_point) { |
| 397 | unsigned int count_decimal_points = 0; |
| 398 | std::string::const_iterator it = s.begin(); |
| 399 | if( *it == '-' ) { |
| 400 | ++it; |
| 401 | } |
| 402 | while( it != s.end() && (std::isdigit(*it) || *it == decimal_point) ) { |
| 403 | if( *it == decimal_point ) { |
| 404 | ++count_decimal_points; |
| 405 | } |
| 406 | ++it; |
| 407 | } |
| 408 | return !s.empty() && it == s.end() && (count_decimal_points <= 1 ); |
| 409 | } |
| 410 | |
| 411 | /* |
| 412 | * Checks if string is a number - a little bit buggy ... TODO |