the number of bytes that can be stored in the
string before it needs to be reallocated. May be larger than len
.
contains the length of the string, not including the terminating nul byte.
points to the character data. It may move as text is added.
The str
field is null-terminated and so
can be used as an ordinary C string.
Appends len
bytes of val
to string
.
If len
is positive, val
may contain embedded nuls and need
not be nul-terminated. It is the caller's responsibility to
ensure that val
has at least len
addressable bytes.
If len
is negative, val
must be nul-terminated and len
is considered to request the entire string length. This
makes g_string_append_len() equivalent to g_string_append().
bytes to append
number of bytes of val
to use, or -1 for all of val
Appends unescaped
to string,
escaping any characters that
are reserved in URIs using URI-style escape sequences.
a string
a string of reserved characters allowed to be used, or %NULL
set %TRUE if the escaped string may include UTF8 characters
Frees the memory allocated for the #GString.
If free_segment
is %TRUE it also frees the character data. If
it's %FALSE, the caller gains ownership of the buffer and must
free it after use with g_free().
if %TRUE, the actual character data is freed as well
Transfers ownership of the contents of string
to a newly allocated
#GBytes. The #GString structure itself is deallocated, and it is
therefore invalid to use string
after invoking this function.
Note that while #GString ensures that its buffer always has a trailing nul character (not reflected in its "len"), the returned #GBytes does not include this extra nul; i.e. it has length exactly equal to the "len" member.
Creates a hash code for str;
for use with #GHashTable.
Inserts len
bytes of val
into string
at pos
.
If len
is positive, val
may contain embedded nuls and need
not be nul-terminated. It is the caller's responsibility to
ensure that val
has at least len
addressable bytes.
If len
is negative, val
must be nul-terminated and len
is considered to request the entire string length.
If pos
is -1, bytes are inserted at the end of the string.
position in string
where insertion should happen, or -1 for at the end
bytes to insert
number of bytes of val
to insert, or -1 for all of val
Overwrites part of a string, lengthening it if necessary. This function will work with embedded nuls.
the position at which to start overwriting
the string that will overwrite the string
starting at pos
the number of bytes to write from val
Prepends len
bytes of val
to string
.
If len
is positive, val
may contain embedded nuls and need
not be nul-terminated. It is the caller's responsibility to
ensure that val
has at least len
addressable bytes.
If len
is negative, val
must be nul-terminated and len
is considered to request the entire string length. This
makes g_string_prepend_len() equivalent to g_string_prepend().
bytes to prepend
number of bytes in val
to prepend, or -1 for all of val
Replaces the string find
with the string replace
in a #GString up to
limit
times. If the number of instances of find
in the #GString is
less than limit,
all instances are replaced. If limit
is 0
,
all instances of find
are replaced.
If find
is the empty string, since versions 2.69.1 and 2.68.4 the
replacement will be inserted no more than once per possible position
(beginning of string, end of string and between characters). This did
not work correctly in earlier versions.
the string to find in string
the string to insert in place of find
the maximum instances of find
to replace with replace,
or 0
for no limit
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.)
the new length
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.
Since this function does not stop at nul bytes, it is the caller's
responsibility to ensure that init
has at least len
addressable
bytes.
initial contents of the string
length of init
to use
The GString struct contains the public fields of a GString.