Sturk 1.0.2
Publish-subscribe C implementation.
Loading...
Searching...
No Matches
str.h File Reference

String utilities. More...

#include "st/dict.h"
#include "vx/cirq.h"
#include "vx/list.h"
Include dependency graph for str.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 VX_LIST (struct StStrList, char *)
 This is a macro definition of the struct StStrList type.
 
 VX_CIRQ (struct StStrQ, char *)
 This is a macro definition of the struct StStrQ type.
 
 ST_DICT (struct StStrBag, union {int n;void *align;})
 This is a macro definition of the struct StStrBag type.
 
char * st_newstr (const char *str)
 
struct StStrListst_strlist_ins (struct StStrList *list, char *str)
 Insert a string into a list.
 
char * st_strlist_rem (struct StStrList **listp)
 Remove a string from a list.
 
struct StStrQst_strq_ins (struct StStrQ *q, char *str)
 Insert a string into a queue.
 
char * st_strq_rem (struct StStrQ **qp)
 Remove a string from a queue.
 
struct StStrBagst_strbag_ins (struct StStrBag *bag, const char *str)
 Insert a string into a bag.
 
struct StStrBagst_strbag_rem (struct StStrBag *bag, const char *str)
 Remove a string from a bag.
 
int st_strbag_count (const struct StStrBag *bag)
 For a bag entry, get the occurence count of its string.
 
void st_strbag_destroy (struct StStrBag *bag)
 Destroy the whole bag of strings.
 

Detailed Description

String utilities.

Function Documentation

◆ st_newstr()

char * st_newstr ( const char *  str)
See also
strdup()

◆ st_strbag_count()

int st_strbag_count ( const struct StStrBag bag)

For a bag entry, get the occurence count of its string.

Parameters
[in]bagThe bag entry.
Returns
The occurence count.

◆ st_strbag_destroy()

void st_strbag_destroy ( struct StStrBag bag)

Destroy the whole bag of strings.

Parameters
[in,out]bagAny entry from the bag.

◆ st_strbag_ins()

struct StStrBag * st_strbag_ins ( struct StStrBag bag,
const char *  str 
)

Insert a string into a bag.

Parameters
[in,out]bagThe root of the bag.
[in]strThe string.

This will increment the occurence count of the string.

Returns
The new root of the bag.

◆ st_strbag_rem()

struct StStrBag * st_strbag_rem ( struct StStrBag bag,
const char *  str 
)

Remove a string from a bag.

Parameters
[in,out]bagThe root of the bag.
[in]strThe string.

This will decrement the occurence count of the string. Negative counts are supported.

Returns
The new root of the bag.

◆ st_strlist_ins()

struct StStrList * st_strlist_ins ( struct StStrList list,
char *  str 
)

Insert a string into a list.

Parameters
[in,out]listThe head of the list.
[in]strThe string.
Returns
The new head of the list.

◆ st_strlist_rem()

char * st_strlist_rem ( struct StStrList **  listp)

Remove a string from a list.

Parameters
[in,out]listpA double pointer to the head fo the list.
Returns
The removed string.

◆ st_strq_ins()

struct StStrQ * st_strq_ins ( struct StStrQ q,
char *  str 
)

Insert a string into a queue.

Parameters
[in,out]qThe head of the queue.
[in]strThe string.
Returns
The new head of the queue.

◆ st_strq_rem()

char * st_strq_rem ( struct StStrQ **  qp)

Remove a string from a queue.

Parameters
[in,out]qpA double pointer to the head of the queue.
Returns
The removed string.