Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

PUInt64 PString::AsUnsigned64 ( unsigned  base = 10 ) const [inherited]

Convert the string to an integer value using the specified number base. All characters up to the first illegal character for the number base are converted. Case is not significant for bases greater than 10.

The number base may only be from 2 to 36 and the function will assert if it is not in this range.

This function uses the standard C library strtouq()# or strtoul()# function.

Returns:
integer value for the string.
Parameters:
baseNumber base to convert the string in.

Definition at line 428 of file ptlib.cxx.

{
  PAssert(base >= 2 && base <= 36, PInvalidParameter);

  PUInt64 total = 0;
  const char * ptr = theArray;

  while (isspace(*ptr))
    ptr++;

  for (;;) {
    unsigned c = *ptr++;
    if (c < '0')
      break;

    if (c <= '9')
      c -= '0';
    else
      c = toupper(c) - 'A' + 10;

    if (c >= base)
      break;

    total = base * total + c;
  }

  return total;
}

Generated by  Doxygen 1.6.0   Back to index