rcutils  master
C API providing common utilities and data structures.
Functions
find.h File Reference
#include "rcutils/types.h"
#include "rcutils/visibility_control.h"
Include dependency graph for find.h:

Go to the source code of this file.

Functions

size_t rcutils_find (const char *str, char delimiter)
 Return the first index of a character in a string. More...
 
size_t rcutils_findn (const char *str, char delimiter, size_t string_length)
 Return the first index of a character in a string of specified length. More...
 
size_t rcutils_find_last (const char *str, char delimiter)
 Return the last index of a character in a string. More...
 
size_t rcutils_find_lastn (const char *str, char delimiter, size_t string_length)
 Return the last index of a character in a string of specifed length. More...
 

Function Documentation

◆ rcutils_find()

size_t rcutils_find ( const char *  str,
char  delimiter 
)

Return the first index of a character in a string.

Search in a string for the first occurence of a delimiter.

Parameters
[in]strnull terminated c string to search
[in]delimiterthe character to search for
Returns
the index of the first occurence of the delimiter if found, or
SIZE_MAX for invalid arguments or if the delimiter is not found

◆ rcutils_findn()

size_t rcutils_findn ( const char *  str,
char  delimiter,
size_t  string_length 
)

Return the first index of a character in a string of specified length.

Identical to rcutils_find_first() but without relying on the string to be a null terminated c string.

Parameters
[in]strstring to search
[in]delimiterthe character to search for
[in]string_lengthlength of the string to search
Returns
the index of the first occurence of the delimiter if found, or
SIZE_MAX for invalid arguments or if the delimiter is not found

◆ rcutils_find_last()

size_t rcutils_find_last ( const char *  str,
char  delimiter 
)

Return the last index of a character in a string.

Search in a string for the last occurence of a delimiter.

Parameters
[in]strnull terminated c string to search
[in]delimiterthe character to search for
Returns
the index of the last occurence of the delimiter if found, or
SIZE_MAX for invalid arguments or if the delimiter is not found

◆ rcutils_find_lastn()

size_t rcutils_find_lastn ( const char *  str,
char  delimiter,
size_t  string_length 
)

Return the last index of a character in a string of specifed length.

Identical to rcutils_find_last() but without relying on the string to be a null terminated c string.

Parameters
[in]strstring to search
[in]delimiterthe character to search for
[in]string_lengthlength of the string to search
Returns
the index of the last occurence of the delimiter if found, or
SIZE_MAX for invalid arguments or if the delimiter is not found