String#

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.

void *
sl_memrchr(void const *buff, char c, size_t buff_len)

Searches for the character in memory, in reverse order.

Function Documentation#

sl_strcpy_s#

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

Copy a string into a buffer.

Parameters
[in]dst

Destination buffer.

[in]dst_size

The size of the destination buffer.

[in]src

Source string.

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.


Definition at line 69 of file platform/common/inc/sl_string.h

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.

Parameters
[in]dst

Destination string.

[in]dst_size

The size of the destination string buffer.

[in]src

Source 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.


Definition at line 86 of file platform/common/inc/sl_string.h

sl_strlen#

size_t sl_strlen (char * str)

Get the string length.

Parameters
[in]str

The string to get the length for.

Returns

  • String lenght.


Definition at line 96 of file platform/common/inc/sl_string.h

sl_strnlen#

size_t sl_strnlen (char * str, size_t max_len)

Get the string length, limited to given length.

Parameters
[in]str

The string to get the length for.

[in]max_len

The input string is searched for at most max_lencharacters.

Returns

  • String lenght.


Definition at line 108 of file platform/common/inc/sl_string.h

sl_str_is_empty#

bool sl_str_is_empty (const char * str)

Check if the string is empty.

Parameters
[in]str

The string to check.

Returns

  • true if string is empty or null, else return false.


Definition at line 118 of file platform/common/inc/sl_string.h

sl_strcasecmp#

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

Compare two strings, ignoring case.

Parameters
[in]a

String to compare.

[in]b

String to compare.

Returns

  • An integer greater than, or less than 0 if the strings are not equal. 0 if the strings are equal.


Definition at line 131 of file platform/common/inc/sl_string.h

sl_memrchr#

void * sl_memrchr (void const * buff, char c, size_t buff_len)

Searches for the character in memory, in reverse order.

Parameters
[in]buff

Address of the memory buffer.

[in]c

Character to look for.

[in]buff_len

Length of the memory buffer.

Returns

  • The address of the character in the buffer if and only if it was found. NULL if no character was found.


Definition at line 147 of file platform/common/inc/sl_string.h