From 4cc7314baa37e4baa4fd3a648fb1b13ef9c55ed2 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 1 Jun 2016 10:50:06 +0200 Subject: [PATCH] document the strbuf --- doc/doxygen/module-xbt.doc | 1 + include/xbt/strbuff.h | 14 +++++++++++++- src/xbt/xbt_strbuff.c | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/doxygen/module-xbt.doc b/doc/doxygen/module-xbt.doc index 14273f6fb9..0673707668 100644 --- a/doc/doxygen/module-xbt.doc +++ b/doc/doxygen/module-xbt.doc @@ -21,6 +21,7 @@ - \ref XBT_swag - \ref XBT_heap - \ref XBT_peer + - @ref xbt_strbuff - \ref XBT_misc - \ref XBT_graph diff --git a/include/xbt/strbuff.h b/include/xbt/strbuff.h index ace5e34c85..2949420011 100644 --- a/include/xbt/strbuff.h +++ b/include/xbt/strbuff.h @@ -17,7 +17,18 @@ SG_BEGIN_DECL() -/** Buffer code **/ +/** @defgroup xbt_strbuff String buffers + * @ingroup XBT_adt + * + * 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. + * + * @{ + */ + +/** @brief Buffer data container **/ struct xbt_strbuff { char *data; int used, size; @@ -35,5 +46,6 @@ XBT_PUBLIC(void) xbt_strbuff_chomp(xbt_strbuff_t b); XBT_PUBLIC(void) xbt_strbuff_trim(xbt_strbuff_t b); XBT_PUBLIC(void) xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns); +/** @} */ SG_END_DECL() #endif diff --git a/src/xbt/xbt_strbuff.c b/src/xbt/xbt_strbuff.c index b73f511f62..0780895eb0 100644 --- a/src/xbt/xbt_strbuff.c +++ b/src/xbt/xbt_strbuff.c @@ -12,12 +12,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(strbuff, xbt, "String buffers"); +/** @brief Remove any content from the buffer */ inline void xbt_strbuff_empty(xbt_strbuff_t b) { b->used = 0; b->data[0] = '\0'; } +/** @brief Constructor */ xbt_strbuff_t xbt_strbuff_new(void) { xbt_strbuff_t res = xbt_malloc(sizeof(s_xbt_strbuff_t)); @@ -54,6 +56,7 @@ inline void xbt_strbuff_free(xbt_strbuff_t b) } } +/** @brief Adds some content at the end of the buffer */ void xbt_strbuff_append(xbt_strbuff_t b, const char *toadd) { int addlen; -- 2.20.1