Tizen Native API
Unicode String Buffer

This group discusses the functions that provide unicode string buffers management.

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

Functions

Eina_UStrbufeina_ustrbuf_new (void)
 Creates a new string buffer.
Eina_UStrbufeina_ustrbuf_manage_new (Eina_Unicode *str)
 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 eina_ustrbuf_string_steal . The passed string must be malloced.
Eina_UStrbufeina_ustrbuf_manage_new_length (Eina_Unicode *str, size_t length)
 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 eina_ustrbuf_string_steal . The passed string must be malloced.
void eina_ustrbuf_free (Eina_UStrbuf *buf)
 Frees a string buffer.
void eina_ustrbuf_reset (Eina_UStrbuf *buf)
 Resets a string buffer.
Eina_Bool eina_ustrbuf_append (Eina_UStrbuf *buf, const Eina_Unicode *str) 2)
 Appends a string to a buffer, reallocating as necessary.
Eina_Bool eina_ustrbuf_append_escaped (Eina_UStrbuf *buf, const Eina_Unicode *str) 2)
 Appends an escaped string to a buffer, reallocating as necessary.
Eina_Bool eina_ustrbuf_append_n (Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen) 2)
 Appends a string to a buffer, reallocating as necessary, limited by the given length.
Eina_Bool eina_ustrbuf_append_length (Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length) 2)
 Appends a string of exact length to a buffer, reallocating as necessary.
Eina_Bool eina_ustrbuf_append_char (Eina_UStrbuf *buf, Eina_Unicode c)
 Appends a character to a string buffer, reallocating as necessary.
Eina_Bool eina_ustrbuf_insert (Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) 2)
 Inserts a string into a buffer, reallocating as necessary.
Eina_Bool eina_ustrbuf_insert_escaped (Eina_UStrbuf *buf, const Eina_Unicode *str, size_t pos) 2)
 Inserts an escaped string into a buffer, reallocating as necessary.
Eina_Bool eina_ustrbuf_insert_n (Eina_UStrbuf *buf, const Eina_Unicode *str, size_t maxlen, size_t pos) 2)
 Inserts a string into a buffer, reallocating as necessary. Limited by maxlen.
Eina_Bool eina_ustrbuf_insert_length (Eina_UStrbuf *buf, const Eina_Unicode *str, size_t length, size_t pos) 2)
 Inserts a string of exact length into a buffer, reallocating as necessary.
Eina_Bool eina_ustrbuf_insert_char (Eina_UStrbuf *buf, Eina_Unicode c, size_t pos)
 Inserts a character into a string buffer, reallocating as necessary.
Eina_Bool eina_ustrbuf_remove (Eina_UStrbuf *buf, size_t start, size_t end)
 Removes a slice of the given string buffer.
const Eina_Unicodeeina_ustrbuf_string_get (const Eina_UStrbuf *buf)
 Gets a pointer to the contents of a string buffer.
Eina_Unicodeeina_ustrbuf_string_steal (Eina_UStrbuf *buf)
 Steals the contents of a string buffer.
void eina_ustrbuf_string_free (Eina_UStrbuf *buf)
 Frees the contents of a string buffer but not the buffer.
size_t eina_ustrbuf_length_get (const Eina_UStrbuf *buf)
 Gets the length of the string buffer's content.

Typedefs

typedef struct _Eina_Strbuf Eina_UStrbuf
 The structure type for a string buffer.

Defines

#define eina_ustrbuf_prepend(buf, str)   eina_ustrbuf_insert(buf, str, 0)
 Prepends the given string to the given buffer.
#define eina_ustrbuf_prepend_escaped(buf, str)   eina_ustrbuf_insert_escaped(buf, str, 0)
 Prepends the given escaped string to the given buffer.
#define eina_ustrbuf_prepend_n(buf, str, maxlen)   eina_ustrbuf_insert_n(buf, str, maxlen, 0)
 Prepends the given escaped string to the given buffer.
#define eina_ustrbuf_prepend_length(buf, str, length)   eina_ustrbuf_insert_length(buf, str, length, 0)
 Prepends the given escaped string to the given buffer.
#define eina_ustrbuf_prepend_char(buf, c)   eina_ustrbuf_insert_char(buf, c, 0)
 Prepends the given unicode character to the given buffer.

Define Documentation

