Gjsify LogoGjsify Logo

The GString struct contains the public fields of a GString.

record

Hierarchy

  • String

Index

Constructors

  • Creates a new #GString, initialized with the given string.

    Parameters

    • init: string

      the initial text to copy into the string, or %NULL to start with an empty string

    Returns GLib.String

Properties

allocated_len: number

the number of bytes that can be stored in the string before it needs to be reallocated. May be larger than len.

field
len: number

contains the length of the string, not including the terminating nul byte.

field
str: string

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.

field
name: string

Methods

  • 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().

    Parameters

    • val: string

      bytes to append

    • len: number

      number of bytes of val to use, or -1 for all of val

    Returns GLib.String

  • append_uri_escaped(unescaped: string, reserved_chars_allowed: string, allow_utf8: boolean): GLib.String
  • Appends unescaped to string, escaping any characters that are reserved in URIs using URI-style escape sequences.

    Parameters

    • unescaped: string

      a string

    • reserved_chars_allowed: string

      a string of reserved characters allowed to be used, or %NULL

    • allow_utf8: boolean

      set %TRUE if the escaped string may include UTF8 characters

    Returns GLib.String

  • 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.

    Parameters

    • rval: string

      the string to copy into string

    Returns GLib.String

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

    Parameters

    • pos: number

      the position of the content to remove

    • len: number

      the number of bytes to remove, or -1 to remove all following bytes

    Returns GLib.String

  • free(free_segment: boolean): string
  • 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().

    Parameters

    • free_segment: boolean

      if %TRUE, the actual character data is freed as well

    Returns string

  • 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.

    Returns Bytes

  • hash(): number
  • Inserts a copy of a string into a #GString, expanding it if necessary.

    Parameters

    • pos: number

      the position to insert the copy of the string

    • val: string

      the string to insert

    Returns GLib.String

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

    Parameters

    • pos: number

      the position to insert the byte

    • c: number

      the byte to insert

    Returns GLib.String

  • insert_len(pos: number, val: string, len: number): GLib.String
  • 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.

    Parameters

    • pos: number

      position in string where insertion should happen, or -1 for at the end

    • val: string

      bytes to insert

    • len: number

      number of bytes of val to insert, or -1 for all of val

    Returns GLib.String

  • insert_unichar(pos: number, wc: string): GLib.String
  • Converts a Unicode character into UTF-8, and insert it into the string at the given position.

    Parameters

    • pos: number

      the position at which to insert character, or -1 to append at the end of the string

    • wc: string

      a Unicode character

    Returns GLib.String

  • Overwrites part of a string, lengthening it if necessary.

    Parameters

    • pos: number

      the position at which to start overwriting

    • val: string

      the string that will overwrite the string starting at pos

    Returns GLib.String

  • overwrite_len(pos: number, val: string, len: number): GLib.String
  • Overwrites part of a string, lengthening it if necessary. This function will work with embedded nuls.

    Parameters

    • pos: number

      the position at which to start overwriting

    • val: string

      the string that will overwrite the string starting at pos

    • len: number

      the number of bytes to write from val

    Returns GLib.String

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

    Parameters

    • val: string

      the string to prepend on the start of string

    Returns GLib.String

  • prepend_len(val: string, len: number): GLib.String
  • 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().

    Parameters

    • val: string

      bytes to prepend

    • len: number

      number of bytes in val to prepend, or -1 for all of val

    Returns GLib.String

  • replace(find: string, replace: string, limit: number): number
  • 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.

    Parameters

    • find: string

      the string to find in string

    • replace: string

      the string to insert in place of find

    • limit: number

      the maximum instances of find to replace with replace, or 0 for no limit

    Returns number

  • 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.)

    Parameters

    • len: number

      the new length

    Returns GLib.String

  • Creates a new #GString, initialized with the given string.

    Parameters

    • init: string

      the initial text to copy into the string, or %NULL to start with an empty string

    Returns GLib.String

  • 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.

    Parameters

    • init: string

      initial contents of the string

    • len: number

      length of init to use

    Returns GLib.String

  • 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.

    Parameters

    • dfl_size: number

      the default size of the space allocated to hold the string

    Returns GLib.String

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method