tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches

Various narrow character string handling functions. More...

Functions

auto memcmp (void const *lhs, void const *rhs, etl::size_t count) noexcept -> int
 Reinterprets the objects pointed to by lhs and rhs as arrays of unsigned char and compares the first count bytes of these arrays. The comparison is done lexicographically.
 
auto memcpy (void *dest, void const *src, etl::size_t n) -> void *
 Copy the first n bytes pointed to by src to the buffer pointed to by dest. Source and destination may not overlap. If source and destination might overlap, memmove() must be used instead.
 
auto memmove (void *dest, void const *src, etl::size_t count) -> void *
 Copy the first n bytes pointed to by src to the buffer pointed to by dest. Source and destination may overlap.
 
auto memset (void *s, int c, etl::size_t n) -> void *
 Copies the value of c (converted to an unsigned char) into each of the first n characters of the object pointed to by s.
 
constexpr auto strcat (char *dest, char const *src) noexcept -> char *
 Appends a copy of the character string pointed to by src to the end of the character string pointed to by dest. The character src[0] replaces the null terminator at the end of dest. The resulting byte string is null-terminated.
 
constexpr auto strcmp (char const *lhs, char const *rhs) -> int
 Compares the C string lhs to the C string rhs.
 
constexpr auto strcpy (char *dest, char const *src) -> char *
 Copies the character string pointed to by src, including the null terminator, to the character array whose first element is pointed to by dest.
 
constexpr auto strcspn (char const *dest, char const *src) noexcept -> etl::size_t
 Returns the length of the maximum initial segment of the byte string pointed to by dest, that consists of only the characters not found in byte string pointed to by src.
 
constexpr auto strlen (char const *str) -> etl::size_t
 Returns the length of the C string str.
 
constexpr auto strncat (char *dest, char const *src, etl::size_t const count) -> char *
 Appends a byte string pointed to by src to a byte string pointed to by dest. At most count characters are copied. The resulting byte string is null-terminated.
 
constexpr auto strncmp (char const *lhs, char const *rhs, etl::size_t count) -> int
 Compares at most count characters of two possibly null-terminated arrays. The comparison is done lexicographically. Characters following the null character are not compared.
 
constexpr auto strncpy (char *dest, char const *src, etl::size_t const count) -> char *
 Copies at most count characters of the byte string pointed to by src (including the terminating null character) to character array pointed to by dest.
 
constexpr auto strspn (char const *dest, char const *src) noexcept -> etl::size_t
 Returns the length of the maximum initial segment (span) of the byte string pointed to by dest, that consists of only the characters found in byte string pointed to by src.
 
auto memchr (void *ptr, int ch, etl::size_t n) -> void *
 Converts ch to unsigned char and locates the first occurrence of that value in the initial count characters (each interpreted as unsigned char) of the object pointed to by ptr.
 
auto memchr (void const *ptr, int ch, etl::size_t n) -> void const *
 Converts ch to unsigned char and locates the first occurrence of that value in the initial count characters (each interpreted as unsigned char) of the object pointed to by ptr.
 
constexpr auto strchr (char const *str, int ch) -> char const *
 Finds the first occurrence of the character static_cast<char>(ch) in the byte string pointed to by str.
 
constexpr auto strchr (char *str, int ch) -> char *
 Finds the first occurrence of the character static_cast<char>(ch) in the byte string pointed to by str.
 
constexpr auto strpbrk (char const *dest, char const *breakset) noexcept -> char const *
 Scans the null-terminated byte string pointed to by dest for any character from the null-terminated byte string pointed to by breakset, and returns a pointer to that character.
 
constexpr auto strpbrk (char *dest, char *breakset) noexcept -> char *
 Scans the null-terminated byte string pointed to by dest for any character from the null-terminated byte string pointed to by breakset, and returns a pointer to that character.
 
constexpr auto strrchr (char const *str, int ch) noexcept -> char const *
 Finds the last occurrence of the character static_cast<char>(ch) in the byte string pointed to by str.
 
constexpr auto strrchr (char *str, int ch) noexcept -> char *
 Finds the last occurrence of the character static_cast<char>(ch) in the byte string pointed to by str.
 
