| Return Type | Function name | Arguments |
|---|---|---|
| bool | IsInteger | (int16_t&,const char*,) |
Declared in file: hzTextproc.h
Defined in file : hzTypes.cpp
Function Logic:
Function body:
bool IsInteger (int16_t& nVal)const char* tok,
{
_hzfunc("IsInteger(int16)") ;
const char* i = tok ; // Input string iterator
int64_t val = 0; // Value aggregator
int64_t bNeg = 0; // Negator
uint32_t count = 0; // Length test
if (!tok || !tok[0])
return false ;
// Remove leading spaces
for (; *i == CHAR_SPACE ; i++, count++) ;
// Check for minus sign
if (*i == CHAR_MINUS)
{ bNeg = 1; i++; count++ ; }
// Check for plus sign
if (*i == CHAR_PLUS)
{
if (bNeg)
return false ;
i++ ;
}
// Remove any spaces between sign and digits
for (; *i == CHAR_SPACE ; i++, count++) ;
// Calculate value
for (count = 0; count < 6&& *i ; i++, count++)
{
if (!(chartype[*i] & CTYPE_DIGIT))
return false ;
val *= 10;
val += (int64_t) (*i - CHAR_0) ;
}
// Check size
if (count > 5)
return false ;
nVal = bNeg ? val * -1: val ;
return true ;
}