gstring.h File Reference

__G_STRING_H__

Typedef GString

typedef typedefG_BEGIN_DECLS struct _GStringGString

Typedef GStringChunk

typedef struct _GStringChunkGStringChunk

g_string_chunk_new ( gsize )

IMPORT_C GStringChunk *g_string_chunk_new(gsizesize)

g_string_chunk_new: : the default size of the blocks of memory which are allocated to store the strings. If a particular string is larger than this default size, a larger block of memory will be allocated for it.

Creates a new GStringChunk.

Returns: a new GStringChunk

g_string_chunk_free ( GStringChunk * )

IMPORT_C voidg_string_chunk_free(GStringChunk *chunk)

g_string_chunk_free: : a GStringChunk

Frees all memory allocated by the GStringChunk. After calling g_string_chunk_free() it is not safe to access any of the strings which were contained within it.

g_string_chunk_clear ( GStringChunk * )

IMPORT_C voidg_string_chunk_clear(GStringChunk *chunk)

g_string_chunk_clear: : a GStringChunk

Frees all strings contained within the GStringChunk. After calling g_string_chunk_clear() it is not safe to access any of the strings which were contained within it.

Since: 2.14

g_string_chunk_insert ( GStringChunk *, const gchar * )

IMPORT_C gchar *g_string_chunk_insert(GStringChunk *chunk,
const gchar *string
)

g_string_chunk_insert: : a GStringChunk : the string to add

Adds a copy of to the GStringChunk. It returns a pointer to the new copy of the string in the GStringChunk. The characters in the string can be changed, if necessary, though you should not change anything after the end of the string.

Unlike g_string_chunk_insert_const(), this function does not check for duplicates. Also strings added with g_string_chunk_insert() will not be searched by g_string_chunk_insert_const() when looking for duplicates.

Returns: a pointer to the copy of within the GStringChunk

g_string_chunk_insert_len ( GStringChunk *, const gchar *, gssize )

IMPORT_C gchar *g_string_chunk_insert_len(GStringChunk *chunk,
const gchar *string,
gssizelen
)

g_string_chunk_insert_len: : a GStringChunk : bytes to insert : number of bytes of to insert, or -1 to insert a nul-terminated string

Adds a copy of the first bytes of to the GStringChunk. The copy is nul-terminated.

Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that has at least addressable bytes.

The characters in the returned string can be changed, if necessary, though you should not change anything after the end of the string.

Return value: a pointer to the copy of within the GStringChunk

Since: 2.4

g_string_chunk_insert_const ( GStringChunk *, const gchar * )

IMPORT_C gchar *g_string_chunk_insert_const(GStringChunk *chunk,
const gchar *string
)

g_string_chunk_insert_const: : a GStringChunk : the string to add

Adds a copy of to the GStringChunk, unless the same string has already been added to the GStringChunk with g_string_chunk_insert_const().

This function is useful if you need to copy a large number of strings but do not want to waste space storing duplicates. But you must remember that there may be several pointers to the same string, and so any changes made to the strings should be done very carefully.

Note that g_string_chunk_insert_const() will not return a pointer to a string added with g_string_chunk_insert(), even if they do match.

Returns: a pointer to the new or existing copy of within the GStringChunk

g_string_new ( const gchar * )

IMPORT_C GString *g_string_new(const gchar *init)

g_string_new: : the initial text to copy into the string

Creates a new GString, initialized with the given string.

Returns: the new GString

g_string_new_len ( const gchar *, gssize )

IMPORT_C GString *g_string_new_len(const gchar *init,
gssizelen
)

g_string_new_len: : initial contents of the string : length of to use

Creates a new GString with bytes of the buffer. Because a length is provided, need not be nul-terminated, and can contain embedded nul bytes.

Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that has at least addressable bytes.

Returns: a new GString

g_string_sized_new ( gsize )

IMPORT_C GString *g_string_sized_new(gsizedfl_size)

g_string_sized_new: : the default size of the space allocated to hold the string

Creates a new GString, with enough space for bytes. This is useful if you are going to add a lot of text to the string and don't want it to be reallocated too often.

Returns: the new GString

g_string_free ( GString *, gboolean )

IMPORT_C gchar *g_string_free(GString *string,
gbooleanfree_segment
)

g_string_free: : a GString : if TRUE the actual character data is freed as well

Frees the memory allocated for the GString. If is TRUE it also frees the character data.

Returns: the character data of (i.e. NULL if is TRUE)

g_string_equal ( const GString *, const GString * )

IMPORT_C gbooleang_string_equal(const GString *v,
const GString *v2
)

g_string_equal: : a GString : another GString

Compares two strings for equality, returning TRUE if they are equal. For use with GHashTable.

