From d7c67febe1e773d52f7b792416cf39988ce0e1f5 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Tue, 10 Jul 2018 10:55:10 +0900 Subject: [PATCH] eina: Improve documentation for binbuf/strbuf/ustrbuf Summary: These three classes have essentially the same API, just different underlying data types. This patch seeks to improve the docs for all three while retaining or improving the consistency between them. Several functions had completely incorrect documentation (looks like cut-and-paste mistakes), others had missing or incorrectly named parameter documentation, typographical errors, or other similar issues. This also cleans up a lot of spelling and grammar errors, defines return values as part of @return, and reformats/revises doxygen code for consistency. There are no changes to code, except some whitespace cleanup. Reviewers: devilhorns Subscribers: cedric, #committers, zmike Tags: #efl Differential Revision: https://phab.enlightenment.org/D6544 --- src/lib/eina/eina_binbuf.h | 202 +++++++-------- src/lib/eina/eina_strbuf.h | 500 +++++++++++++++++------------------- src/lib/eina/eina_ustrbuf.h | 247 ++++++++---------- 3 files changed, 448 insertions(+), 501 deletions(-) diff --git a/src/lib/eina/eina_binbuf.h b/src/lib/eina/eina_binbuf.h index 27da52351a..f9e688d5e0 100644 --- a/src/lib/eina/eina_binbuf.h +++ b/src/lib/eina/eina_binbuf.h @@ -13,7 +13,8 @@ * @brief These functions provide string buffer management. * * The Binary Buffer data type is designed to be a mutable string, - * allowing to append, prepend or insert a string to a buffer. + * allowing the appending, prepending or insertion of a string to a + * buffer. */ /** @@ -30,12 +31,12 @@ /** * @typedef Eina_Binbuf - * Type for a string buffer. + * Type for a binary string buffer. */ typedef struct _Eina_Strbuf Eina_Binbuf; /** - * @brief Creates a new string buffer. + * @brief Creates a new binary string buffer. * * @return Newly allocated string buffer instance, or @c NULL on error. * @@ -49,37 +50,22 @@ typedef struct _Eina_Strbuf Eina_Binbuf; EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; /** - * @brief Creates a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_binbuf_string_steal . The passed string must be malloced. + * @brief Creates a new string buffer using the passed string. * * @param str The string to manage. * @param length The length of the string. + * @param ro The passed string will not be touched if set to #EINA_TRUE. * @return Newly allocated string buffer instance, or @c NULL on error. * - * This function creates a new string buffer. To free the resources, use + * This function creates a new binary string buffer. The passed string + * is used directly as the buffer, it's effectively the inverse of + * eina_binbuf_string_steal(). To free the resources, use * eina_binbuf_free(). * - * @see eina_binbuf_manage_new() - * @since 1.2.0 - */ -EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_DEPRECATED; - -/** - * @brief Creates a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_binbuf_string_steal . - * - * @param str The string to start from. - * @param length The length of the string. - * @param ro The passed string will not be touched if set to EINA_TRUE. - * @return Newly allocated string buffer instance, or @c NULL on error. - * - * This function creates a new string buffer. To free the resources, use - * eina_binbuf_free(). It will not touch the buffer if ro is set to @c - * EINA_TRUE, but it will also not copy it. If ro is set to @c EINA_TRUE - * any change operation will create a fresh new memory, copy old data - * there and starting modifying that one. + * This routine will not touch the buffer if @p ro is set to + * #EINA_TRUE, but it will also not copy it. If @p ro is set to + * #EINA_TRUE any change operation will create a fresh new memory + * buffer, copy the old data there and modify that one instead. * * @see eina_binbuf_manage_new() * @see eina_binbuf_manage_new_length() @@ -90,20 +76,37 @@ EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t lengt EAPI Eina_Binbuf *eina_binbuf_manage_new(const unsigned char *str, size_t length, Eina_Bool ro) EINA_MALLOC EINA_WARN_UNUSED_RESULT; /** - * @brief Creates a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_binbuf_string_steal . The passed string will not be touched. + * @brief Creates a new string buffer using the passed string. + * + * @param str The string to manage. + * @param length The length of the string. + * @return Newly allocated string buffer instance, or @c NULL on error. + * + * This function creates a new string buffer. To free the resources, use + * eina_binbuf_free(). + * + * @see eina_binbuf_manage_new() + * + * @since 1.2.0 + */ +EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_DEPRECATED; + +/** + * @brief Creates a new string buffer using the passed string. * * @param str The string to start from. * @param length The length of the string. * @return Newly allocated string buffer instance, or @c NULL on error. * - * This function creates a new string buffer. To free the resources, use - * eina_binbuf_free(). It will not touch the internal buffer. Any - * changing operation will create a fresh new memory, copy old data - * there and starting modifying that one. + * This function creates a new string buffer. The passed string is used + * directly as the buffer, it's effectively the inverse of + * eina_binbuf_string_steal(). The passed string will not be touched. + * It will not touch the internal buffer. Any changing operation will + * create a fresh new memory, copy old data there and starting modifying + * that one. To free the resources, use eina_binbuf_free(). * * @see eina_binbuf_manage_new() + * * @since 1.9.0 */ EAPI Eina_Binbuf *eina_binbuf_manage_read_only_new_length(const unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_DEPRECATED; @@ -121,7 +124,7 @@ EAPI void eina_binbuf_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); /** * @brief Resets a string buffer. * - * @param buf The string buffer to reset. + * @param buf The string buffer. * * This function resets @p buf: the buffer len is set to 0, and the * string is set to '\\0'. No memory is freed. @@ -129,28 +132,27 @@ EAPI void eina_binbuf_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); EAPI void eina_binbuf_reset(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); /** - * @brief Expands a buffer, making room for at least @a minimum_unused_space. - * - * One of the properties of the buffer is that it may overallocate - * space, thus it may have more than eina_binbuf_length_get() bytes - * allocated. How much depends on buffer growing logic, but this - * function allows one to request a minimum amount of bytes to be - * allocated at the end of the buffer. - * - * This is particularly useful to write directly to buffer's memory - * (ie: a call to read(2)). After the bytes are used call - * eina_binbuf_use() to mark them as such, so eina_binbuf_length_get() - * will consider the new bytes. + * @brief Expands a buffer, making room for at least @p minimum_unused_space. * * @param buf The Buffer to expand. * @param minimum_unused_space The minimum unused allocated space, in * bytes, at the end of the buffer. Zero can be used to query * the available slice of unused bytes. - * * @return The slice of unused bytes. The slice length may be zero if - * @a minimum_unused_space couldn't be allocated, otherwise it - * will be at least @a minimum_unused_space. After bytes are used, - * mark them as such using eina_binbuf_use(). + * @p minimum_unused_space couldn't be allocated, otherwise it will + * be at least @p minimum_unused_space. After bytes are used, mark + * them as such using eina_binbuf_use(). + * + * One of the properties of the buffer is that it may overallocate + * space, thus it may have more than eina_binbuf_length_get() bytes + * allocated. How much depends on the buffer growth logic, but this + * function allows requesting a minimum amount of bytes to be allocated + * at the end of the buffer. + * + * This is particularly useful to write directly to buffer's memory + * (i.e.: a call to read(2)). After the bytes are used call + * eina_binbuf_use() to mark them as such, so eina_binbuf_length_get() + * will account for the new bytes. * * @see eina_binbuf_rw_slice_get() * @see eina_binbuf_use() @@ -162,17 +164,16 @@ EAPI Eina_Rw_Slice eina_binbuf_expand(Eina_Binbuf *buf, size_t minimum_unused_sp /** * @brief Marks more bytes as used. * - * This function should be used after eina_binbuf_expand(), marking - * the extra bytes returned there as used, then they will be - * considered in all other functions, such as eina_binbuf_length_get(). - * * @param buf The buffer to mark extra bytes as used. * @param extra_bytes the number of bytes to be considered used, must * be between zero and the length of the slice returned by * eina_binbuf_expand(). + * @return #EINA_TRUE on success, #EINA_FALSE on failure, such as + * @p extra_bytes is too big or @a buf is NULL. * - * @return #EINA_TRUE on success, #EINA_FALSE on failure, such as @a - * extra_bytes is too big or @a buf is NULL. + * This function should be used after eina_binbuf_expand(), marking + * the extra bytes returned there as used, then they will be + * taken into account by other functions, such as eina_binbuf_length_get(). * * @see eina_binbuf_expand() * @@ -181,13 +182,13 @@ EAPI Eina_Rw_Slice eina_binbuf_expand(Eina_Binbuf *buf, size_t minimum_unused_sp EAPI Eina_Bool eina_binbuf_use(Eina_Binbuf *buf, size_t extra_bytes) EINA_ARG_NONNULL(1); /** - * @brief Appends a string of exact length to a buffer, reallocating as necessary. + * @brief Appends a string of exact length to a buffer, reallocating as + * necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param str The string to append. * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure such as if @p - * buf can't be appended. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be appended. * * This function appends @p str to @p buf. @p str must be of size at * most @p length. It is slightly faster than eina_binbuf_append() as @@ -203,10 +204,9 @@ EAPI Eina_Bool eina_binbuf_append_length(Eina_Binbuf *buf, const unsigned char * /** * @brief Appends a slice to a buffer, reallocating as necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param slice The slice to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure such as if - * @p buf can't be appended. + * @return #EINA_TRUE on success, #EINA_FALSE if @p slice could not be appended. * * This function appends @p slice to @p buf. * @@ -217,18 +217,18 @@ EAPI Eina_Bool eina_binbuf_append_slice(Eina_Binbuf *buf, const Eina_Slice slice /** * @brief Appends an Eina_Binbuf to a buffer, reallocating as necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param data The string buffer to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure such as if @p - * buf can't be appended. + * @return #EINA_TRUE on success, #EINA_FALSE if @p data could not be appended. * * This function appends @p data to @p buf. @p data must be allocated and * different from @c NULL. It is slightly faster than eina_binbuf_append() as - * it does not compute the size of @p str. + * it does not compute the size of @p data. * * @see eina_binbuf_append() * @see eina_binbuf_append_n() * @see eina_binbuf_append_length() + * * @since 1.9.0 */ EAPI Eina_Bool eina_binbuf_append_buffer(Eina_Binbuf *buf, const Eina_Binbuf *data) EINA_ARG_NONNULL(1, 2); @@ -237,25 +237,25 @@ EAPI Eina_Bool eina_binbuf_append_buffer(Eina_Binbuf *buf, const Eina_Binbuf *da * @brief Appends a character to a string buffer, reallocating as * necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param c The char to append. - * @return #EINA_TRUE on success, #EINA_FALSE if @pc could not be inserted. + * @return #EINA_TRUE on success, #EINA_FALSE if @p c could not be inserted. * - * This function inserts @p c to @p buf. + * This function appends @p c to @p buf. */ EAPI Eina_Bool eina_binbuf_append_char(Eina_Binbuf *buf, unsigned char c) EINA_ARG_NONNULL(1); /** - * @brief Inserts a string of exact length to a buffer, reallocating as necessary. + * @brief Inserts a string of exact length into a buffer, reallocating as necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param str The string to insert. * @param length The exact length to use. * @param pos The position to insert the string. * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be inserted. * - * This function inserts @p str to @p buf. @p str must be of size at - * most @p length. It is slightly faster than eina_binbuf_insert() as + * This function inserts @p str into @p buf. @p str must be no longer + * than @p length. It is slightly faster than eina_binbuf_insert() as * it does not compute the size of @p str. It is useful when dealing * with strings of known size, such as eina_stringshare. * @@ -266,24 +266,24 @@ EAPI Eina_Bool eina_binbuf_append_char(Eina_Binbuf *buf, unsigned char c) EINA_A EAPI Eina_Bool eina_binbuf_insert_length(Eina_Binbuf *buf, const unsigned char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2); /** - * @brief Inserts a slice to a buffer, reallocating as necessary. + * @brief Inserts a slice into a buffer, reallocating as necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param slice The slice to insert. * @param pos The position to insert the string. * @return #EINA_TRUE on success, #EINA_FALSE if @p slice could not be inserted. * - * This function inserts @p slice to @p buf at position @p pos. + * This function inserts @p slice into @p buf at position @p pos. * * @since 1.19.0 */ EAPI Eina_Bool eina_binbuf_insert_slice(Eina_Binbuf *buf, const Eina_Slice slice, size_t pos) EINA_ARG_NONNULL(1); /** - * @brief Inserts a character to a string buffer, reallocating as + * @brief Inserts a character into a string buffer, reallocating as * necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param c The char to insert. * @param pos The position to insert the char. * @return #EINA_TRUE on success, #EINA_FALSE if @p c could not be inserted. @@ -295,7 +295,7 @@ EAPI Eina_Bool eina_binbuf_insert_char(Eina_Binbuf *buf, unsigned char c, size_t /** * @brief Removes a slice of the given string buffer. * - * @param buf The string buffer to remove a slice. + * @param buf The string buffer. * @param start The initial (inclusive) slice position to start * removing, in bytes. * @param end The final (non-inclusive) slice position to finish @@ -306,7 +306,6 @@ EAPI Eina_Bool eina_binbuf_insert_char(Eina_Binbuf *buf, unsigned char c, size_t * (inclusive) and ending at @p end (non-inclusive). Both values are * in bytes. */ - EAPI Eina_Bool eina_binbuf_remove(Eina_Binbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1); /** @@ -317,8 +316,8 @@ EAPI Eina_Bool eina_binbuf_remove(Eina_Binbuf *buf, size_t start, size_t end) EI * * This function returns the string contained in @p buf. The returned * value must not be modified and will no longer be valid if @p buf is - * modified. In other words, any eina_binbuf_append() or similar will - * make the pointer invalid. + * modified. In other words, calling eina_binbuf_append() or similar + * functions will make the pointer invalid. * * @see eina_binbuf_string_steal() */ @@ -342,7 +341,7 @@ EAPI unsigned char *eina_binbuf_string_steal(Eina_Binbuf *buf) EINA_MALLOC EINA_ /** * @brief Frees the contents of a string buffer but not the buffer. * - * @param buf The string buffer to free the string of. + * @param buf The string buffer. * * This function frees the string contained in @p buf without freeing * @p buf. @@ -350,33 +349,33 @@ EAPI unsigned char *eina_binbuf_string_steal(Eina_Binbuf *buf) EINA_MALLOC EINA_ EAPI void eina_binbuf_string_free(Eina_Binbuf *buf) EINA_ARG_NONNULL(1); /** - * @brief Retrieves the length of the string buffer content. + * @brief Retrieves the length of the string buffer's content. * * @param buf The string buffer. * @return The current length of the string, in bytes. * * This function returns the length of @p buf. */ -EAPI size_t eina_binbuf_length_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; +EAPI size_t eina_binbuf_length_get(const Eina_Binbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; /** - * @brief Gets a read-only slice representing the current binbuf contents. + * @brief Gets a read-only slice of the buffer contents. * - * @param buf the src buffer. - * @return a read-only slice for the current contents. It may become - * invalid as soon as the @a buf is changed. + * @param buf The string buffer. + * @return A read-only slice of the current contents. It may become + * invalid as soon as @p buf is changed. * * @since 1.19 */ EAPI Eina_Slice eina_binbuf_slice_get(const Eina_Binbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); /** - * @brief Gets a read-write slice representing the current binbuf contents. + * @brief Gets a read-write slice of the buffer contents. * - * @param buf the src buffer. - * @return a read-write slice for the current contents. It may become - * invalid as soon as the @a buf is changed with calls such as - * eina_binbuf_append(), eina_binbuf_remove() + * @param buf The string buffer. + * @return A read-write slice for the current contents. It may become + * invalid as soon as @p buf is changed, such as through calls like + * eina_binbuf_append() or eina_binbuf_remove(). * * @see eina_binbuf_expand() * @@ -385,14 +384,11 @@ EAPI Eina_Slice eina_binbuf_slice_get(const Eina_Binbuf *buf) EINA_WARN_UNUSED_R EAPI Eina_Rw_Slice eina_binbuf_rw_slice_get(const Eina_Binbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); /** - * @brief Gets the content of the buffer and frees the buffer. + * @brief Frees the buffer, returning its old contents. * - * @param buf the buffer to get the content from and which will be freed - * - * @return The content contained by buf. - * - * The caller must release the memory of the returned content by calling - * free(). + * @param buf The string buffer. + * @return The content contained by buf. The caller must release the + * memory of the returned string by calling free(). * * @since 1.19 */ diff --git a/src/lib/eina/eina_strbuf.h b/src/lib/eina/eina_strbuf.h index a0b77af8fe..27552318c2 100644 --- a/src/lib/eina/eina_strbuf.h +++ b/src/lib/eina/eina_strbuf.h @@ -36,13 +36,15 @@ * * @example eina_strbuf_01.c */ + /** * @addtogroup Eina_String_Buffer_Group String Buffer * - * @brief These functions provide string buffers management. + * @brief These functions provide string buffer management. * * The String Buffer data type is designed to be a mutable string, - * allowing to append, prepend or insert a string to a buffer. + * allowing the appending, prepending or insertion of a string to a + * buffer. * * For more information see @ref tutorial_strbuf "this example". */ @@ -68,10 +70,10 @@ typedef struct _Eina_Strbuf Eina_Strbuf; /** * @brief Creates a new string buffer. * - * @return Newly allocated string buffer instance. + * @return Newly allocated string buffer instance, or @c NULL on error. * - * This function creates a new string buffer. On error, @c NULL is - * returned. To free the resources, use eina_strbuf_free(). + * This function creates a new string buffer. To free the resources, use + * eina_strbuf_free(). * * @see eina_strbuf_free() * @see eina_strbuf_append() @@ -80,56 +82,59 @@ typedef struct _Eina_Strbuf Eina_Strbuf; EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; /** - * @brief Creates a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_strbuf_string_steal . The passed string must be malloc'd. + * @brief Creates a new string buffer using the passed string. * - * @param str The string to manage - * @return Newly allocated string buffer instance. + * @param str The string to manage. + * @return Newly allocated string buffer instance, or @c NULL on error. * - * This function creates a new string buffer. On error, @c NULL is - * returned. To free the resources, use eina_strbuf_free(). + * This function creates a new string buffer. The passed string is used + * directly as the buffer, it's effectively the inverse of + * eina_strbuf_string_steal(). The passed string must be malloc'd. + * To free the resources, use eina_strbuf_free(). * * @see eina_strbuf_free() * @see eina_strbuf_append() * @see eina_strbuf_string_get() + * * @since 1.1.0 */ EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; /** - * @brief Creates a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_strbuf_string_steal . The passed string must be malloc'd. + * @brief Creates a new string buffer using the passed string. * - * @param str The string to manage + * @param str The string to manage. * @param length The length of the string. - * @return Newly allocated string buffer instance. + * @return Newly allocated string buffer instance, or @c NULL on error. * - * This function creates a new string buffer. On error, @c NULL is - * returned. To free the resources, use eina_strbuf_free(). + * This function creates a new string buffer. The passed string is used + * directly as the buffer, it's effectively the inverse of + * eina_strbuf_string_steal(). The passed string must be malloc'd. To + * free the resources, use eina_strbuf_free(). * * @see eina_strbuf_manage_new() + * * @since 1.2.0 */ EAPI Eina_Strbuf *eina_strbuf_manage_new_length(char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT; /** - * @brief Creates a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_strbuf_string_steal . The passed string is expected to be static or - * otherwise on the stack rather than the malloc'd string required by - * @ref eina_strbuf_manage_new_length . + * @brief Creates a new string buffer using the passed string. * - * @param str The string to manage + * @param str The string to manage. * @param length The length of the string. - * @return Newly allocated string buffer instance. + * @return Newly allocated string buffer instance, or @c NULL on error. * - * This function creates a new string buffer. On error, @c NULL is - * returned. To free the resources, use eina_strbuf_free(). + * This function creates a new string buffer. The passed string is used + * directly as the buffer, it's effectively the inverse of + * eina_strbuf_string_steal(). The passed string is expected to be static + * or otherwise on the stack rather than the malloc'd string required by + * eina_strbuf_manage_new_length(). To free the resources, use + * eina_strbuf_free(). * * @see eina_strbuf_manage_new() * @see eina_strbuf_manage_new_length() + * * @since 1.9.0 */ EAPI Eina_Strbuf *eina_strbuf_manage_read_only_new_length(const char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT; @@ -147,25 +152,24 @@ EAPI void eina_strbuf_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); /** * @brief Resets a string buffer. * - * @param buf The string buffer to reset. + * @param buf The string buffer. * - * This function reset @p buf: the buffer len is set to 0, and the - * string is set to '\\0'. No memory is free'd. + * This function resets @p buf: the buffer len is set to 0, and the + * string data is set to '\\0'. No memory is freed. */ EAPI void eina_strbuf_reset(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); /** * @brief Appends a string to a buffer, reallocating as necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param str The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE on failure such as if + * @p str could not be appended. * * This function appends @p str to @p buf. It computes the length of * @p str, so is slightly slower than eina_strbuf_append_length(). If - * the length is known beforehand, consider using that variant. If - * @p buf can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * the length is known beforehand, consider using that variant. * * @see eina_strbuf_append() * @see eina_strbuf_append_length() @@ -175,13 +179,11 @@ EAPI Eina_Bool eina_strbuf_append(Eina_Strbuf *buf, const char *str) EINA_ARG_NO /** * @brief Appends an escaped string to a buffer, reallocating as necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param str The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be appended. * - * This function escapes and then appends the string @p str to @p buf. If @p str - * can not be appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is - * returned. + * This function escapes and then appends the string @p str to @p buf. */ EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1, 2); @@ -189,19 +191,17 @@ EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EIN * @brief Appends a string to a buffer, reallocating as necessary, * limited by the given length. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param str The string to append. * @param maxlen The maximum number of characters to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be appended. * * This function appends at most @p maxlen characters of @p str to * @p buf. It can't append more than the length of @p str. It * computes the length of @p str, so it is slightly slower than * eina_strbuf_append_length(). If the length is known beforehand, * consider using that variant (@p maxlen should then be checked so - * that it is greater than the size of @p str). If @p str can not be - * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is - * returned. + * that it is greater than the size of @p str). * * @see eina_strbuf_append() * @see eina_strbuf_append_length() @@ -209,19 +209,18 @@ EAPI Eina_Bool eina_strbuf_append_escaped(Eina_Strbuf *buf, const char *str) EIN EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t maxlen) EINA_ARG_NONNULL(1, 2); /** - * @brief Appends a string of exact length to a buffer, reallocating as necessary. + * @brief Appends a string of exact length to a buffer, reallocating as + * necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param str The string to append. * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be appended. * * This function appends @p str to @p buf. @p str must be of size at * most @p length. It is slightly faster than eina_strbuf_append() as * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_stringshare. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * with strings of known size, such as eina_stringshare. * * @see eina_stringshare_length() * @see eina_strbuf_append() @@ -232,12 +231,11 @@ EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size /** * @brief Append a slice to a buffer, reallocating as necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param slice The slice to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p slice could not be appended. * - * This function appends @p slice to @p buf. If @p buf can't append - * it, #EINA_FALSE is returned, otherwise #EINA_TRUE is returned. + * This function appends @p slice to @p buf. * * @since 1.19.0 */ @@ -246,18 +244,18 @@ EAPI Eina_Bool eina_strbuf_append_slice(Eina_Strbuf *buf, const Eina_Slice slice /** * @brief Appends an Eina_Strbuf to a buffer, reallocating as necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param data The string buffer to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p data could not be appended. * * This function appends @p data to @p buf. @p data must be allocated and * different from @c NULL. It is slightly faster than eina_strbuf_append() as - * it does not compute the size of @p str. If @p buf can't append it, - * #EINA_FALSE is returned, otherwise #EINA_TRUE is returned. + * it does not compute the size of @p str. * * @see eina_strbuf_append() * @see eina_strbuf_append_n() * @see eina_strbuf_append_length() + * * @since 1.9.0 */ EAPI Eina_Bool eina_strbuf_append_buffer(Eina_Strbuf *buf, const Eina_Strbuf *data) EINA_ARG_NONNULL(1, 2); @@ -266,35 +264,36 @@ EAPI Eina_Bool eina_strbuf_append_buffer(Eina_Strbuf *buf, const Eina_Strbuf *da * @brief Appends a character to a string buffer, reallocating as * necessary. * - * @param buf The string buffer to append to. - * @param c The char to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @param buf The string buffer. + * @param c The character to append. + * @return #EINA_TRUE on success, #EINA_FALSE if @p c could not be appended. * - * This function inserts @p c to @p buf. If it can not insert it, #EINA_FALSE - * is returned, otherwise #EINA_TRUE is returned. + * This function appends @p c to @p buf. */ EAPI Eina_Bool eina_strbuf_append_char(Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1); /** - * @brief Appends a string to a buffer, reallocating as necessary. + * @brief Appends data elements to a buffer using printf-style formatting. * - * @param buf The string buffer to append to. - * @param fmt The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @param buf The string buffer. + * @param fmt A formatting string. + * @param ... Variable list of data parameters to be appended. + * @return #EINA_TRUE on success, #EINA_FALSE if formatted string could + * not be appended. * - * This function appends the string defined by the format @p fmt to @p buf. @p - * fmt must be of a valid format for printf family of functions. If it can't - * insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is returned. + * This function appends the string defined by the format @p fmt to @p + * buf, reallocating as necessary. @p fmt must be of a valid format for + * the printf family of functions. * * @see eina_strbuf_append() */ EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 3); /** - * @brief Appends a string to a buffer, reallocating as necessary. + * @brief Appends data elements to a string buffer using a va_list. * - * @param buf The string buffer to append to. - * @param fmt The string to append. + * @param buf The string buffer. + * @param fmt A formatting string. * @param args The variable arguments. * @return #EINA_TRUE on success, #EINA_FALSE on failure. * @@ -303,71 +302,66 @@ EAPI Eina_Bool eina_strbuf_append_printf(Eina_Strbuf *buf, const char *fmt, ...) EAPI Eina_Bool eina_strbuf_append_vprintf(Eina_Strbuf *buf, const char *fmt, va_list args) EINA_ARG_NONNULL(1, 2); /** - * @brief Inserts a string to a buffer, reallocating as necessary. + * @brief Inserts a string into a buffer, reallocating as necessary. * - * @param buf The string buffer to insert. + * @param buf The string buffer. * @param str The string to insert. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be inserted. * - * This function inserts @p str to @p buf at position @p pos. It + * This function inserts @p str into @p buf at position @p pos. It * computes the length of @p str, so is slightly slower than - * eina_strbuf_insert_length(). If the length is known beforehand, - * consider using that variant. If @p buf can't insert it, #EINA_FALSE - * is returned, otherwise #EINA_TRUE is returned. + * eina_strbuf_insert_length(). If the length is known beforehand, + * consider using that variant. */ EAPI Eina_Bool eina_strbuf_insert(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2); /** - * @brief Inserts an escaped string to a buffer, reallocating as + * @brief Inserts an escaped string into a buffer, reallocating as * necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param str The string to insert. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be inserted. * - * This function escapes and inserts the string @p str to @p buf at - * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is - * returned, otherwise #EINA_TRUE is returned. + * This function escapes and inserts the string @p str into @p buf at + * position @p pos. */ EAPI Eina_Bool eina_strbuf_insert_escaped(Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1, 2); /** - * @brief Inserts a string to a buffer, reallocating as necessary. Limited by maxlen. + * @brief Inserts a string of a maximum length into a buffer, reallocating as necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param str The string to insert. * @param maxlen The maximum number of chars to insert. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be inserted. * - * This function inserts @p str to @p buf at position @p pos, with at - * most @p maxlen bytes. The number of inserted characters can not be + * This function inserts @p str into @p buf at position @p pos, with at + * most @p maxlen bytes. The number of inserted characters cannot be * greater than the length of @p str. It computes the length of * @p str, so is slightly slower than eina_strbuf_insert_length(). If the * length is known beforehand, consider using that variant (@p maxlen * should then be checked so that it is greater than the size of - * @p str). If @p str can not be inserted, #EINA_FALSE is returned, - * otherwise, #EINA_TRUE is returned. + * @p str). */ EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2); /** - * @brief Inserts a string of exact length to a buffer, reallocating as necessary. + * @brief Inserts a string of an exact length into a buffer, reallocating as necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param str The string to insert. * @param length The exact length to use. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p string could not be inserted. * - * This function inserts @p str to @p buf. @p str must be of size at - * most @p length. It is slightly faster than eina_strbuf_insert() as + * This function inserts @p str into @p buf. @p str must be no longer + * than @p length. It is slightly faster than eina_strbuf_insert() as * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_strngshare. If @p buf - * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * with strings of known size, such as eina_stringshare. * * @see eina_stringshare_length() * @see eina_strbuf_insert() @@ -376,55 +370,51 @@ EAPI Eina_Bool eina_strbuf_insert_n(Eina_Strbuf *buf, const char *str, size_t ma EAPI Eina_Bool eina_strbuf_insert_length(Eina_Strbuf *buf, const char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1, 2); /** - * @brief Insert a slice to a buffer, reallocating as necessary. + * @brief Insert a slice into a buffer, reallocating as necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param slice The slice to insert. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p slice could not be inserted. * - * This function inserts @p slice to @p buf at position @p pos. If @p - * buf can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE - * is returned. + * This function inserts @p slice into @p buf at position @p pos. * * @since 1.19.0 */ EAPI Eina_Bool eina_strbuf_insert_slice(Eina_Strbuf *buf, const Eina_Slice slice, size_t pos) EINA_ARG_NONNULL(1); /** - * @brief Inserts a character to a string buffer, reallocating as + * @brief Inserts a character into a string buffer, reallocating as * necessary. * - * @param buf The string buffer to insert to. - * @param c The char to insert. - * @param pos The position to insert the char. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @param buf The string buffer. + * @param c The character to insert. + * @param pos The position to insert the character. + * @return #EINA_TRUE on success, #EINA_FALSE if @p c could not be inserted. * - * This function inserts @p c to @p buf at position @p pos. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This function inserts @p c into @p buf at position @p pos. */ EAPI Eina_Bool eina_strbuf_insert_char(Eina_Strbuf *buf, char c, size_t pos) EINA_ARG_NONNULL(1); /** - * @brief Inserts a string to a buffer, reallocating as necessary. + * @brief Inserts data elements into a buffer using printf-style formatting. * - * @param buf The string buffer to insert. + * @param buf The string buffer. * @param fmt The string to insert. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @param ... Variable list of data parameters to be inserted. + * @return #EINA_TRUE on success, #EINA_FALSE if the string could not be inserted. * - * This function inserts a string as described by the format @p fmt to @p buf at + * This function inserts a string as described by the format @p fmt into @p buf at * the position @p pos. @p fmt must be of a valid format for printf family of - * functions. If it can't insert it, #EINA_FALSE is returned, - * otherwise #EINA_TRUE is returned. + * functions. */ EAPI Eina_Bool eina_strbuf_insert_printf(Eina_Strbuf *buf, const char *fmt, size_t pos, ...) EINA_ARG_NONNULL(1, 2) EINA_PRINTF(2, 4); /** - * @brief Inserts a string to a buffer, reallocating as necessary. + * @brief Inserts data elements into a buffer using a va_list. * - * @param buf The string buffer to insert. + * @param buf The string buffer. * @param fmt The string to insert. * @param pos The position to insert the string. * @param args The variable arguments. @@ -436,118 +426,103 @@ EAPI Eina_Bool eina_strbuf_insert_vprintf(Eina_Strbuf *buf, const char *fmt, siz /** * @def eina_strbuf_prepend(buf, str) - * @brief Prepends the given string to the given buffer. + * @brief Prepends a string to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param str The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be prepended. * - * This macro is calling eina_strbuf_insert() at position 0. If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_strbuf_insert() with position 0. */ -#define eina_strbuf_prepend(buf, str) eina_strbuf_insert(buf, str, 0) +#define eina_strbuf_prepend(buf, str) eina_strbuf_insert(buf, str, 0) /** * @def eina_strbuf_prepend_escaped(buf, str) - * @brief Prepends the given escaped string to the given buffer. + * @brief Prepends an escaped string to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param str The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be prepended. * - * This macro is calling eina_strbuf_insert_escaped() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_strbuf_insert_escaped() with position 0. */ -#define eina_strbuf_prepend_escaped(buf, str) eina_strbuf_insert_escaped(buf, str, 0) +#define eina_strbuf_prepend_escaped(buf, str) eina_strbuf_insert_escaped(buf, str, 0) /** * @def eina_strbuf_prepend_n(buf, str) - * @brief Prepends the given escaped string to the given buffer. + * @brief Prepends an escaped string to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param str The string to prepend. * @param maxlen The maximum number of chars to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be prepended. * - * This macro is calling eina_strbuf_insert_n() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_strbuf_insert_n() with position 0. */ -#define eina_strbuf_prepend_n(buf, str, maxlen) eina_strbuf_insert_n(buf, str, maxlen, 0) +#define eina_strbuf_prepend_n(buf, str, maxlen) eina_strbuf_insert_n(buf, str, maxlen, 0) /** * @def eina_strbuf_prepend_length(buf, str) - * @brief Prepends the given escaped string to the given buffer. + * @brief Prepends an escaped string to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param str The string to prepend. * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be prepended. * - * This macro is calling eina_strbuf_insert_length() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_strbuf_insert_length() with position 0. */ #define eina_strbuf_prepend_length(buf, str, length) eina_strbuf_insert_length(buf, str, length, 0) /** * @def eina_strbuf_prepend_char(buf, str) - * @brief Prepends the given character to the given buffer. + * @brief Prepends a character to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param c The character to prepend. * @return #EINA_TRUE on success, #EINA_FALSE on failure. * - * This macro is calling eina_strbuf_insert_char() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE - * is returned. + * This macro simply calls eina_strbuf_insert_char() with position 0. */ -#define eina_strbuf_prepend_char(buf, c) eina_strbuf_insert_char(buf, c, 0) +#define eina_strbuf_prepend_char(buf, c) eina_strbuf_insert_char(buf, c, 0) /** * @def eina_strbuf_prepend_printf(buf, fmt, ...) - * @brief Prepends the given string to the given buffer. + * @brief Prepends data elements to the given buffer using printf-style formatting. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param fmt The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @param ... Variable list of data elements to prepend. + * @return #EINA_TRUE on success, #EINA_FALSE if data could not be prepended. * - * This macro is calling eina_strbuf_insert_printf() at position 0. If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_strbuf_insert_printf() with position 0. */ -#define eina_strbuf_prepend_printf(buf, fmt, ...) eina_strbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__) +#define eina_strbuf_prepend_printf(buf, fmt, ...) eina_strbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__) /** * @def eina_strbuf_prepend_vprintf(buf, fmt, args) * @brief Prepends the given string to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param fmt The string to prepend. * @param args The variable arguments. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if data could not be prepended. * - * This macro is calling eina_strbuf_insert_vprintf() at position 0.If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_strbuf_insert_vprintf() with position 0. */ #define eina_strbuf_prepend_vprintf(buf, fmt, args) eina_strbuf_insert_vprintf(buf, fmt, 0, args) /** - * @brief Removes a slice of the given string buffer. + * @brief Removes a section from the given string buffer. * - * @param buf The string buffer to remove a slice. - * @param start The initial (inclusive) slice position to start - * removing, in bytes. - * @param end The final (non-inclusive) slice position to finish - * removing, in bytes. + * @param buf The string buffer. + * @param start The initial (inclusive) byte position to start removal. + * @param end The final (non-inclusive) byte position to end removal. * @return #EINA_TRUE on success, #EINA_FALSE on failure. * * This function removes a slice of @p buf, starting at @p start * (inclusive) and ending at @p end (non-inclusive). Both values are - * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise. + * in bytes. */ EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1); @@ -560,9 +535,9 @@ EAPI Eina_Bool eina_strbuf_remove(Eina_Strbuf *buf, size_t start, size_t end) EI * * This function returns the string contained in @p buf. The returned * value must not be modified and will no longer be valid if @p buf is - * modified. In other words, any eina_strbuf_append() or similar will - * make that pointer invalid. The pointer returned by this function must - * not be freed. + * modified. In other words, calling eina_strbuf_append() or similar + * functions will make this pointer invalid. The pointer returned by + * this function must not be freed. * * @see eina_strbuf_string_steal() */ @@ -571,8 +546,8 @@ EAPI const char *eina_strbuf_string_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL /** * @brief Steals the contents of a string buffer. * - * @param buf The string buffer to steal. - * @return The current string in the string buffer. + * @param buf The string buffer. + * @return The string that was contained in @p buf. * * This function returns the string contained in @p buf. @p buf is * then initialized and does not own the returned string anymore. The @@ -586,7 +561,7 @@ EAPI char *eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUS /** * @brief Frees the contents of a string buffer but not the buffer. * - * @param buf The string buffer to free the string of. + * @param buf The string buffer. * * This function frees the string contained in @p buf without freeing * @p buf. @@ -594,160 +569,160 @@ EAPI char *eina_strbuf_string_steal(Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUS EAPI void eina_strbuf_string_free(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); /** - * @brief Retrieves the length of the string buffer content. + * @brief Retrieves the length of the string buffer's content. * * @param buf The string buffer. * @return The current length of the string, in bytes. * * This function returns the length of @p buf. */ -EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; - +EAPI size_t eina_strbuf_length_get(const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; /** - * @brief Replaces the n-th string with an other string. + * @brief Replaces a substring in the buffer with another string. * - * @param buf The string buffer to work with. - * @param str The string to replace. - * @param with The replacing string. - * @param n The number of the fitting string. + * @param buf The string buffer. + * @param str The text to match. + * @param with The replacement string. + * @param n The indexed occurrence to be replaced. * @return #EINA_TRUE on success, #EINA_FALSE on failure. * * This function replaces the n-th occurrence of @p str in @p buf with - * @p with. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise. + * @p with. */ EAPI Eina_Bool eina_strbuf_replace(Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1, 2, 3); /** * @def eina_strbuf_replace_first(buf, str, with) - * @brief Prepends the given character to the given buffer. + * @brief Replaces the first occurance of a substring with another string. * - * @param buf The string buffer to work with. - * @param str The string to replace. - * @param with The replaceing string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @param buf The string buffer. + * @param str The text to match. + * @param with The replacement string. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be + * replaced in @p buf. * - * This macro is calling eina_strbuf_replace() with the n-th occurrence - * equal to @c 1. If @p buf can't replace it, #EINA_FALSE is returned, - * otherwise #EINA_TRUE is returned. + * This macro simply calls eina_strbuf_replace() with @p n + * equal to @c 1. */ #define eina_strbuf_replace_first(buf, str, with) eina_strbuf_replace(buf, str, with, 1) - /** - * @brief Replaces all strings with another string. - - * @param buf The string buffer to work with. - * @param str The string to replace. + * @brief Replaces all matching substrings with another string. + * + * @param buf The string buffer. + * @param str The text to match. * @param with The replacement string. - * @return How often the string was replaced. + * @return Number of replacements made, or @c 0 on failure. * * This function replaces all the occurrences of @p str in @p buf with - * the string @p with. This function returns the number of times @p str - * has been replaced. On failure, it returns @c 0. + * the string @p with. */ EAPI int eina_strbuf_replace_all(Eina_Strbuf *buf, const char *str, const char *with) EINA_ARG_NONNULL(1, 2, 3); /** * @brief Trims the string buffer. - - * @param buf The string buffer to work with. * - * This function skips whitespaces at the beginning and the end of the buffer. + * @param buf The string buffer. + * + * This function removes whitespace at the beginning and end of the + * buffer's string. */ EAPI void eina_strbuf_trim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); /** * @brief Left trims the string buffer. - - * @param buf The string buffer to work with. * - * This function skips whitespaces in the beginning of the buffer. + * @param buf The string buffer. + * + * This function removes whitespace at the beginning of the buffer's + * string. */ EAPI void eina_strbuf_ltrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); /** * @brief Right trims the string buffer. - - * @param buf The string buffer to work with. * - * This function skips whitespaces in the end of the buffer. + * @param buf The string buffer. + * + * This function removes whitespace at the end of the buffer's string. */ EAPI void eina_strbuf_rtrim(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); /** * @brief Converts the string to lower case. * - * @param buf The string buffer to work with. + * @param buf The string buffer. * - * This function converts all the characters in the strbuf to lower case. + * This function converts all the characters in the buffer's string to + * lower case. * * @since 1.17 */ EAPI void eina_strbuf_tolower(Eina_Strbuf *buf) EINA_ARG_NONNULL(1); /** - * @brief Obtains substring from the src. + * @brief Obtains substring from a source string buffer. * - * @param buf The src string. - * @param pos The position in the source string from which the substring - * should be created. The first character is denoted by a - * value of 0 (not 1). - * @param len The length from pos that should be copied to substring. + * @param buf The string buffer. + * @param pos The (0-based) position where the substring starts. + * @param len The length from @p pos that should be copied. + * @return A string buffer containing the substring, or @c NULL if + * invalid parameters were specified. * - * This function creates a Eina_Strbuf which is a substring of buf which - * is passed from pos position with len length. - * If buf is NULL then returns NULL. - * If len is 0, then an empty strbuf is returned. + * This function creates a Eina_Strbuf containing a copy of a substring + * of buf starting at @p pos with @p len length. If len is 0, then an + * empty strbuf will be returned. * * @since 1.17 */ EAPI Eina_Strbuf * eina_strbuf_substr_get(Eina_Strbuf *buf, size_t pos, size_t len) EINA_MALLOC EINA_WARN_UNUSED_RESULT; /** - * @brief Gets a read-only slice representing the current strbuf contents. + * @brief Gets a read-only slice of the buffer contents. * - * @param buf The source string. - * @return A read-only slice for the current contents. It may become - * invalid as soon as the @a buf is changed. + * @param buf The string buffer. + * @return A read-only slice of the current contents. It may become + * invalid as soon as @p buf is changed. * * @since 1.19 */ EAPI Eina_Slice eina_strbuf_slice_get(const Eina_Strbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); /** - * @brief Gets a read-write slice representing the current strbuf contents. + * @brief Gets a read-write slice of the buffer contents. * - * @param buf The source string. + * @param buf The string buffer. * @return A read-write slice for the current contents. It may become - * invalid as soon as the @a buf is changed with calls such as - * eina_strbuf_append(), eina_strbuf_remove() + * invalid as soon as the @p buf is changed, such as through calls like + * eina_strbuf_append() or eina_strbuf_remove(). * * @since 1.19.0 */ EAPI Eina_Rw_Slice eina_strbuf_rw_slice_get(const Eina_Strbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); - /** - * @brief Gets the string of the buffer and free the buffer + * @brief Frees the buffer, returning its old contents. * - * @param buf The buffer to get the string from and which will be freed - * - * @return The string contained by buf. The caller must release the memory of the returned string by calling - * free(). + * @param buf The string buffer.* + * @return The string contained by buf. The caller must release the + * memory of the returned string by calling free(). * * @since 1.19 */ EAPI char* eina_strbuf_release(Eina_Strbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); /** - * @brief append the given buffer based on strftime output. + * @brief Appends a strftime-style timestamp to the buffer. * - * @param tm Pointer to a tm structure needed by strftime. - * @param fmt String containing format specifiers needed by strftime. + * @param buf The string buffer. + * @param fmt The formatting string. + * @param tm The time value. * @return #EINA_TRUE on success, #EINA_FALSE on failure. * - * This will add append buffer of exact required size based on strftime output + * This function appends a timestamp to the buffer, formatted using + * strftime. A string of the exact size required by strftime's output + * is added to the end. * * Example usage: * @code @@ -759,21 +734,24 @@ EAPI char* eina_strbuf_release(Eina_Strbuf *buf) EINA_WARN_UNUSED_RESULT EINA_AR * eina_strbuf_append_strftime(buf, "%I:%M%p", info); * //after use * eina_strbuf_free(buf); - * @endcode #EINA_TRUE on success, #EINA_FALSE on failure. + * @endcode * * @since 1.21 */ EAPI Eina_Bool eina_strbuf_append_strftime(Eina_Strbuf *buf, const char *fmt, const struct tm *tm); /** - * @brief insert the given buffer based on strftime output at given position + * @brief Inserts a strftime-style timestamp into the buffer. * - * @param buf The string buffer to prepend to. - * @param fmt String containing format specifiers needed by strftime. - * @param tm Pointer to a tm structure needed by strftime. + * @param buf The string buffer. + * @param fmt The formatting string. + * @param tm The time value. + * @param pos The position in the buffer to insert the timestamp. * @return #EINA_TRUE on success, #EINA_FALSE on failure. * - * This will add append buffer of exact required size based on strftime output + * This function inserts a timestamp into the buffer, formatted using + * strftime. The buffer's length will be increased by the exact amount + * required by strftime's output. * * Example usage: * @code @@ -793,20 +771,18 @@ EAPI Eina_Bool eina_strbuf_insert_strftime(Eina_Strbuf *buf, const char *fmt, co /** * @def eina_strbuf_prepend_strftime(buf, fmt, tm) - * @brief Prepends the given string to the given buffer. + * @brief Prepends a strftime-style timestamp to the buffer. * - * @param buf The string buffer to prepend to. - * @param fmt The string to prepend. - * @param tm The variable arguments. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @param buf The string buffer. + * @param fmt The formatting string. + * @param tm The time value. + * @return #EINA_TRUE on success, #EINA_FALSE if @p tm could not be prepended. * - * This macro is calling eina_strbuf_insert_strftime() at position 0. If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_strbuf_insert_strftime() with position 0. * * @since 1.21 */ -#define eina_strbuf_prepend_strftime(buf, fmt, tm) eina_strbuf_insert_strftime(buf, fmt, tm, 0) +#define eina_strbuf_prepend_strftime(buf, fmt, tm) eina_strbuf_insert_strftime(buf, fmt, tm, 0) /** * @} diff --git a/src/lib/eina/eina_ustrbuf.h b/src/lib/eina/eina_ustrbuf.h index f3ea97d931..5c88af9257 100644 --- a/src/lib/eina/eina_ustrbuf.h +++ b/src/lib/eina/eina_ustrbuf.h @@ -9,10 +9,11 @@ /** * @addtogroup Eina_Unicode_String_Buffer_Group Unicode String Buffer * - * @brief These functions provide unicode string buffers management. + * @brief These functions provide unicode string buffer management. * - * The Unicode String Buffer data type is designed to be a mutable string, - * allowing to append, prepend or insert a string to a buffer. + * The Unicode String Buffer data type is designed to be a mutable + * string, allowing the appending, prepending or insertion of a string + * to a buffer. */ /** @@ -29,17 +30,17 @@ /** * @typedef Eina_UStrbuf - * Type for a string buffer. + * Type for a unicode string buffer. */ typedef struct _Eina_Strbuf Eina_UStrbuf; /** - * @brief Creates a new string buffer. + * @brief Creates a new unicode string buffer. * - * @return Newly allocated string buffer instance. + * @return Newly allocated string buffer instance, or @c NULL on error. * - * This function creates a new string buffer. On error, @c NULL is - * returned. To free the resources, use eina_ustrbuf_free(). + * This function creates a new string buffer. To free the resources, use + * eina_ustrbuf_free(). * * @see eina_ustrbuf_free() * @see eina_ustrbuf_append() @@ -48,36 +49,38 @@ typedef struct _Eina_Strbuf Eina_UStrbuf; EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; /** - * @brief Creates a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_ustrbuf_string_steal . The passed string must be malloc'd. + * @brief Creates a new string buffer using the passed string. * - * @param str The string to manage - * @return Newly allocated string buffer instance + * @param str The string to manage. + * @return Newly allocated string buffer instance, or @c NULL on error. * - * This function creates a new string buffer. On error, @c NULL is - * returned. To free the resources, use eina_strbuf_free(). + * This function creates a new unicode string buffer. The passed string + * is used directly as the buffer, it's effectively the inverse of + * eina_ustrbuf_string_steal(). The passed string must be malloc'd. + * To free the resources, use eina_ustrbuf_free(). * * @see eina_ustrbuf_free() * @see eina_ustrbuf_append() * @see eina_ustrbuf_string_get() + * * @since 1.1.0 */ EAPI Eina_UStrbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; /** - * @brief Creates a new string buffer using the passed string. The passed - * string is used directly as the buffer, it's somehow the opposite function of - * @ref eina_ustrbuf_string_steal . The passed string must be malloc'd. + * @brief Creates a new string buffer using the passed string. * - * @param str The string to manage + * @param str The string to manage. * @param length The length of the string. - * @return Newly allocated string buffer instance. + * @return Newly allocated string buffer instance, or @c NULL on error. * - * This function creates a new string buffer. On error, @c NULL is - * returned. To free the resources, use eina_ustrbuf_free(). + * This function creates a new string buffer. The passed string is used + * directly as the buffer, it's effectively the inverse of + * eina_ustrbuf_string_steal(). The passed string must be malloc'd. To + * free the resources, use eina_ustrbuf_free(). * * @see eina_ustrbuf_manage_new() + * * @since 1.2.0 */ EAPI Eina_UStrbuf *eina_ustrbuf_manage_new_length(Eina_Unicode *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT; @@ -95,25 +98,24 @@ EAPI void eina_ustrbuf_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1); /** * @brief Resets a string buffer. * - * @param buf The string buffer to reset. + * @param buf The string buffer. * - * This function reset @p buf: the buffer len is set to 0, and the - * string is set to '\\0'. No memory is free'd. + * This function resets @p buf: the buffer len is set to 0, and the + * string data is set to '\\0'. No memory is freed. */ EAPI void eina_ustrbuf_reset(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1); /** * @brief Appends a string to a buffer, reallocating as necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param str The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE on failure such as if + * @p str could not be appended. * * This function appends @p str to @p buf. It computes the length of * @p str, so is slightly slower than eina_ustrbuf_append_length(). If - * the length is known beforehand, consider using that variant. If - * @p buf can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * the length is known beforehand, consider using that variant. * * @see eina_ustrbuf_append() * @see eina_ustrbuf_append_length() @@ -123,13 +125,11 @@ EAPI Eina_Bool eina_ustrbuf_append(Eina_UStrbuf *buf, const Eina_Unicode *str) E /** * @brief Appends an escaped string to a buffer, reallocating as necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param str The string to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be appended. * - * This function appends the escaped string @p str to @p buf. If @p - * str can not be appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is - * returned. + * This function appends the escaped string @p str to @p buf. */ EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str) EINA_ARG_NONNULL(1, 2); @@ -140,16 +140,14 @@ EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Unicode * @param buf The string buffer to append to. * @param str The string to append. * @param maxlen The maximum number of characters to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be appended. * * This function appends at most @p maxlen characters of @p str to * @p buf. It can't append more than the length of @p str. It * computes the length of @p str, so is slightly slower than * eina_ustrbuf_append_length(). If the length is known beforehand, * consider using that variant (@p maxlen should then be checked so - * that it is greater than the size of @p str). If @p str can not be - * appended, #EINA_FALSE is returned, otherwise, #EINA_TRUE is - * returned. + * that it is greater than the size of @p str). * * @see eina_ustrbuf_append() * @see eina_ustrbuf_append_length() @@ -157,19 +155,18 @@ EAPI Eina_Bool eina_ustrbuf_append_escaped(Eina_UStrbuf *buf, const Eina_Unicode EAPI Eina_Bool eina_ustrbuf_append_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen) EINA_ARG_NONNULL(1, 2); /** - * @brief Appends a string of exact length to a buffer, reallocating as necessary. + * @brief Appends a string of exact length to a buffer, reallocating as + * necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param str The string to append. * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be appended. * * This function appends @p str to @p buf. @p str must be of size at * most @p length. It is slightly faster than eina_ustrbuf_append() as * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_strngshare. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * with strings of known size, such as eina_strngshare. * * @see eina_stringshare_length() * @see eina_ustrbuf_append() @@ -180,12 +177,11 @@ EAPI Eina_Bool eina_ustrbuf_append_length(Eina_UStrbuf *buf, const Eina_Unicode /** * @brief Appends a slice to a buffer, reallocating as necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param slice The slice to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p slice could not be appended. * - * This function appends @p slice to @p buf. If @p buf can't append - * it, #EINA_FALSE is returned, otherwise #EINA_TRUE is returned. + * This function appends @p slice to @p buf. * * @since 1.19.0 */ @@ -195,12 +191,11 @@ EAPI Eina_Bool eina_ustrbuf_append_slice(Eina_UStrbuf *buf, const Eina_Slice sli * @brief Appends a character to a string buffer, reallocating as * necessary. * - * @param buf The string buffer to append to. + * @param buf The string buffer. * @param c The char to append. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p c could not be appended. * - * This function inserts @p c to @p buf. If it can not insert it, #EINA_FALSE - * is returned, otherwise #EINA_TRUE is returned. + * This function appends @p c to @p buf. */ EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf *buf, Eina_Unicode c) EINA_ARG_NONNULL(1); @@ -210,13 +205,12 @@ EAPI Eina_Bool eina_ustrbuf_append_char(Eina_UStrbuf *buf, Eina_Unicode c) EINA_ * @param buf The string buffer to insert. * @param str The string to insert. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be inserted. * * This function inserts @p str to @p buf at position @p pos. It * computes the length of @p str, so is slightly slower than * eina_ustrbuf_insert_length(). If the length is known beforehand, - * consider using that variant. If @p buf can't insert it, #EINA_FALSE - * is returned, otherwise #EINA_TRUE is returned. + * consider using that variant. */ EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2); @@ -224,52 +218,48 @@ EAPI Eina_Bool eina_ustrbuf_insert(Eina_UStrbuf *buf, const Eina_Unicode *str, s * @brief Inserts an escaped string to a buffer, reallocating as * necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param str The string to insert. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be inserted. * * This function inserts the escaped string @p str to @p buf at - * position @p pos. If @p buf can't insert @p str, #EINA_FALSE is - * returned, otherwise #EINA_TRUE is returned. + * position @p pos. */ EAPI Eina_Bool eina_ustrbuf_insert_escaped(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) EINA_ARG_NONNULL(1, 2); /** * @brief Inserts a string to a buffer, reallocating as necessary. Limited by maxlen. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param str The string to insert. * @param maxlen The maximum number of chars to insert. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be inserted. * - * This function inserts @p str ot @p buf at position @p pos, with at - * most @p maxlen bytes. The number of inserted characters can not be + * This function inserts @p str into @p buf at position @p pos, with at + * most @p maxlen bytes. The number of inserted characters cannot be * greater than the length of @p str. It computes the length of * @p str, so is slightly slower than eina_ustrbuf_insert_length(). If the * length is known beforehand, consider using that variant (@p maxlen * should then be checked so that it is greater than the size of - * @p str). If @p str can not be inserted, #EINA_FALSE is returned, - * otherwise, #EINA_TRUE is returned. + * @p str). */ EAPI Eina_Bool eina_ustrbuf_insert_n(Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1, 2); /** * @brief Inserts a string of exact length to a buffer, reallocating as necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param str The string to insert. * @param length The exact length to use. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be inserted. * - * This function inserts @p str to @p buf. @p str must be of size at - * most @p length. It is slightly faster than eina_ustrbuf_insert() as + * This function inserts @p str into @p buf. @p str must be no longer + * than @p length. It is slightly faster than eina_ustrbuf_insert() as * it does not compute the size of @p str. It is useful when dealing - * with strings of known size, such as eina_strngshare. If @p buf - * can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * with strings of known size, such as eina_stringshare. * * @see eina_stringshare_length() * @see eina_ustrbuf_insert() @@ -280,14 +270,12 @@ EAPI Eina_Bool eina_ustrbuf_insert_length(Eina_UStrbuf *buf, const Eina_Unicode /** * @brief Inserts a slice to a buffer, reallocating as necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param slice The slice to insert. * @param pos The position to insert the string. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p slice could not be inserted. * - * This function inserts @p slice to @p buf at position @p pos. If @p - * buf can't insert it, #EINA_FALSE is returned, otherwise #EINA_TRUE - * is returned. + * This function inserts @p slice to @p buf at position @p pos. * * @since 1.19.0 */ @@ -297,91 +285,79 @@ EAPI Eina_Bool eina_ustrbuf_insert_slice(Eina_UStrbuf *buf, const Eina_Slice sli * @brief Inserts a character to a string buffer, reallocating as * necessary. * - * @param buf The string buffer to insert to. + * @param buf The string buffer. * @param c The char to insert. * @param pos The position to insert the char. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p c could not be inserted. * - * This function inserts @p c to @p buf at position @p pos. If @p buf - * can't append it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This function inserts @p c to @p buf at position @p pos. */ EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf *buf, Eina_Unicode c, size_t pos) EINA_ARG_NONNULL(1); /** * @def eina_ustrbuf_prepend(buf, str) - * @brief Prepends the given string to the given buffer. + * @brief Prepends a string to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param str The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be prepended. * - * This macro is calling eina_ustrbuf_insert() at position 0. If @p buf - * can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_ustrbuf_insert() with position 0. */ -#define eina_ustrbuf_prepend(buf, str) eina_ustrbuf_insert(buf, str, 0) +#define eina_ustrbuf_prepend(buf, str) eina_ustrbuf_insert(buf, str, 0) /** * @def eina_ustrbuf_prepend_escaped(buf, str) - * @brief Prepends the given escaped string to the given buffer. + * @brief Prepends an escaped string to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param str The string to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be prepended. * - * This macro is calling eina_ustrbuf_insert_escaped() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_ustrbuf_insert_escaped() with position 0. */ -#define eina_ustrbuf_prepend_escaped(buf, str) eina_ustrbuf_insert_escaped(buf, str, 0) +#define eina_ustrbuf_prepend_escaped(buf, str) eina_ustrbuf_insert_escaped(buf, str, 0) /** * @def eina_ustrbuf_prepend_n(buf, str) - * @brief Prepends the given escaped string to the given buffer. + * @brief Prepends an escaped string to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param str The string to prepend. * @param maxlen The maximum number of Eina_Unicode *s to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @str could not be prepended. * - * This macro is calling eina_ustrbuf_insert_n() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_ustrbuf_insert_n() with position 0. */ -#define eina_ustrbuf_prepend_n(buf, str, maxlen) eina_ustrbuf_insert_n(buf, str, maxlen, 0) +#define eina_ustrbuf_prepend_n(buf, str, maxlen) eina_ustrbuf_insert_n(buf, str, maxlen, 0) /** * @def eina_ustrbuf_prepend_length(buf, str) - * @brief Prepends the given escaped string to the given buffer. + * @brief Prepends an escaped string to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param str The string to prepend. * @param length The exact length to use. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p str could not be prepended. * - * This macro is calling eina_ustrbuf_insert_length() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro simply calls eina_ustrbuf_insert_length() with position 0. */ #define eina_ustrbuf_prepend_length(buf, str, length) eina_ustrbuf_insert_length(buf, str, length, 0) /** * @def eina_ustrbuf_prepend_char(buf, c) - * @brief Prepends the given unicode character to the given buffer. + * @brief Prepends a unicode character to the given buffer. * - * @param buf The string buffer to prepend to. + * @param buf The string buffer. * @param c The Eina_Unicode character to prepend. - * @return #EINA_TRUE on success, #EINA_FALSE on failure. + * @return #EINA_TRUE on success, #EINA_FALSE if @p c could not be prepended. * - * This macro is calling eina_ustrbuf_insert_Eina_Unicode *() at position 0. If - * @p buf can't prepend it, #EINA_FALSE is returned, otherwise #EINA_TRUE is - * returned. + * This macro is calling eina_ustrbuf_insert_Eina_Unicode() at position 0. */ #define eina_ustrbuf_prepend_char(buf, c) eina_ustrbuf_insert_char(buf, c, 0) /** - * @brief Removes a slice of the given string buffer. + * @brief Removes a section of the given string buffer. * * @param buf The string buffer to remove a slice. * @param start The initial (inclusive) slice position to start @@ -392,7 +368,7 @@ EAPI Eina_Bool eina_ustrbuf_insert_char(Eina_UStrbuf *buf, Eina_Unicode c, size_ * * This function removes a slice of @p buf, starting at @p start * (inclusive) and ending at @p end (non-inclusive). Both values are - * in bytes. It returns #EINA_FALSE on failure, #EINA_TRUE otherwise. + * in bytes. */ EAPI Eina_Bool eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1); @@ -405,8 +381,8 @@ eina_ustrbuf_remove(Eina_UStrbuf *buf, size_t start, size_t end) EINA_ARG_NONNUL * * This function returns the string contained in @p buf. The returned * value must not be modified and will no longer be valid if @p buf is - * modified. In other words, any eina_ustrbuf_append() or similar will - * make that pointer invalid. + * modified. In other words, calling eina_ustrbuf_append() or similar + * functions will make this pointer invalid. * * @see eina_ustrbuf_string_steal() */ @@ -416,8 +392,8 @@ eina_ustrbuf_string_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_U /** * @brief Steals the contents of a string buffer. * - * @param buf The string buffer to steal. - * @return The current string in the string buffer. + * @param buf The string buffer. + * @return The string that was contained in @p buf. * * This function returns the string contained in @p buf. @p buf is * then initialized and does not own the returned string anymore. The @@ -432,7 +408,7 @@ eina_ustrbuf_string_steal(Eina_UStrbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT /** * @brief Frees the contents of a string buffer but not the buffer. * - * @param buf The string buffer to free the string of. + * @param buf The string buffer. * * This function frees the string contained in @p buf without freeing * @p buf. @@ -441,7 +417,7 @@ EAPI void eina_ustrbuf_string_free(Eina_UStrbuf *buf) EINA_ARG_NONNULL(1); /** - * @brief Retrieves the length of the string buffer content. + * @brief Retrieves the length of the string buffer's content. * * @param buf The string buffer. * @return The current length of the string, in bytes. @@ -452,35 +428,34 @@ EAPI size_t eina_ustrbuf_length_get(const Eina_UStrbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; /** - * @brief Gets a read-only slice representing the current ustrbuf contents. + * @brief Gets a read-only slice of the buffer contents. * - * @param buf The source string. + * @param buf The string buffer. * @return A read-only slice for the current contents. It may become - * invalid as soon as the @a buf is changed. + * invalid as soon as @a buf is changed. * * @since 1.19 */ EAPI Eina_Slice eina_ustrbuf_slice_get(const Eina_UStrbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); /** - * @brief Gets a read-write slice representing the current ustrbuf contents. + * @brief Gets a read-write slice of the buffer contents. * - * @param buf The source string. + * @param buf The string buffer. * @return A read-write slice for the current contents. It may become - * invalid as soon as the @a buf is changed with calls such as - * eina_ustrbuf_append(), eina_ustrbuf_remove() + * invalid as soon as the @p buf is changed, such as through calls like + * eina_ustrbuf_append() or eina_ustrbuf_remove(). * * @since 1.19.0 */ EAPI Eina_Rw_Slice eina_ustrbuf_rw_slice_get(const Eina_UStrbuf *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); /** - * @brief Gets the string of the buffer and free the buffer + * @brief Frees the buffer, returning its old contents. * - * @param buf The buffer to get the string from and which will be freed - * - * @return The string contained by buf. The caller must release the memory of the returned string by calling - * free(). + * @param buf The string buffer. + * @return The string contained by buf. The caller must release the + * memory of the returned string by calling free(). * * @since 1.19 */