#define eina_ustrbuf_prepend (   buf,
  str 
)    eina_ustrbuf_insert(buf, str, 0)

Prepends the given string to the given buffer.

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

Since :
2.3.1
Parameters:
bufThe string buffer to prepend to
strThe string to prepend
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
#define eina_ustrbuf_prepend_char (   buf,
 
)    eina_ustrbuf_insert_char(buf, c, 0)

Prepends the given unicode character to the given buffer.

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

Since :
2.3.1
Parameters:
bufThe string buffer to prepend to
cThe Eina_Unicode character to prepend
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
#define eina_ustrbuf_prepend_escaped (   buf,
  str 
)    eina_ustrbuf_insert_escaped(buf, str, 0)

Prepends the given escaped string to the given buffer.

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

Since :
2.3.1
Parameters:
bufThe string buffer to prepend to
strThe string to prepend
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
#define eina_ustrbuf_prepend_length (   buf,
  str,
  length 
)    eina_ustrbuf_insert_length(buf, str, length, 0)

Prepends the given escaped string to the given buffer.

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

Since :
2.3.1
Parameters:
bufThe string buffer to prepend to
strThe string to prepend
lengthThe exact length to use
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
#define eina_ustrbuf_prepend_n (   buf,
  str,
  maxlen 
)    eina_ustrbuf_insert_n(buf, str, maxlen, 0)

Prepends the given escaped string to the given buffer.

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

Since :
2.3.1
Parameters:
bufThe string buffer to prepend to
strThe string to prepend
maxlenThe maximum number of Eina_Unicode characters to prepend
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure

Function Documentation

Appends a string to a buffer, reallocating as necessary.

This function appends str to buf. It computes the length of str, so is slightly slower than eina_ustrbuf_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.

Since :
2.3.1
Parameters:
[in]bufThe string buffer to append to
[in]strThe string to append
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
See also:
eina_ustrbuf_append()
eina_ustrbuf_append_length()

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

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

Since :
2.3.1
Parameters:
[in]bufThe string buffer to append to
[in]cThe char to append
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure

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

This function appends the escaped string str to buf. If str cannot be appended, EINA_FALSE is returned, otherwise, EINA_TRUE is returned.

Since :
2.3.1
Parameters:
[in]bufThe string buffer to append to
[in]strThe string to append
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
Eina_Bool eina_ustrbuf_append_length ( Eina_UStrbuf buf,
const Eina_Unicode str,
size_t  length 
)

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

This function appends str to buf. str must be at most of size length. It is slightly faster than eina_ustrbuf_append() 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 append it, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

Since :
2.3.1
Parameters:
[in]bufThe string buffer to append to
[in]strThe string to append
[in]lengthThe exact length to use
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
See also:
eina_stringshare_length()
eina_ustrbuf_append()
eina_ustrbuf_append_n()
Eina_Bool eina_ustrbuf_append_n ( Eina_UStrbuf buf,
const Eina_Unicode str,
size_t  maxlen 
)

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

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 is slightly slower than eina_ustrbuf_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 cannot be appended, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

Since :
2.3.1
Parameters:
[in]bufThe string buffer to append to
[in]strThe string to append
[in]maxlenThe maximum number of characters to append
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
See also:
eina_ustrbuf_append()
eina_ustrbuf_append_length()

Frees a string buffer.

This function frees the memory of buf. buf must have been created by eina_ustrbuf_new().

Since :
2.3.1
Parameters:
[in]bufThe string buffer to free
Eina_Bool eina_ustrbuf_insert ( Eina_UStrbuf buf,
const Eina_Unicode str,
size_t  pos 
)

Inserts a string into a buffer, reallocating as necessary.

This function inserts str into buf at position pos. It computes the length of str, so is slightly slower than eina_ustrbuf_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.

Since :
2.3.1
Parameters:
[in]bufThe string buffer to insert into
[in]strThe string to insert
[in]posThe position at which to insert the string
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
Eina_Bool eina_ustrbuf_insert_char ( Eina_UStrbuf buf,
Eina_Unicode  c,
size_t  pos 
)

Inserts a character into a string buffer, reallocating as necessary.

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

Since :
2.3.1
Parameters:
[in]bufThe string buffer to insert into
[in]cThe character to insert
[in]posThe position at which to insert the char
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
Eina_Bool eina_ustrbuf_insert_escaped ( Eina_UStrbuf buf,
const Eina_Unicode str,
size_t  pos 
)

