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.
◆ s_xbt_strbuff_t
◆ xbt_strbuff_t
◆ xbt_strbuff_clear()
Remove any content from the buffer.
◆ xbt_strbuff_new()
◆ xbt_strbuff_new_from()
creates a new string buffer containing the provided string
Beware, the ctn is copied, you want to free it afterward, anyhow
◆ xbt_strbuff_free()
frees the buffer and its content
◆ xbt_strbuff_free_container()
frees only the container without touching to the contained string
◆ xbt_strbuff_append()
Adds some content at the end of the buffer.
◆ xbt_strbuff_printf()
format some content and push it at the end of the buffer
◆ xbt_strbuff_chomp()
◆ xbt_strbuff_trim()
◆ xbt_strbuff_varsubst()
Replaces a set of variables by their values.
- Parameters
-
b | buffer to modify |
patterns | variables 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).