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.
|
|
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.
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] dst
Destination buffer. [in] dst_size
The size of the destination buffer. [in] src
Source 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] dst
Destination string. [in] dst_size
The size of the destination string buffer. [in] src
Source string.
◆ 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.
◆ 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.
◆ 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.
◆ 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.
◆ 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.