Inserts an escaped string into a buffer, reallocating as necessary.

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

Since :
2.3.1
Parameters:
[in]bufThe string buffer to insert into
[in]strThe string to insert
[in]posThe position at which to insert the string
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
Eina_Bool eina_ustrbuf_insert_length ( Eina_UStrbuf buf,
const Eina_Unicode str,
size_t  length,
size_t  pos 
)

Inserts a string of exact length into a buffer, reallocating as necessary.

This function inserts str into buf. str must be at most of size length. It is slightly faster than eina_ustrbuf_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.

Since :
2.3.1
Parameters:
[in]bufThe string buffer to insert into
[in]strThe string to insert
[in]lengthThe exact length to use
[in]posThe position at which to insert the string
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
See also:
eina_stringshare_length()
eina_ustrbuf_insert()
eina_ustrbuf_insert_n()
Eina_Bool eina_ustrbuf_insert_n ( Eina_UStrbuf buf,
const Eina_Unicode str,
size_t  maxlen,
size_t  pos 
)

Inserts a string into a buffer, reallocating as necessary. Limited by maxlen.

This function inserts str into buf at position pos, with at most maxlen bytes. The number of inserted characters cannot be greater than the length of str. It computes the length of str, so is slightly slower than eina_ustrbuf_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 cannot be inserted, EINA_FALSE is returned, otherwise EINA_TRUE is returned.

Since :
2.3.1
Parameters:
[in]bufThe string buffer to insert into
[in]strThe string to insert
[in]maxlenThe maximum number of characters to insert
[in]posThe position at which to insert the string
Returns:
EINA_TRUE on success, otherwise EINA_FALSE on failure
size_t eina_ustrbuf_length_get ( const Eina_UStrbuf buf)

Gets the length of the string buffer's content.

This function returns the length of buf.

Since :
2.3.1
Parameters:
[in]bufThe string buffer
Returns:
The current length of the string, in bytes

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 eina_ustrbuf_string_steal . The passed string must be malloced.

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

Since (EFL) :
1.1.0
Since :
2.3.1
Parameters:
[in]strThe string to manage
Returns:
A newly allocated string buffer instance
See also:
eina_ustrbuf_free()
eina_ustrbuf_append()
eina_ustrbuf_string_get()
Eina_UStrbuf* eina_ustrbuf_manage_new_length ( Eina_Unicode str,
size_t  length 
)

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 eina_ustrbuf_string_steal . The passed string must be malloced.

This function creates a new string buffer. On error, NULL is returned and Eina error is set to EINA_ERROR_OUT_OF_MEMORY. To free the resources, use eina_ustrbuf_free().

Since (EFL) :
1.2.0
Since :
2.3.1
Parameters:
[in]strThe string to manage
[in]lengthThe length of the string
Returns:
A newly allocated string buffer instance
See also:
eina_ustrbuf_manage_new()

Creates a new string buffer.

This function creates a new string buffer. On error, NULL is returned and Eina error is set to EINA_ERROR_OUT_OF_MEMORY. To free the resources, use eina_ustrbuf_free().

Since :
2.3.1
Returns:
A newly allocated string buffer instance
See also:
eina_ustrbuf_free()
eina_ustrbuf_append()
eina_ustrbuf_string_get()
Eina_Bool eina_ustrbuf_remove ( Eina_UStrbuf buf,
size_t  start,
size_t  end 
)

Removes a slice of the given string buffer.

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

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

Resets a string buffer.

This function resets buf: the buffer length is set to 0, and the string is set to '\0'. No memory is freed.

Since :
2.3.1
Parameters:
[in]bufThe string buffer to reset

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

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

Since :
2.3.1
Parameters:
[in]bufThe string buffer to free the string of

Gets a pointer to the contents of a string buffer.

This function returns the string contained in buf. The returned value must not be modified and is longer be valid if buf is modified. In other words, any eina_ustrbuf_append() or similar makes that pointer invalid.

Since :
2.3.1
Parameters:
bufThe string buffer
Returns:
The current string in the string buffer
See also:
eina_ustrbuf_string_steal()

Steals the contents of a 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().

Since :
2.3.1
Parameters:
[in]bufThe string buffer to steal from
Returns:
The current string in the string buffer
See also:
eina_ustrbuf_string_get()