MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / isFloat

Method isFloat

src/helper.cpp:396–409  ·  view source on GitHub ↗

* Checks if string is a float * decimal_point: defaults to '.' */

Source from the content-addressed store, hash-verified

394 * decimal_point: defaults to '.'
395 */
396bool 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

Callers

nothing calls this directly

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected