Thingstream Client Library  BLD4131-v2.13
Functions
Integer/String conversions

Functions to convert between integers and strings. More...

Collaboration diagram for Integer/String conversions:

Functions

char * Thingstream_Util_sprintfUInt (char *buf, uint32_t num)
 
char * Thingstream_Util_sprintfHex (char *buf, uint32_t num)
 
int32_t Thingstream_Util_parseInt (const char *ptr, const char *end, const char **pOut)
 
uint32_t Thingstream_Util_parseUInt (const char *ptr, const char *end, const char **pOut)
 
uint32_t Thingstream_Util_parseHex (const char *ptr, const char *end, const char **pOut)
 

Detailed Description

Functions to convert between integers and strings.

Function Documentation

◆ Thingstream_Util_parseHex()

uint32_t Thingstream_Util_parseHex ( const char *  ptr,
const char *  end,
const char **  pOut 
)

A helper to parse a sequence of ascii digits as a hex number.

Parameters
ptrstart of sequence
endend of sequence, or NULL to parse until non-digit character
pOutif non-NULL, address of first non-digit is written here

◆ Thingstream_Util_parseInt()

int32_t Thingstream_Util_parseInt ( const char *  ptr,
const char *  end,
const char **  pOut 
)

A helper to parse a sequence of ascii digits as a signed decimal number.

Parameters
ptrstart of sequence
endend of sequence, or NULL to parse until non-digit character
pOutif non-NULL, address of first non-digit is written here

◆ Thingstream_Util_parseUInt()

uint32_t Thingstream_Util_parseUInt ( const char *  ptr,
const char *  end,
const char **  pOut 
)

A helper to parse a sequence of ascii digits as an unsigned decimal number.

Parameters
ptrstart of sequence
endend of sequence, or NULL to parse until non-digit character
pOutif non-NULL, address of first non-digit is written here

◆ Thingstream_Util_sprintfHex()

char* Thingstream_Util_sprintfHex ( char *  buf,
uint32_t  num 
)

Convert an integer to an unsigned base-16 string representation. A helper routine to avoid pulling in the large sprintf() library. Note that the result is not 0-terminated.

Parameters
bufbuffer to receive the string - assumed to be big enough to hold largest possible uint32_t value (8 bytes).
numthe number to be converted
Returns
a pointer to just after the last byte of the conversion.

◆ Thingstream_Util_sprintfUInt()

char* Thingstream_Util_sprintfUInt ( char *  buf,
uint32_t  num 
)

Convert an integer to an unsigned base-10 string representation. A helper routine to avoid pulling in the large sprintf() library. Note that the result is not 0-terminated.

Parameters
bufbuffer to receive the string - assumed to be big enough to hold largest possible uint32_t value (10 bytes).
numthe number to be converted
Returns
a pointer to just after the last byte of the conversion.