SimGrid  3.14.159
Versatile Simulation of Distributed Systems

Detailed Description

This data container is very similar to the Java StringBuffer: that's a string to which you can add content with a lesser performance penalty than if you recreate a new string from scratch.

Once done building your string, you must retrieve the content and free its container.

Classes

struct  xbt_strbuff
 Buffer data container. More...
 

Typedefs

typedef struct xbt_strbuff s_xbt_strbuff_t
 
typedef struct xbt_strbuffxbt_strbuff_t
 

Functions

void xbt_strbuff_clear (xbt_strbuff_t b)
 Remove any content from the buffer. More...
 
xbt_strbuff_t xbt_strbuff_new (void)
 Constructor. More...
 
xbt_strbuff_t xbt_strbuff_new_from (const char *s)
 creates a new string buffer containing the provided string More...
 
void xbt_strbuff_free (xbt_strbuff_t b)
 frees the buffer and its content More...
 
void xbt_strbuff_free_container (xbt_strbuff_t b)
 frees only the container without touching to the contained string More...
 
void xbt_strbuff_append (xbt_strbuff_t b, const char *toadd)
 Adds some content at the end of the buffer. More...
 
void xbt_strbuff_printf (xbt_strbuff_t b, const char *fmt,...)
 format some content and push it at the end of the buffer More...
 
void xbt_strbuff_chomp (xbt_strbuff_t b)
 
void xbt_strbuff_trim (xbt_strbuff_t b)
 
void xbt_strbuff_varsubst (xbt_strbuff_t b, xbt_dict_t patterns)
 Replaces a set of variables by their values. More...
 

Typedef Documentation

◆ s_xbt_strbuff_t

typedef struct xbt_strbuff s_xbt_strbuff_t

◆ xbt_strbuff_t

typedef struct xbt_strbuff* xbt_strbuff_t

Function Documentation

◆ xbt_strbuff_clear()

void xbt_strbuff_clear ( xbt_strbuff_t  b)
inline

Remove any content from the buffer.

◆ xbt_strbuff_new()

xbt_strbuff_t xbt_strbuff_new ( void  )

Constructor.

◆ xbt_strbuff_new_from()

xbt_strbuff_t xbt_strbuff_new_from ( const char *  ctn)
inline

creates a new string buffer containing the provided string

Beware, the ctn is copied, you want to free it afterward, anyhow

◆ xbt_strbuff_free()

void xbt_strbuff_free ( xbt_strbuff_t  b)
inline

frees the buffer and its content

◆ xbt_strbuff_free_container()

void xbt_strbuff_free_container ( xbt_strbuff_t  b)
inline

frees only the container without touching to the contained string

◆ xbt_strbuff_append()

void xbt_strbuff_append ( xbt_strbuff_t  b,
const char *  toadd 
)

Adds some content at the end of the buffer.

◆ xbt_strbuff_printf()

void xbt_strbuff_printf ( xbt_strbuff_t  b,
const char *  fmt,
  ... 
)

format some content and push it at the end of the buffer

◆ xbt_strbuff_chomp()

void xbt_strbuff_chomp ( xbt_strbuff_t  b)

◆ xbt_strbuff_trim()

void xbt_strbuff_trim ( xbt_strbuff_t  b)

◆ xbt_strbuff_varsubst()

void xbt_strbuff_varsubst ( xbt_strbuff_t  b,
xbt_dict_t  patterns 
)

Replaces a set of variables by their values.

Parameters
bbuffer to modify
patternsvariables to substitute in the buffer

Both '$toto' and '${toto}' are valid (and the two writing are equivalent).

If the variable name contains spaces, use the brace version (ie, ${toto tutu})

You can provide a default value to use if the variable is not set in the dict by using '${var:=default}' or '${var:-default}'. These two forms are equivalent, even if they shouldn't to respect the shell standard (:= form should set the value in the dict, but does not) (BUG).