constexpr auto strstr (char *haystack, char *needle) noexcept -> char *
 Finds the first occurrence of the byte string needle in the byte string pointed to by haystack. The terminating null characters are not compared.
 
constexpr auto strstr (char const *haystack, char const *needle) noexcept -> char const *
 Finds the first occurrence of the byte string needle in the byte string pointed to by haystack. The terminating null characters are not compared.
 

Detailed Description

Various narrow character string handling functions.

Function Documentation

◆ memchr() [1/2]

auto memchr ( void * ptr,
int ch,
etl::size_t n ) -> void*
inlinenodiscard

Converts ch to unsigned char and locates the first occurrence of that value in the initial count characters (each interpreted as unsigned char) of the object pointed to by ptr.

This function behaves as if it reads the characters sequentially and stops as soon as a matching character is found: if the array pointed to by ptr is smaller than count, but the match is found within the array, the behavior is well-defined.

https://en.cppreference.com/w/cpp/string/byte/memchr

Returns
Pointer to the location of the character, or a null pointer if no such character is found.

◆ memchr() [2/2]

auto memchr ( void const * ptr,
int ch,
etl::size_t n ) -> void const*
inlinenodiscard

Converts ch to unsigned char and locates the first occurrence of that value in the initial count characters (each interpreted as unsigned char) of the object pointed to by ptr.

This function behaves as if it reads the characters sequentially and stops as soon as a matching character is found: if the array pointed to by ptr is smaller than count, but the match is found within the array, the behavior is well-defined.

https://en.cppreference.com/w/cpp/string/byte/memchr

Returns
Pointer to the location of the character, or a null pointer if no such character is found.

◆ memcmp()

auto memcmp ( void const * lhs,
void const * rhs,
etl::size_t count ) -> int
inlinenodiscardnoexcept

Reinterprets the objects pointed to by lhs and rhs as arrays of unsigned char and compares the first count bytes of these arrays. The comparison is done lexicographically.

https://en.cppreference.com/w/cpp/string/byte/memcmp

◆ memcpy()

auto memcpy ( void * dest,
void const * src,
etl::size_t n ) -> void*
inline

Copy the first n bytes pointed to by src to the buffer pointed to by dest. Source and destination may not overlap. If source and destination might overlap, memmove() must be used instead.

◆ memmove()

auto memmove ( void * dest,
void const * src,
etl::size_t count ) -> void*
inline

Copy the first n bytes pointed to by src to the buffer pointed to by dest. Source and destination may overlap.

◆ memset()

auto memset ( void * s,
int c,
etl::size_t n ) -> void*
inline

Copies the value of c (converted to an unsigned char) into each of the first n characters of the object pointed to by s.

◆ strcat()

auto strcat ( char * dest,
char const * src ) -> char*
constexprnoexcept

Appends a copy of the character string pointed to by src to the end of the character string pointed to by dest. The character src[0] replaces the null terminator at the end of dest. The resulting byte string is null-terminated.

The behavior is undefined if the destination array is not large enough for the contents of both src and dest and the terminating null character. The behavior is undefined if the strings overlap.

◆ strchr() [1/2]

auto strchr ( char * str,
int ch ) -> char*
nodiscardconstexpr

Finds the first occurrence of the character static_cast<char>(ch) in the byte string pointed to by str.

The terminating null character is considered to be a part of the string and can be found if searching for '\0'.

https://en.cppreference.com/w/cpp/string/byte/strchr

◆ strchr() [2/2]

auto strchr ( char const * str,
int ch ) -> char const*
nodiscardconstexpr

Finds the first occurrence of the character static_cast<char>(ch) in the byte string pointed to by str.

The terminating null character is considered to be a part of the string and can be found if searching for '\0'.

https://en.cppreference.com/w/cpp/string/byte/strchr

◆ strcmp()

auto strcmp ( char const * lhs,
char const * rhs ) -> int
nodiscardconstexpr

Compares the C string lhs to the C string rhs.

This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ or until a terminating null-character is reached.

◆ strcpy()

auto strcpy ( char * dest,
char const * src ) -> char*
constexpr

