eina: add eina_binbuf_append_buffer() and eina_strbuf_append_buffer().

This commit is contained in:
Cedric BAIL 2014-01-02 12:16:26 +09:00
parent 00d4f5cf1c
commit 342dd72e37
3 changed files with 45 additions and 0 deletions

View File

@ -105,6 +105,24 @@ EAPI void eina_binbuf_reset(Eina_Binbuf *buf) EINA_ARG_NONNULL(1);
*/
EAPI Eina_Bool eina_binbuf_append_length(Eina_Binbuf *buf, const unsigned char *str, size_t length) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append an Eina_Binbuf to a buffer, reallocating as necessary.
*
* @param buf The string buffer to append to.
* @param data The string buffer to append.
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function appends @p data to @p buf. @p data must be allocated and
* different from @NULL. It is slightly faster than eina_binbuf_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.
*
* @see eina_binbuf_append()
* @see eina_binbuf_append_n()
* @see eina_binbuf_append_length()
*/
EAPI Eina_Bool eina_binbuf_append_buffer(Eina_Binbuf *buf, const Eina_Binbuf *data) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a character to a string buffer, reallocating as
* necessary.

View File

@ -98,6 +98,15 @@ _FUNC_EXPAND(append_length)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *s
return eina_strbuf_common_append_length(_STRBUF_CSIZE, buf, (const void *) str, length);
}
EAPI Eina_Bool
_FUNC_EXPAND(append_buffer)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_STRUCT_NAME *data)
{
EINA_MAGIC_CHECK_STRBUF(buf, EINA_FALSE);
EINA_MAGIC_CHECK_STRBUF(data, EINA_FALSE);
return eina_strbuf_common_append_length(_STRBUF_CSIZE, buf, (_STRBUF_DATA_TYPE *) eina_strbuf_common_string_get(data), eina_strbuf_common_length_get(data));
}
EAPI Eina_Bool
_FUNC_EXPAND(insert_length)(_STRBUF_STRUCT_NAME *buf, const _STRBUF_DATA_TYPE *str, size_t length, size_t pos)
{

View File

@ -208,6 +208,24 @@ EAPI Eina_Bool eina_strbuf_append_n(Eina_Strbuf *buf, const char *str, size_t ma
*/
EAPI Eina_Bool eina_strbuf_append_length(Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append an Eina_Strbuf to a buffer, reallocating as necessary.
*
* @param buf The string buffer to append to.
* @param data The string buffer to append.
* @return #EINA_TRUE on success, #EINA_FALSE on failure.
*
* This function appends @p data to @p buf. @p data must be allocated and
* different from @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.
*
* @see eina_strbuf_append()
* @see eina_strbuf_append_n()
* @see eina_strbuf_append_length()
*/
EAPI Eina_Bool eina_strbuf_append_buffer(Eina_Strbuf *buf, const Eina_Strbuf *data) EINA_ARG_NONNULL(1, 2);
/**
* @brief Append a character to a string buffer, reallocating as
* necessary.