PipeWire  0.3.15
pw_utils Class Reference

Public Types

typedef void(* pw_destroy_t) (void *object)
 a function to destroy an item More...
 

Public Member Functions

const SPA_EXPORT char * pw_split_walk (const char *str, const char *delimiter, size_t *len, const char **state)
 Split a string based on delimiters. More...
 
SPA_EXPORT char ** pw_split_strv (const char *str, const char *delimiter, int max_tokens, int *n_tokens)
 Split a string based on delimiters. More...
 
SPA_EXPORT void pw_free_strv (char **str)
 Free a NULL terminated array of strings. More...
 
SPA_EXPORT char * pw_strip (char *str, const char *whitespace)
 Strip all whitespace before and after a string. More...
 

Detailed Description

Various utility functions

Member Typedef Documentation

◆ pw_destroy_t

typedef void(* pw_destroy_t(void *object)

a function to destroy an item

Member Function Documentation

◆ pw_free_strv()

SPA_EXPORT void pw_free_strv ( char **  str)

Free a NULL terminated array of strings.

Parameters
stra NULL terminated array of string

Free all the strings in the array and the array

◆ pw_split_strv()

SPA_EXPORT char ** pw_split_strv ( const char *  str,
const char *  delimiter,
int  max_tokens,
int *  n_tokens 
)

Split a string based on delimiters.

Parameters
stra string to split
delimiterdelimiter characters to split on
max_tokensthe max number of tokens to split
[out]n_tokensthe number of tokens
Returns
a NULL terminated array of strings that should be freed with pw_free_strv.

References pw_array::data, pw_array::pw_array_add_ptr, pw_array::pw_array_init(), and pw_split_walk().

Referenced by pw_impl_module::pw_context_load_module().

◆ pw_split_walk()

const SPA_EXPORT char * pw_split_walk ( const char *  str,
const char *  delimiter,
size_t *  len,
const char **  state 
)

Split a string based on delimiters.

Parameters
stra string to split
delimiterdelimiter characters to split on
[out]lenthe length of the current string
[in,out]statea state variable
Returns
a string or NULL when the end is reached

Repeatedly call this function to split str into all substrings delimited by delimiter. state should be set to NULL on the first invocation and passed to the function until NULL is returned.

Referenced by pw_split_strv().

◆ pw_strip()

SPA_EXPORT char * pw_strip ( char *  str,
const char *  whitespace 
)

Strip all whitespace before and after a string.

Parameters
stra string to strip
whitespacecharacters to strip
Returns
the stripped part of str

Strip whitespace before and after str. str will be modified.


The documentation for this class was generated from the following files: