mirror of
https://github.com/introlab/rtabmap_ros.git
synced 2026-10-04 08:47:45 +08:00
uIsInteger(): Added checkForSign option (default true)
This commit is contained in:
@@ -629,12 +629,12 @@ inline bool uIsDigit(const char c)
|
|||||||
* @param str the string
|
* @param str the string
|
||||||
* @return true if the string is a integer number
|
* @return true if the string is a integer number
|
||||||
*/
|
*/
|
||||||
inline bool uIsInteger(const std::string & str)
|
inline bool uIsInteger(const std::string & str, bool checkForSign = true)
|
||||||
{
|
{
|
||||||
bool isInteger = str.size()!=0;
|
bool isInteger = str.size()!=0;
|
||||||
for(unsigned int i=0; i<str.size() && isInteger; ++i)
|
for(unsigned int i=0; i<str.size() && isInteger; ++i)
|
||||||
{
|
{
|
||||||
isInteger = i==0&&str[i]=='-'||uIsDigit(str[i]);
|
isInteger = (checkForSign && i==0 && str[i]=='-') || uIsDigit(str[i]);
|
||||||
}
|
}
|
||||||
return isInteger;
|
return isInteger;
|
||||||
}
|
}
|
||||||
@@ -653,7 +653,7 @@ inline bool uIsNumber(const std::string & str)
|
|||||||
}
|
}
|
||||||
else if(list.size() == 2)
|
else if(list.size() == 2)
|
||||||
{
|
{
|
||||||
return uIsInteger(list.front()) && uIsInteger(list.back());
|
return uIsInteger(list.front()) && uIsInteger(list.back(), false);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user