Returns: TRUE if they strings are the same length and contain the same bytes

g_string_hash ( const GString * )

IMPORT_C guintg_string_hash(const GString *str)

g_string_hash: : a string to hash

Creates a hash code for ; for use with GHashTable.

Returns: hash code for

g_string_assign ( GString *, const gchar * )

IMPORT_C GString *g_string_assign(GString *string,
const gchar *rval
)

g_string_assign: : the destination GString. Its current contents are destroyed. : the string to copy into

Copies the bytes from a string into a GString, destroying any previous contents. It is rather like the standard strcpy() function, except that you do not have to worry about having enough space to copy the string.

Returns:

g_string_truncate ( GString *, gsize )

IMPORT_C GString *g_string_truncate(GString *string,
gsizelen
)

g_string_truncate: : a GString : the new size of

Cuts off the end of the GString, leaving the first bytes.

Returns:

g_string_set_size ( GString *, gsize )

IMPORT_C GString *g_string_set_size(GString *string,
gsizelen
)

g_string_set_size: : a GString : the new length

Sets the length of a GString. If the length is less than the current length, the string will be truncated. If the length is greater than the current length, the contents of the newly added area are undefined. (However, as always, string->str[string->len] will be a nul byte.)

Return value:

g_string_insert_len ( GString *, gssize, const gchar *, gssize )

IMPORT_C GString *g_string_insert_len(GString *string,
gssizepos,
const gchar *val,
gssizelen
)

g_string_insert_len: : a GString : position in where insertion should happen, or -1 for at the end : bytes to insert : number of bytes of to insert

Inserts bytes of into at . Because is provided, may contain embedded nuls and need not be nul-terminated. If is -1, bytes are inserted at the end of the string.

Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that has at least addressable bytes.

Returns:

g_string_append ( GString *, const gchar * )

IMPORT_C GString *g_string_append(GString *string,
const gchar *val
)

g_string_append: : a GString : the string to append onto the end of

Adds a string onto the end of a GString, expanding it if necessary.

Returns:

g_string_append_len ( GString *, const gchar *, gssize )

IMPORT_C GString *g_string_append_len(GString *string,
const gchar *val,
gssizelen
)

g_string_append_len: : a GString : bytes to append : number of bytes of to use

Appends bytes of to . Because is provided, may contain embedded nuls and need not be nul-terminated.

Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that has at least addressable bytes.

Returns:

g_string_append_c ( GString *, gchar )

IMPORT_C GString *g_string_append_c(GString *string,
gcharc
)

g_string_append_c: : a GString : the byte to append onto the end of

Adds a byte onto the end of a GString, expanding it if necessary.

Returns:

g_string_append_unichar ( GString *, gunichar )

IMPORT_C GString *g_string_append_unichar(GString *string,
gunicharwc
)

g_string_append_unichar: : a GString : a Unicode character

Converts a Unicode character into UTF-8, and appends it to the string.

Return value:

g_string_prepend ( GString *, const gchar * )

IMPORT_C GString *g_string_prepend(GString *string,
const gchar *val
)

g_string_prepend: : a GString : the string to prepend on the start of

Adds a string on to the start of a GString, expanding it if necessary.

Returns:

g_string_prepend_c ( GString *, gchar )

IMPORT_C GString *g_string_prepend_c(GString *string,
gcharc
)

g_string_prepend_c: : a GString : the byte to prepend on the start of the GString

Adds a byte onto the start of a GString, expanding it if necessary.

Returns:

g_string_prepend_unichar ( GString *, gunichar )

IMPORT_C GString *g_string_prepend_unichar(GString *string,
gunicharwc
)

g_string_prepend_unichar: : a GString : a Unicode character

Converts a Unicode character into UTF-8, and prepends it to the string.

Return value:

g_string_prepend_len ( GString *, const gchar *, gssize )

IMPORT_C GString *g_string_prepend_len(GString *string,
const gchar *val,
gssizelen
)

g_string_prepend_len: : a GString : bytes to prepend : number of bytes in to prepend

Prepends bytes of to . Because is provided, may contain embedded nuls and need not be nul-terminated.

Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that has at least addressable bytes.

Returns:

g_string_insert ( GString *, gssize, const gchar * )

IMPORT_C GString *g_string_insert(GString *string,
gssizepos,
const gchar *val
)

g_string_insert: : a GString : the position to insert the copy of the string : the string to insert

Inserts a copy of a string into a GString, expanding it if necessary.

Returns:

g_string_insert_c ( GString *, gssize, gchar )

IMPORT_C GString *g_string_insert_c(GString *string,
gssizepos,
gcharc
)

