X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=docs%2Freference%2Fglib%2Ftmpl%2Fstrings.sgml;h=8a35eeb2ec5b2918754c72cd5047d8125a3f88cf;hb=9090c67afc1aea46e2bc2ccd18574a52f9d52bec;hp=c9167c23e1efd03e03d0e69984e24db6536879a3;hpb=19f04a9024d48c9524604bc8097c2527b1675b98;p=platform%2Fupstream%2Fglib.git diff --git a/docs/reference/glib/tmpl/strings.sgml b/docs/reference/glib/tmpl/strings.sgml index c9167c2..8a35eeb 100644 --- a/docs/reference/glib/tmpl/strings.sgml +++ b/docs/reference/glib/tmpl/strings.sgml @@ -2,185 +2,295 @@ Strings - +text buffers which grow automatically as text is added. - +A #GString is similar to a standard C string, except that it grows automatically +as text is appended or inserted. Also, it stores the length of the string, so +can be used for binary data with embedded nul bytes. - + + - +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 byte. + + +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. @str: @len: +@allocated_len: +Creates a new #GString, initialized with the given string. + + +@init: the initial text to copy into the string. +@Returns: the new #GString. + + + +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. -@init: -@Returns: +@init: initial contents of string. +@len: length of @init to use. +@Returns: a new #GString. - +Creates a new #GString, with enough space for @dfl_size 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. -@dfl_size: -@Returns: +@dfl_size: the default size of the space allocated to hold the string. +@Returns: the new #GString. - +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. -@string: -@rval: -@Returns: +@string: the destination #GString. Its current contents are destroyed. +@rval: the string to copy into @string +@Returns: the destination #GString. + +@val: the string to copy into @string. - + +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. + + +@Deprecated: This function has been renamed to g_string_printf(). + +@string: a #GString. +@format: the string format. See the sprintf() documentation. +@Varargs: the parameters to insert into the format string. + + + +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. -@string: -@format: -@Varargs: +@Deprecated: This function has been renamed to g_string_append_printf(). + +@string: a #GString. +@format: the string format. See the sprintf() documentation. +@Varargs: the parameters to insert into the format string. - + +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. + + +@string: a #GString. +@format: the string format. See the printf() documentation. +@Varargs: the parameters to insert into the format string. + + + +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. -@string: -@format: -@Varargs: +@string: a #GString. +@format: the string format. See the printf() documentation. +@Varargs: the parameters to insert into the format string. - +Adds a string onto the end of a #GString, expanding it if necessary. -@string: -@val: -@Returns: +@string: a #GString. +@val: the string to append onto the end of the #GString. +@Returns: the #GString. +Adds a byte onto the end of a #GString, expanding it if necessary. + + +@string: a #GString. +@c: the byte to append onto the end of the #GString. +@Returns: the #GString. + + + + @string: -@c: +@wc: @Returns: - +Appends @len bytes of @val to @string. Because @len is provided, +@val may contain embedded nuls and need not be nul-terminated. -@string: -@val: -@len: -@Returns: +@string: a #GString. +@val: bytes to append. +@len: number of bytes of @val to use. +@Returns: the #GString. - +Adds a string on to the start of a #GString, expanding it if necessary. -@string: -@val: -@Returns: +@string: a #GString. +@val: the string to prepend on the start of the #GString. +@Returns: the #GString. +Adds a byte onto the start of a #GString, expanding it if necessary. + + +@string: a #GString. +@c: the byte to prepend on the start of the #GString. +@Returns: the #GString. + + + + @string: -@c: +@wc: @Returns: - +Prepends @len bytes of @val to @string. Because @len is provided, +@val may contain embedded nuls and need not be nul-terminated. -@string: -@val: -@len: -@Returns: +@string: a #GString. +@val: bytes to prepend. +@len: number of bytes in @val to prepend. +@Returns: the #GString passed in. - +Inserts a copy of a string into a #GString, expanding it if necessary. -@string: -@pos: -@val: -@Returns: +@string: a #GString. +@pos: the position to insert the copy of the string. +@val: the string to insert. +@Returns: the #GString. +Inserts a byte into a #GString, expanding it if necessary. + + +@string: a #GString. +@pos: the position to insert the byte. +@c: the byte to insert. +@Returns: the #GString. + + + + @string: @pos: -@c: +@wc: @Returns: - +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. -@string: -@pos: -@val: -@len: -@Returns: +@string: a #GString. +@pos: position in @string where insertion should happen, or -1 for at the end. +@val: bytes to insert. +@len: number of bytes of @val to insert. +@Returns: the #GString. - +Removes @len bytes from a #GString, starting at position @pos. +The rest of the #GString is shifted down to fill the gap. -@string: -@pos: -@len: -@Returns: +@string: a #GString. +@pos: the position of the content to remove. +@len: the number of bytes to remove, or -1 to remove all + following bytes. +@Returns: the #GString. +Cuts off the end of the GString, leaving the first @len bytes. + + +@string: a #GString. +@len: the new size of the #GString. +@Returns: the #GString. + + + + @@ -191,17 +301,17 @@ Strings - +Frees the memory allocated for the #GString. +If @free_segment is %TRUE it also frees the character data. -@string: -@free_segment: -@Returns: +@string: a #GString. +@free_segment: if %TRUE the actual character data is freed as well. +@Returns: the character data of @string (i.e. %NULL if @free_segment is %TRUE) - @string: @@ -210,7 +320,6 @@ Strings - @string: @@ -219,20 +328,21 @@ Strings - +Creates a hash code for @str; for use with #GHashTable. -@str: -@Returns: +@str: a string to hash. +@Returns: hash code for @str. - +Compares two strings for equality, returning %TRUE if they are equal. +For use with #GHashTable. -@v: -@v2: -@Returns: +@v: a #GString. +@v2: another #GString. +@Returns: %TRUE if they strings are the same length and contain the same bytes.