Macros | Typedefs | Functions
String Buffer

These functions provide string buffers management. More...

Macros

#define eina_strbuf_prepend(buf, str)   eina_strbuf_insert(buf, str, 0)
 Prepend the given string to the given buffer. More...
 
#define eina_strbuf_prepend_escaped(buf, str)   eina_strbuf_insert_escaped(buf, str, 0)
 Prepend the given escaped string to the given buffer. More...
 
#define eina_strbuf_prepend_n(buf, str, maxlen)   eina_strbuf_insert_n(buf, str, maxlen, 0)
 Prepend the given escaped string to the given buffer. More...
 
#define eina_strbuf_prepend_length(buf, str, length)   eina_strbuf_insert_length(buf, str, length, 0)
 Prepend the given escaped string to the given buffer. More...
 
#define eina_strbuf_prepend_char(buf, c)   eina_strbuf_insert_char(buf, c, 0)
 Prepend the given character to the given buffer. More...
 
#define eina_strbuf_prepend_printf(buf, fmt, ...)   eina_strbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__)
 Prepend the given string to the given buffer. More...
 
#define eina_strbuf_prepend_vprintf(buf, fmt, args)   eina_strbuf_insert_vprintf(buf, fmt, 0, args)
 Prepend the given string to the given buffer. More...
 
#define eina_strbuf_replace_first(buf, str, with)   eina_strbuf_replace(buf, str, with, 1)
 Prepend the given character to the given buffer. More...
 

Typedefs

typedef struct _Eina_Strbuf Eina_Strbuf
 Type for a string buffer.
 

Functions

EAPI Eina_Strbufeina_strbuf_new (void) EINA_MALLOC EINA_WARN_UNUSED_RESULT
 Create a new string buffer. More...
 