g_string_insert_c: : a GString : the position to insert the byte : the byte to insert

Inserts a byte into a GString, expanding it if necessary.

Returns:

g_string_insert_unichar ( GString *, gssize, gunichar )

IMPORT_C GString *g_string_insert_unichar(GString *string,
gssizepos,
gunicharwc
)

g_string_insert_unichar: : a GString : the position at which to insert character, or -1 to append at the end of the string : a Unicode character

Converts a Unicode character into UTF-8, and insert it into the string at the given position.

Return value:

g_string_overwrite ( GString *, gsize, const gchar * )

IMPORT_C GString *g_string_overwrite(GString *string,
gsizepos,
const gchar *val
)

g_string_overwrite: : a GString : the position at which to start overwriting : the string that will overwrite the starting at

Overwrites part of a string, lengthening it if necessary.

Return value:

Since: 2.14

g_string_overwrite_len ( GString *, gsize, const gchar *, gssize )

IMPORT_C GString *g_string_overwrite_len(GString *string,
gsizepos,
const gchar *val,
gssizelen
)

g_string_overwrite_len: : a GString : the position at which to start overwriting : the string that will overwrite the starting at : the number of bytes to write from

Overwrites part of a string, lengthening it if necessary. This function will work with embedded nuls.

Return value:

Since: 2.14

g_string_erase ( GString *, gssize, gssize )

IMPORT_C GString *g_string_erase(GString *string,
gssizepos,
gssizelen
)

g_string_erase: : a GString : the position of the content to remove : the number of bytes to remove, or -1 to remove all following bytes

Removes bytes from a GString, starting at position . The rest of the GString is shifted down to fill the gap.

Returns:

g_string_ascii_down ( GString * )

IMPORT_C GString *g_string_ascii_down(GString *string)

g_string_ascii_down: : a GString

Converts all upper case ASCII letters to lower case ASCII letters.

Return value: passed-in pointer, with all the upper case characters converted to lower case in place, with semantics that exactly match g_ascii_tolower().

g_string_ascii_up ( GString * )

IMPORT_C GString *g_string_ascii_up(GString *string)

g_string_ascii_up: : a GString

Converts all lower case ASCII letters to upper case ASCII letters.

Return value: passed-in pointer, with all the lower case characters converted to upper case in place, with semantics that exactly match g_ascii_toupper().

g_string_vprintf ( GString *, const gchar *, va_list )

IMPORT_C voidg_string_vprintf(GString *string,
const gchar *format,
va_listargs
)

g_string_vprintf: : a GString : the string format. See the printf() documentation : the parameters to insert into the format string

Writes a formatted string into a GString. This function is similar to g_string_printf() except that the arguments to the format string are passed as a va_list.

Since: 2.14

g_string_printf ( GString *, const gchar *, ... )

IMPORT_C voidg_string_printf(GString *string,
const gchar *format,
...
)

g_string_append_vprintf ( GString *, const gchar *, va_list )

IMPORT_C void IMPORT_C voidg_string_append_vprintf(GString *string,
const gchar *format,
va_listargs
)

g_string_append_vprintf: : a GString : the string format. See the printf() documentation : the list of arguments to insert in the output

Appends a formatted string onto the end of a GString. This function is similar to g_string_append_printf() except that the arguments to the format string are passed as a va_list.

Since: 2.14

g_string_append_printf ( GString *, const gchar *, ... )

IMPORT_C voidg_string_append_printf(GString *string,
const gchar *format,
...
)

g_string_append_uri_escaped ( GString *, const char *, const char *, gboolean )

IMPORT_C void IMPORT_C GString *g_string_append_uri_escaped(GString *string,
const char *unescaped,
const char *reserved_chars_allowed,
gbooleanallow_utf8
)

g_string_append_uri_escaped: : a GString : a string : a string of reserved characters allowed to be used : set TRUE if the escaped string may include UTF8 characters

Appends to , escaped any characters that are reserved in URIs using URI-style escape sequences.

Returns:

Since: 2.16

g_string_down ( GString * )

IMPORT_C GString *g_string_down(GString *string)

g_string_down: : a GString

Converts a GString to lowercase.

Returns: the GString.

Deprecated:2.2: This function uses the locale-specific tolower() function, which is almost never the right thing. Use g_string_ascii_down() or g_utf8_strdown() instead.

g_string_up ( GString * )

IMPORT_C GString *g_string_up(GString *string)

g_string_up: : a GString

Converts a GString to uppercase.

Return value:

Deprecated:2.2: This function uses the locale-specific toupper() function, which is almost never the right thing. Use g_string_ascii_up() or g_utf8_strup() instead.

g_string_sprintf

g_string_sprintfa