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

Go to the source code of this file.

Functions

rcutils_ret_t rcutils_split (const char *str, char delimiter, rcutils_allocator_t allocator, rcutils_string_array_t *string_array)
 Split a given string with the specified delimiter. More...
 
rcutils_ret_t rcutils_split_last (const char *str, char delimiter, rcutils_allocator_t allocator, rcutils_string_array_t *string_array)
 Split a given string on the last occurrence of the specified delimiter. More...
 

Function Documentation

◆ rcutils_split()

rcutils_ret_t rcutils_split ( const char *  str,
char  delimiter,
rcutils_allocator_t  allocator,
rcutils_string_array_t string_array 
)

Split a given string with the specified delimiter.

Parameters
[in]strstring to split
[in]delimiteron where to split
[in]allocatorfor allocating new memory for the output array
[out]string_arraywith the split tokens
Returns
RCUTILS_RET_OK if successful, or
RCUTILS_RET_INVALID_ARGUMENT for invalid arguments, or
RCUTILS_RET_BAD_ALLOC if memory allocation fails, or
RCUTILS_RET_ERROR if an unknown error occurs

◆ rcutils_split_last()

rcutils_ret_t rcutils_split_last ( const char *  str,
char  delimiter,
rcutils_allocator_t  allocator,
rcutils_string_array_t string_array 
)

Split a given string on the last occurrence of the specified delimiter.

Parameters
[in]strstring to split
[in]delimiteron where to split
[in]allocatorfor allocating new memory for the output array
[out]string_arraywith the split tokens
Returns
array with split token, NULL in case of error