chsvlib
chsv helper source code

◆ ucpstoll()

long long Chusov::String::ucpstoll ( const ucp_t *restrict  str,
ucp_t **restrict  str_end,
int  base 
)
noexcept

Converts a number withing a string to the type "long long".

Parameters
strA string with the number to convert.
str_endAn output pointer receiving an address of a first character that does not match any digit according to the value of base.
baseA radix used for conversion. Valid values are from the range 2 to 36 inclusively and 0 for automatic detection of the base. For base greater than 10 digits are expected to be encoded with latin characters. The conversion is case-insensitive.
Returns
The result of the conversion. If the converted number is not representable by the type
long long
, the return value is LLONG_MIN or LLONG_MAX depending on the sign of the number. If the conversion fails, the functions returns 0.

The function skips leading whitespace characters, if any, before the actual conversion takes place.

If the value of base is 0, the function determines the base from the prefix of the number in str. If the prefix is "0x" or "0X", the base is determined to be 16. Otherwise, if the prefix is 0, the base is considered to be 8. Otherwise, it is 10.

If the number falls out of the range of values representable with the type

long long

, the function sets errno to ERANGE and returns LLONG_MIN or LLONG_MAX depending on the sign of the number.

In any case, on output *str_end points to the first character in str which (after skipping all leading whitespace characters) does not correspond to a digit in base.

Remarks
The function repeats the functionality of the standard [strtoll] function but works with ucp_t characters.
See also
Chusov::String::ucpstol ucpstol
Chusov::String::ucpstoul ucpstoul
Chusov::String::ucpstoull ucpstoull
Chusov::String::ucpstof ucpstof
Chusov::String::ucpstod ucpstod
Chusov::String::ucpstold ucpstold.