Details
struct GString
struct GString
{
gchar *str;
gsize len;
gsize allocated_len;
};
|
The GString struct contains the public fields of a GString.
The str field points to the character data.
It may move as text is added.
The len field contains the length of the string,
not including the terminating nul character.
The str field is nul-terminated and so can be used as an ordinary C
string. But it may be moved when text is appended or inserted into the
string.
g_string_new ()
Creates a new GString, initialized with the given string.
g_string_new_len ()
Creates a new GString with len bytes of the init buffer. Because a length is
provided, init need not be nul-terminated, and can contain embedded nul bytes.
g_string_sized_new ()
Creates a new GString, with enough space for dfl_size characters.
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.
g_string_assign ()
Copies the characters 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.
g_string_sprintf
Warning |
g_string_sprintf is deprecated and should not be used in newly-written code.
|
Writes a formatted string into a GString.
This is similar to the standard sprintf() function,
except that the GString buffer automatically expands to contain the results.
The previous contents of the GString are destroyed. This
function has been renamaed to g_string_printf().
g_string_sprintfa
#define g_string_sprintfa |
Warning |
g_string_sprintfa is deprecated and should not be used in newly-written code.
|
Appends a formatted string onto the end of a GString.
This function is is similar to g_string_sprintf() except that
the text is appended to the GString. The function has been
renamed to g_string_append_printf().
g_string_printf ()
void g_string_printf (GString *string,
const gchar *format,
...); |
Writes a formatted string into a GString.
This is similar to the standard sprintf() function,
except that the GString buffer automatically expands to contain the results.
The previous contents of the GString are destroyed.
g_string_append_printf ()
void g_string_append_printf (GString *string,
const gchar *format,
...); |
Appends a formatted string onto the end of a GString.
This function is is similar to g_string_printf() except that
the text is appended to the GString.
g_string_append ()
Adds a string onto the end of a GString, expanding it if necessary.
g_string_append_c ()
Adds a character onto the end of a GString, expanding it if necessary.
g_string_append_unichar ()
Converts a Unicode character into UTF-8, and appends it
to the string.
g_string_append_len ()
Appends len bytes of val to string. Because len is provided,
val may contain embedded nuls and need not be nul-terminated.
g_string_prepend ()
Adds a string on to the start of a GString, expanding it if necessary.
g_string_prepend_c ()
Adds a character onto the start of a GString, expanding it if necessary.
g_string_prepend_unichar ()
Converts a Unicode character into UTF-8, and prepends it
to the string.
g_string_prepend_len ()
Prepends len bytes of val to string. Because len is provided,
val may contain embedded nuls and need not be nul-terminated.
g_string_insert ()
Inserts a copy of a string into a GString, expanding it if necessary.
g_string_insert_c ()
Inserts a character into a GString, expanding it if necessary.
g_string_insert_unichar ()
Converts a Unicode character into UTF-8, and insert it
into the string at the given position.
g_string_insert_len ()
Inserts len bytes of val into string at pos. Because len is provided, val
may contain embedded nuls and need not be nul-terminated. If pos is -1, bytes are inserted at the end of the string.
g_string_erase ()
Removes len characters from a GString, starting at position pos.
The rest of the GString is shifted down to fill the gap.
g_string_truncate ()
Cuts off the end of the GString, leaving the first len characters.
g_string_set_size ()
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.)
g_string_free ()
Frees the memory allocated for the GString.
If free_segment is TRUE it also frees the character data.
g_string_up ()
Warning |
g_string_up is deprecated and should not be used in newly-written code.
|
Converts a GString to upper case.
g_string_down ()
Warning |
g_string_down is deprecated and should not be used in newly-written code.
|
Converts a GString to lower case.
g_string_hash ()
Creates a hash code for str; for use with GHashTable.
g_string_equal ()
Compares two strings for equality, returning TRUE if they are equal.
For use with GHashTable.