Copies the character string pointed to by src, including the null terminator, to the character array whose first element is pointed to by dest.

The behavior is undefined if the dest array is not large enough. The behavior is undefined if the strings overlap.

Returns
dest

◆ strcspn()

auto strcspn ( char const * dest,
char const * src ) -> etl::size_t
nodiscardconstexprnoexcept

Returns the length of the maximum initial segment of the byte string pointed to by dest, that consists of only the characters not found in byte string pointed to by src.

The function name stands for "complementary span"

https://en.cppreference.com/w/cpp/string/byte/strcspn

◆ strlen()

auto strlen ( char const * str) -> etl::size_t
nodiscardconstexpr

Returns the length of the C string str.

◆ strncat()

auto strncat ( char * dest,
char const * src,
etl::size_t const count ) -> char*
constexpr

Appends a byte string pointed to by src to a byte string pointed to by dest. At most count characters are copied. The resulting byte string is null-terminated.

The destination byte string must have enough space for the contents of both dest and src plus the terminating null character, except that the size of src is limited to count. The behavior is undefined if the strings overlap.

◆ strncmp()

auto strncmp ( char const * lhs,
char const * rhs,
etl::size_t count ) -> int
nodiscardconstexpr

Compares at most count characters of two possibly null-terminated arrays. The comparison is done lexicographically. Characters following the null character are not compared.

The behavior is undefined when access occurs past the end of either array lhs or rhs. The behavior is undefined when either lhs or rhs is the null pointer.

◆ strncpy()

auto strncpy ( char * dest,
char const * src,
etl::size_t const count ) -> char*
constexpr

Copies at most count characters of the byte string pointed to by src (including the terminating null character) to character array pointed to by dest.

If count is reached before the entire string src was copied, the resulting character array is not null-terminated. If, after copying the terminating null character from src, count is not reached, additional null characters are written to dest until the total of count characters have been written. If the strings overlap, the behavior is undefined.

Returns
dest

◆ strpbrk() [1/2]

auto strpbrk ( char * dest,
char * breakset ) -> char*
nodiscardconstexprnoexcept

Scans the null-terminated byte string pointed to by dest for any character from the null-terminated byte string pointed to by breakset, and returns a pointer to that character.

https://en.cppreference.com/w/cpp/string/byte/strpbrk

◆ strpbrk() [2/2]

auto strpbrk ( char const * dest,
char const * breakset ) -> char const*
nodiscardconstexprnoexcept

Scans the null-terminated byte string pointed to by dest for any character from the null-terminated byte string pointed to by breakset, and returns a pointer to that character.

https://en.cppreference.com/w/cpp/string/byte/strpbrk

◆ strrchr() [1/2]

auto strrchr ( char * str,
int ch ) -> char*
nodiscardconstexprnoexcept

Finds the last occurrence of the character static_cast<char>(ch) in the byte string pointed to by str.

The terminating null character is considered to be a part of the string and can be found if searching for '\0'.

https://en.cppreference.com/w/cpp/string/byte/strrchr

◆ strrchr() [2/2]

auto strrchr ( char const * str,
int ch ) -> char const*
nodiscardconstexprnoexcept

Finds the last occurrence of the character static_cast<char>(ch) in the byte string pointed to by str.

The terminating null character is considered to be a part of the string and can be found if searching for '\0'.

https://en.cppreference.com/w/cpp/string/byte/strrchr

◆ strspn()

auto strspn ( char const * dest,
char const * src ) -> etl::size_t
nodiscardconstexprnoexcept

Returns the length of the maximum initial segment (span) of the byte string pointed to by dest, that consists of only the characters found in byte string pointed to by src.

https://en.cppreference.com/w/cpp/string/byte/strspn

◆ strstr() [1/2]

auto strstr ( char * haystack,
char * needle ) -> char*
nodiscardconstexprnoexcept

Finds the first occurrence of the byte string needle in the byte string pointed to by haystack. The terminating null characters are not compared.

◆ strstr() [2/2]

auto strstr ( char const * haystack,
char const * needle ) -> char const*
nodiscardconstexprnoexcept

Finds the first occurrence of the byte string needle in the byte string pointed to by haystack. The terminating null characters are not compared.