SimGrid  3.13
Versatile Simulation of Distributed Systems
xbt_strbuff.c File Reference
#include "xbt/strbuff.h"

Macros

#define minimal_increment   512
 

Functions

 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (strbuff, xbt,"String buffers")
 
void xbt_strbuff_empty (xbt_strbuff_t b)
 
xbt_strbuff_t xbt_strbuff_new (void)
 
xbt_strbuff_t xbt_strbuff_new_from (const char *ctn)
 creates a new string buffer containing the provided string More...
 
void xbt_strbuff_free_container (xbt_strbuff_t b)
 frees only the container without touching to the contained string More...
 
void xbt_strbuff_free (xbt_strbuff_t b)
 frees the buffer and its content More...
 
void xbt_strbuff_append (xbt_strbuff_t b, const char *toadd)
 
void xbt_strbuff_varsubst (xbt_strbuff_t b, xbt_dict_t patterns)
 Replaces a set of variables by their values. More...
 

Macro Definition Documentation

#define minimal_increment   512

Function Documentation

XBT_LOG_NEW_DEFAULT_SUBCATEGORY ( strbuff  ,
xbt  ,
"String buffers"   
)
void xbt_strbuff_empty ( xbt_strbuff_t  b)
inline
xbt_strbuff_t xbt_strbuff_new ( void  )
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

void xbt_strbuff_free_container ( xbt_strbuff_t  b)
inline

frees only the container without touching to the contained string

void xbt_strbuff_free ( xbt_strbuff_t  b)
inline

frees the buffer and its content

void xbt_strbuff_append ( xbt_strbuff_t  b,
const char *  toadd 
)
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).