String

Description

String module provides APIs to handle string-related operations.

Functions

void sl_strcpy_s (char *dst, size_t dst_size, const char *src)
 Copy a string into a buffer.
 
void sl_strcat_s (char *dst, size_t dst_size, const char *src)
 Append the source string to the end of destination string.
 
size_t sl_strlen (char *str)
 Get the string length.
 
size_t sl_strnlen (char *str, size_t max_len)
 Get the string length, limited to given length.
 
bool sl_str_is_empty (const char *str)
 Check if the string is empty.
 
int sl_strcasecmp (char const *a, char const *b)
 Compare two strings, ignoring case.
 

Function Documentation

◆ sl_strcpy_s()

void sl_strcpy_s ( char *  dst,
size_t  dst_size,
const char *  src 
)

Copy a string into a buffer.

Normally, the complete source string including the '\0' termination will be copied to the destination. If the destination buffer doesn't have room to receive the complete source string, the source string will be truncated and the destination buffer will be '\0' terminated within the destination buffer.

Parameters
[in]dstDestination buffer.
[in]dst_sizeThe size of the destination buffer.
[in]srcSource string.

◆ sl_strcat_s()

void sl_strcat_s ( char *  dst,
size_t  dst_size,
const char *  src 
)

Append the source string to the end of destination string.

Normally, the complete source string including the '\0' termination will be appended to the destination, starting at the source strings '\0' termination. If the destination buffer has no room to receive the complete source string, the source string will be truncated and the destination '\0' terminated within the destination buffer.

Parameters
[in]dstDestination string.
[in]dst_sizeThe size of the destination string buffer.
[in]srcSource string.

◆ sl_strlen()

size_t sl_strlen ( char *  str)

Get the string length.

Parameters
[in]strThe string to get the length for.
Returns
String lenght.

◆ sl_strnlen()

size_t sl_strnlen ( char *  str,
size_t  max_len 
)

Get the string length, limited to given length.

Parameters
[in]strThe string to get the length for.
[in]max_lenThe input string is searched for at most max_lencharacters.
Returns
String lenght.

◆ sl_str_is_empty()

bool sl_str_is_empty ( const char *  str)

Check if the string is empty.

Parameters
[in]strThe string to check.
Returns
true if string is empty or null, else return false.

◆ sl_strcasecmp()

int sl_strcasecmp ( char const *  a,
char const * 
)

Compare two strings, ignoring case.

Parameters
[in]aString to compare.
[in]bString to compare.
Returns
An integer greater than, or less than 0 if the strings are not equal. 0 if the strings are equal.