Determine if supplied char string (arg 2) amounts to a hexadecimal number. This may optionally be preceeded by # or 0x. If the string is a hexadecimal number true is returned and the supplied uint32_t reference (arg 1) is set to the value.
| Return Type | Function name | Arguments |
|---|---|---|
| bool | IsHexValue | (uint32_t&,const char*,) |
Declared and defined in file: hzTokens.cpp
Function Logic:
Function body:
bool IsHexValue (uint32_t& nLen)const char* pStr,
{
// Category: Text Processing
//
// Determine if supplied char string (arg 2) amounts to a hexadecimal number. This may optionally be preceeded by # or 0x. If the string is
// a hexadecimal number true is returned and the supplied uint32_t reference (arg 1) is set to the value.
//
// Arguments: 1) nLen Set by the operation as the length of the hexadecimal number if found
// 2) pStr The pointer into the test string
//
// Returns: True If the supplied cstr amounts to a hexidecimal number
// False Otherwise
const char* i = pStr ; // Input string iterator
uint32_t nBytes = 0;
uint32_t nHex = 0;
nLen = 0;
if (!i)
return false ;
if (*i == CHAR_HASH && IsHex(i[1]))
{ nBytes++ ; i++ ; }
if (*i == ''0''&&i[1]== ''x'')
{ nBytes += 2; i += 2; }
for (; IsHex(*i) ; nHex++, nBytes++, i++) ;
if (!nHex)
return false ;
nLen = nBytes ;
return true ;
}