EAPI Eina_Strbufeina_strbuf_manage_new (char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT
 Create a new string buffer using the passed string. More...
 
EAPI Eina_Strbufeina_strbuf_manage_new_length (char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT
 Create a new string buffer using the passed string. More...
 
EAPI Eina_Strbufeina_strbuf_manage_read_only_new_length (const char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT
 Create a new string buffer using the passed string. More...
 
EAPI void eina_strbuf_free (Eina_Strbuf *buf) EINA_ARG_NONNULL(1)
 Free a string buffer. More...
 
EAPI void eina_strbuf_reset (Eina_Strbuf *buf) EINA_ARG_NONNULL(1)
 Reset a string buffer. More...
 
EAPI Eina_Bool eina_strbuf_append (Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1
 Append a string to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_escaped (Eina_Strbuf *buf, const char *str) EINA_ARG_NONNULL(1
 Append an escaped string to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_n (Eina_Strbuf *buf, const char *str, size_t maxlen) EINA_ARG_NONNULL(1
 Append a string to a buffer, reallocating as necessary, limited by the given length. More...
 
EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_length (Eina_Strbuf *buf, const char *str, size_t length) EINA_ARG_NONNULL(1
 Append a string of exact length to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_buffer (Eina_Strbuf *buf, const Eina_Strbuf *data) EINA_ARG_NONNULL(1
 Append an Eina_Strbuf to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_char (Eina_Strbuf *buf, char c) EINA_ARG_NONNULL(1)
 Append a character to a string buffer, reallocating as necessary. More...
 
EAPI Eina_Bool eina_strbuf_append_printf (Eina_Strbuf *buf, const char *fmt,...) EINA_ARG_NONNULL(1
 Append a string to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EINA_PRINTF (2, 3)
 
EAPI Eina_Bool eina_strbuf_append_vprintf (Eina_Strbuf *buf, const char *fmt, va_list args) EINA_ARG_NONNULL(1
 Append a string to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert (Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1
 Insert a string to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert_escaped (Eina_Strbuf *buf, const char *str, size_t pos) EINA_ARG_NONNULL(1
 Insert an escaped string to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert_n (Eina_Strbuf *buf, const char *str, size_t maxlen, size_t pos) EINA_ARG_NONNULL(1
 Insert a string to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert_length (Eina_Strbuf *buf, const char *str, size_t length, size_t pos) EINA_ARG_NONNULL(1
 Insert a string of exact length to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert_char (Eina_Strbuf *buf, char c, size_t pos) EINA_ARG_NONNULL(1)
 Insert a character to a string buffer, reallocating as necessary. More...
 
EAPI Eina_Bool eina_strbuf_insert_printf (Eina_Strbuf *buf, const char *fmt, size_t pos,...) EINA_ARG_NONNULL(1
 Insert a string to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool EINA_PRINTF (2, 4)
 
EAPI Eina_Bool eina_strbuf_insert_vprintf (Eina_Strbuf *buf, const char *fmt, size_t pos, va_list args) EINA_ARG_NONNULL(1
 Insert a string to a buffer, reallocating as necessary. More...
 
EAPI Eina_Bool eina_strbuf_remove (Eina_Strbuf *buf, size_t start, size_t end) EINA_ARG_NONNULL(1)
 Remove a slice of the given string buffer. More...
 
EAPI const char * eina_strbuf_string_get (const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
 Retrieve a pointer to the contents of a string buffer. More...
 
EAPI char * eina_strbuf_string_steal (Eina_Strbuf *buf) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1)
 Steal the contents of a string buffer. More...
 
EAPI void eina_strbuf_string_free (Eina_Strbuf *buf) EINA_ARG_NONNULL(1)
 Free the contents of a string buffer but not the buffer. More...
 
EAPI size_t eina_strbuf_length_get (const Eina_Strbuf *buf) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT
 Retrieve the length of the string buffer content. More...
 
EAPI Eina_Bool eina_strbuf_replace (Eina_Strbuf *buf, const char *str, const char *with, unsigned int n) EINA_ARG_NONNULL(1
 Replace the n-th string with an other string. More...
 
EAPI int eina_strbuf_replace_all (Eina_Strbuf *buf, const char *str, const char *with) EINA_ARG_NONNULL(1
 Replace all strings with an other string. More...
 
EAPI int EAPI void eina_strbuf_trim (Eina_Strbuf *buf) EINA_ARG_NONNULL(1)
 Trim the string buffer. More...
 
EAPI void eina_strbuf_ltrim (Eina_Strbuf *buf) EINA_ARG_NONNULL(1)
 Left trim the string buffer. More...
 
EAPI void eina_strbuf_rtrim (Eina_Strbuf *buf) EINA_ARG_NONNULL(1)
 Right trim the string buffer. More...
 
EAPI void eina_strbuf_tolower (Eina_Strbuf *buf) EINA_ARG_NONNULL(1)
 Convert the string to lower case. More...
 
EAPI Eina_Strbufeina_strbuf_substr_get (Eina_Strbuf *buf, size_t pos, size_t len) EINA_MALLOC EINA_WARN_UNUSED_RESULT
 Obtain substring from the src. More...
 

Detailed Description

These functions provide string buffers management.

The String Buffer data type is designed to be a mutable string, allowing to append, prepend or insert a string to a buffer.

For more information see this example.

Macro Definition Documentation

◆ eina_strbuf_prepend

#define eina_strbuf_prepend (   buf,
  str 
)    eina_strbuf_insert(buf, str, 0)

Prepend the given string to the given buffer.

Parameters
bufThe string buffer to prepend to.
strThe string to prepend.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This macro is calling eina_strbuf_insert() at position 0. If buf can't prepend it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

◆ eina_strbuf_prepend_escaped

#define eina_strbuf_prepend_escaped (   buf,
  str 
)    eina_strbuf_insert_escaped(buf, str, 0)

Prepend the given escaped string to the given buffer.

Parameters
bufThe string buffer to prepend to.
strThe string to prepend.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This macro is calling eina_strbuf_insert_escaped() at position 0. If buf can't prepend it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

◆ eina_strbuf_prepend_n

#define eina_strbuf_prepend_n (   buf,
  str,
  maxlen 
)    eina_strbuf_insert_n(buf, str, maxlen, 0)

Prepend the given escaped string to the given buffer.

Parameters
bufThe string buffer to prepend to.
strThe string to prepend.
maxlenThe maximum number of chars to prepend.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This macro is calling eina_strbuf_insert_n() at position 0. If buf can't prepend it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

◆ eina_strbuf_prepend_length

#define eina_strbuf_prepend_length (   buf,
  str,
  length 
)    eina_strbuf_insert_length(buf, str, length, 0)

Prepend the given escaped string to the given buffer.

Parameters
bufThe string buffer to prepend to.
strThe string to prepend.
lengthThe exact length to use.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This macro is calling eina_strbuf_insert_length() at position 0. If buf can't prepend it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

◆ eina_strbuf_prepend_char

#define eina_strbuf_prepend_char (   buf,
 
)    eina_strbuf_insert_char(buf, c, 0)

Prepend the given character to the given buffer.

Parameters
bufThe string buffer to prepend to.
cThe character to prepend.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This macro is calling eina_strbuf_insert_char() at position 0. If buf can't prepend it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

◆ eina_strbuf_prepend_printf

#define eina_strbuf_prepend_printf (   buf,
  fmt,
  ... 
)    eina_strbuf_insert_printf(buf, fmt, 0, ## __VA_ARGS__)

Prepend the given string to the given buffer.

Parameters
bufThe string buffer to prepend to.
fmtThe string to prepend.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This macro is calling eina_strbuf_insert_printf() at position 0. If buf can't prepend it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

◆ eina_strbuf_prepend_vprintf

#define eina_strbuf_prepend_vprintf (   buf,
  fmt,
  args 
)    eina_strbuf_insert_vprintf(buf, fmt, 0, args)

Prepend the given string to the given buffer.

Parameters
bufThe string buffer to prepend to.
fmtThe string to prepend.
argsThe variable arguments.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This macro is calling eina_strbuf_insert_vprintf() at position 0.If buf can't prepend it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

◆ eina_strbuf_replace_first

#define eina_strbuf_replace_first (   buf,
  str,
  with 
)    eina_strbuf_replace(buf, str, with, 1)

Prepend the given character to the given buffer.

Parameters
bufThe string buffer to work with.
strThe string to replace.
withThe replaceing string.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This macro is calling eina_strbuf_replace() with the n-th occurrence equal to 1. If buf can't replace it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

Function Documentation

◆ eina_strbuf_new()

EAPI Eina_Strbuf* eina_strbuf_new ( void  )

◆ eina_strbuf_manage_new()

EAPI Eina_Strbuf* eina_strbuf_manage_new ( char *  str)

Create a new string buffer using the passed string.

The passed string is used directly as the buffer, it's somehow the opposite function of eina_strbuf_string_steal . The passed string must be malloced.

Parameters
strthe string to manage
Returns
Newly allocated string buffer instance.

This function creates a new string buffer. On error, NULL is returned. To free the resources, use eina_strbuf_free().

See also
eina_strbuf_free()
eina_strbuf_append()
eina_strbuf_string_get()
Since
1.1.0

Referenced by eina_strbuf_substr_get().

◆ eina_strbuf_manage_new_length()

EAPI Eina_Strbuf* eina_strbuf_manage_new_length ( char *  str,
size_t  length 
)

Create a new string buffer using the passed string.

The passed string is used directly as the buffer, it's somehow the opposite function of eina_strbuf_string_steal . The passed string must be malloced.

Parameters
strthe string to manage
lengththe length of the string.
Returns
Newly allocated string buffer instance.

This function creates a new string buffer. On error, NULL is returned. To free the resources, use eina_strbuf_free().

See also
eina_strbuf_manage_new()
Since
1.2.0

◆ eina_strbuf_manage_read_only_new_length()

EAPI Eina_Strbuf* eina_strbuf_manage_read_only_new_length ( const char *  str,
size_t  length 
)

Create a new string buffer using the passed string.

The passed string is used directly as the buffer, it's somehow the opposite function of eina_strbuf_string_steal . The passed string must be malloced.

Parameters
strthe string to manage
lengththe length of the string.
Returns
Newly allocated string buffer instance.

This function creates a new string buffer. On error, NULL is returned. To free the resources, use eina_strbuf_free().

See also
eina_strbuf_manage_new()
Since
1.9.0
Examples:
eina_strbuf_01.c.

◆ eina_strbuf_free()

EAPI void eina_strbuf_free ( Eina_Strbuf buf)

◆ eina_strbuf_reset()

EAPI void eina_strbuf_reset ( Eina_Strbuf buf)

Reset a string buffer.

Parameters
bufThe string buffer to reset.

This function reset buf: the buffer len is set to 0, and the string is set to '\0'. No memory is free'd.

Examples:
eina_strbuf_01.c.

Referenced by edje_evas_global_perspective_get().

◆ eina_strbuf_append()

EAPI Eina_Bool eina_strbuf_append ( Eina_Strbuf buf,
const char *  str 
)

Append a string to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to append to.
strThe string to append.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function appends str to buf. It computes the length of str, so is slightly slower than eina_strbuf_append_length(). If the length is known beforehand, consider using that variant. If buf can't append it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

See also
eina_strbuf_append()
eina_strbuf_append_length()

Referenced by ecore_file_app_exe_get(), edje_edit_source_generate(), edje_evas_global_perspective_get(), evas_object_textblock_text_markup_prepend(), and evas_textblock_text_markup_to_utf8().

◆ eina_strbuf_append_escaped()

EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_escaped ( Eina_Strbuf buf,
const char *  str 
)

Append an escaped string to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to append to.
strThe string to append.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function escapes and then appends the string str to buf. If str can not be appended, EINA_FALSE is returned, otherwise, EINA_TRUE is returned.

Examples:
eina_strbuf_01.c.

◆ eina_strbuf_append_n()

EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_n ( Eina_Strbuf buf,
const char *  str,
size_t  maxlen 
)

Append a string to a buffer, reallocating as necessary, limited by the given length.

Parameters
bufThe string buffer to append to.
strThe string to append.
maxlenThe maximum number of characters to append.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function appends at most maxlen characters of str to buf. It can't append more than the length of str. It computes the length of str, so it is slightly slower than eina_strbuf_append_length(). If the length is known beforehand, consider using that variant (maxlen should then be checked so that it is greater than the size of str). If str can not be appended, EINA_FALSE is returned, otherwise, EINA_TRUE is returned.

See also
eina_strbuf_append()
eina_strbuf_append_length()

◆ eina_strbuf_append_length()

EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_length ( Eina_Strbuf buf,
const char *  str,
size_t  length 
)

Append a string of exact length to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to append to.
strThe string to append.
lengthThe exact length to use.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function appends str to buf. str must be of size at most length. It is slightly faster than eina_strbuf_append() as it does not compute the size of str. It is useful when dealing with strings of known size, such as eina_stringshare. If buf can't append it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

See also
eina_stringshare_length()
eina_strbuf_append()
eina_strbuf_append_n()
Examples:
eina_strbuf_01.c.

Referenced by evas_object_textblock_text_markup_prepend(), evas_textblock_style_set(), and evas_textblock_text_markup_to_utf8().

◆ eina_strbuf_append_buffer()

EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_buffer ( Eina_Strbuf buf,
const Eina_Strbuf data 
)

Append an Eina_Strbuf to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to append to.
dataThe string buffer to append.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function appends data to buf. data must be allocated and different from . It is slightly faster than eina_strbuf_append() as it does not compute the size of str. If buf can't append it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

See also
eina_strbuf_append()
eina_strbuf_append_n()
eina_strbuf_append_length()
Since
1.9.0

◆ eina_strbuf_append_char()

EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_append_char ( Eina_Strbuf buf,
char  c 
)

Append a character to a string buffer, reallocating as necessary.

Parameters
bufThe string buffer to append to.
cThe char to append.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function inserts c to buf. If it can not insert it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

Examples:
eina_strbuf_01.c.

Referenced by ecore_file_app_exe_get(), elm_theme_get(), evas_object_textblock_text_markup_prepend(), and evas_textblock_style_set().

◆ eina_strbuf_append_printf()

EAPI Eina_Bool eina_strbuf_append_printf ( Eina_Strbuf buf,
const char *  fmt,
  ... 
)

Append a string to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to append to.
fmtThe string to append.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function appends the string defined by the format fmt to buf. 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.

See also
eina_strbuf_append()
Examples:
eina_strbuf_01.c.

Referenced by edje_edit_source_generate(), and edje_init().

◆ eina_strbuf_append_vprintf()

EAPI Eina_Bool eina_strbuf_append_vprintf ( Eina_Strbuf buf,
const char *  fmt,
va_list  args 
)

Append a string to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to append to.
fmtThe string to append.
argsThe variable arguments.
Returns
EINA_TRUE on success, EINA_FALSE on failure.
See also
eina_strbuf_append_printf()

◆ eina_strbuf_insert()

EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert ( Eina_Strbuf buf,
const char *  str,
size_t  pos 
)

Insert a string to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to insert.
strThe string to insert.
posThe position to insert the string.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function inserts str to buf at position pos. It computes the length of str, so is slightly slower than eina_strbuf_insert_length(). If the length is known beforehand, consider using that variant. If buf can't insert it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

◆ eina_strbuf_insert_escaped()

EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert_escaped ( Eina_Strbuf buf,
const char *  str,
size_t  pos 
)

Insert an escaped string to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to insert to.
strThe string to insert.
posThe position to insert the string.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function escapes and inserts the string str to buf at position pos. If buf can't insert str, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

Examples:
eina_strbuf_01.c.

◆ eina_strbuf_insert_n()

EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert_n ( Eina_Strbuf buf,
const char *  str,
size_t  maxlen,
size_t  pos 
)

Insert a string to a buffer, reallocating as necessary.

Limited by maxlen.

Parameters
bufThe string buffer to insert to.
strThe string to insert.
maxlenThe maximum number of chars to insert.
posThe position to insert the string.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function inserts str to buf at position pos, with at most maxlen bytes. The number of inserted characters can not be greater than the length of str. It computes the length of str, so is slightly slower than eina_strbuf_insert_length(). If the length is known beforehand, consider using that variant (maxlen should then be checked so that it is greater than the size of str). If str can not be inserted, EINA_FALSE is returned, otherwise, EINA_TRUE is returned.

◆ eina_strbuf_insert_length()

EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert_length ( Eina_Strbuf buf,
const char *  str,
size_t  length,
size_t  pos 
)

Insert a string of exact length to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to insert to.
strThe string to insert.
lengthThe exact length to use.
posThe position to insert the string.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function inserts str to buf. str must be of size at most length. It is slightly faster than eina_strbuf_insert() as it does not compute the size of str. It is useful when dealing with strings of known size, such as eina_strngshare. If buf can't insert it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

See also
eina_stringshare_length()
eina_strbuf_insert()
eina_strbuf_insert_n()

◆ eina_strbuf_insert_char()

EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool EAPI Eina_Bool eina_strbuf_insert_char ( Eina_Strbuf buf,
char  c,
size_t  pos 
)

Insert a character to a string buffer, reallocating as necessary.

Parameters
bufThe string buffer to insert to.
cThe char to insert.
posThe position to insert the char.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function inserts c to buf at position pos. If buf can't append it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

◆ eina_strbuf_insert_printf()

EAPI Eina_Bool eina_strbuf_insert_printf ( Eina_Strbuf buf,
const char *  fmt,
size_t  pos,
  ... 
)

Insert a string to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to insert.
fmtThe string to insert.
posThe position to insert the string.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function insert a string as described by the format fmt to buf at the position pos. 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.

Examples:
eina_strbuf_01.c.

◆ eina_strbuf_insert_vprintf()

EAPI Eina_Bool eina_strbuf_insert_vprintf ( Eina_Strbuf buf,
const char *  fmt,
size_t  pos,
va_list  args 
)

Insert a string to a buffer, reallocating as necessary.

Parameters
bufThe string buffer to insert.
fmtThe string to insert.
posThe position to insert the string.
argsThe variable arguments.
Returns
EINA_TRUE on success, EINA_FALSE on failure.
See also
eina_strbuf_insert_printf

◆ eina_strbuf_remove()

EAPI Eina_Bool eina_strbuf_remove ( Eina_Strbuf buf,
size_t  start,
size_t  end 
)

Remove a slice of the given string buffer.

Parameters
bufThe string buffer to remove a slice.
startThe initial (inclusive) slice position to start removing, in bytes.
endThe final (non-inclusive) slice position to finish removing, in bytes.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function removes a slice of buf, starting at start (inclusive) and ending at end (non-inclusive). Both values are in bytes. It returns EINA_FALSE on failure, EINA_TRUE otherwise.

Examples:
eina_strbuf_01.c.

◆ eina_strbuf_string_get()

EAPI const char* eina_strbuf_string_get ( const Eina_Strbuf buf)

Retrieve a pointer to the contents of a string buffer.

Parameters
bufThe string buffer.
Returns
The current string in the string buffer.

This function returns the string contained in buf. The returned value must not be modified and will no longer be valid if 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.

See also
eina_strbuf_string_steal()
Examples:
eina_strbuf_01.c.

Referenced by ecore_evas_aux_hint_add(), ecore_evas_aux_hint_del(), ecore_evas_aux_hint_val_set(), edje_edit_full_source_generate(), edje_edit_source_generate(), edje_evas_global_perspective_get(), edje_init(), eldbus_signal_handler_match_extra_vset(), eldbus_signal_handler_ref(), eldbus_signal_handler_unref(), elm_theme_get(), and evas_object_textblock_text_markup_get().

◆ eina_strbuf_string_steal()

EAPI char* eina_strbuf_string_steal ( Eina_Strbuf buf)

Steal the contents of a string buffer.

Parameters
bufThe string buffer to steal.
Returns
The current string in the string buffer.

This function returns the string contained in buf. buf is then initialized and does not own the returned string anymore. The caller must release the memory of the returned string by calling free().

See also
eina_strbuf_string_get()

Referenced by ecore_file_app_exe_get(), edje_edit_full_source_generate(), eina_simple_xml_node_dump(), evas_textblock_cursor_content_get(), evas_textblock_style_set(), evas_textblock_text_markup_to_utf8(), and evas_textblock_text_utf8_to_markup().

◆ eina_strbuf_string_free()

EAPI void eina_strbuf_string_free ( Eina_Strbuf buf)

Free the contents of a string buffer but not the buffer.

Parameters
bufThe string buffer to free the string of.

This function frees the string contained in buf without freeing buf.

◆ eina_strbuf_length_get()

EAPI size_t eina_strbuf_length_get ( const Eina_Strbuf buf)

Retrieve the length of the string buffer content.

Parameters
bufThe string buffer.
Returns
The current length of the string, in bytes.

This function returns the length of buf.

Examples:
eina_strbuf_01.c.

◆ eina_strbuf_replace()

EAPI Eina_Bool eina_strbuf_replace ( Eina_Strbuf buf,
const char *  str,
const char *  with,
unsigned int  n 
)

Replace the n-th string with an other string.

Parameters
bufThe string buffer to work with.
strThe string to replace.
withThe replaceing string.
nThe number of the fitting string.
Returns
EINA_TRUE on success, EINA_FALSE on failure.

This function replaces the n-th occurrence of str in buf with with. It returns EINA_FALSE on failure, EINA_TRUE otherwise.

◆ eina_strbuf_replace_all()

EAPI int eina_strbuf_replace_all ( Eina_Strbuf buf,
const char *  str,
const char *  with 
)

Replace all strings with an other string.

Parameters
bufthe string buffer to work with.
strThe string to replace.
withThe replaceing string.
Returns
How often the string was replaced.

This function replaces all the occurrences of str in buf with the string with. This function returns the number of times str has been replaced. On failure, it returns 0.

Examples:
eina_strbuf_01.c.

◆ eina_strbuf_trim()

EAPI int EAPI void eina_strbuf_trim ( Eina_Strbuf buf)

Trim the string buffer.

Parameters
bufthe string buffer to work with.

This function skips whitespaces in the beginning and the end of the buffer.

◆ eina_strbuf_ltrim()

EAPI void eina_strbuf_ltrim ( Eina_Strbuf buf)

Left trim the string buffer.

Parameters
bufthe string buffer to work with.

This function skips whitespaces in the beginning of the buffer.

◆ eina_strbuf_rtrim()

EAPI void eina_strbuf_rtrim ( Eina_Strbuf buf)

Right trim the string buffer.

Parameters
bufthe string buffer to work with.

This function skips whitespaces in the end of the buffer.

◆ eina_strbuf_tolower()

EAPI void eina_strbuf_tolower ( Eina_Strbuf buf)

Convert the string to lower case.

Parameters
bufthe string buffer to work with.

This function converts all the characters in the strbuf to lower case.

Since
1.17

References eina_str_tolower().

◆ eina_strbuf_substr_get()

EAPI Eina_Strbuf* eina_strbuf_substr_get ( Eina_Strbuf buf,
size_t  pos,
size_t  len 
)

Obtain substring from the src.

Parameters
bufthe src string.
posthe position in the source string from which the substring should be created. The first character is denoted by a value of 0 (not 1).
lenthe length from pos that should be copied to substring.

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.

Since
1.17

References eina_strbuf_manage_new().