Glib.String

Entities

Record Types

Subprograms

Description

The GString struct contains the public fields of a GString.

Append

function Append (Self : Gstring; Val : UTF8_String) return Gstring

Adds a string onto the end of a Glib.String.Gstring, expanding it if necessary.

Parameters
Self
Val

the string to append onto the end of String

Return Value

String

Append_C

function Append_C (Self : Gstring; C : Gchar) return Gstring

Adds a byte onto the end of a Glib.String.Gstring, expanding it if necessary.

Parameters
Self
C

the byte to append onto the end of String

Return Value

String

Append_Len

function Append_Len
   (Self : Gstring;
    Val  : UTF8_String;
    Len  : Gssize) return Gstring

Appends Len bytes of Val to String. Because Len is provided, Val 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 Val has at least Len addressable bytes.

Parameters
Self
Val

bytes to append

Len

number of bytes of Val to use

Return Value

String

Append_Unichar

function Append_Unichar (Self : Gstring; Wc : Gunichar) return Gstring

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

Parameters
Self
Wc

a Unicode character

Return Value

String

Append_Uri_Escaped

function Append_Uri_Escaped
   (Self                   : Gstring;
    Unescaped              : UTF8_String;
    Reserved_Chars_Allowed : UTF8_String;
    Allow_Utf8             : Boolean) return Gstring

Appends Unescaped to String, escaped any characters that are reserved in URIs using URI-style escape sequences. Since: gtk+ 2.16

Parameters
Self
Unescaped

a string

Reserved_Chars_Allowed

a string of reserved characters allowed to be used, or null

Allow_Utf8

set True if the escaped string may include UTF8 characters

Return Value

String

Ascii_Down

function Ascii_Down (Self : Gstring) return Gstring

Converts all uppercase ASCII letters to lowercase ASCII letters.

Parameters
Self
Return Value

passed-in String pointer, with all the uppercase characters converted to lowercase in place, with semantics that exactly match g_ascii_tolower.

Ascii_Up

function Ascii_Up (Self : Gstring) return Gstring

Converts all lowercase ASCII letters to uppercase ASCII letters.

Parameters
Self
Return Value

passed-in String pointer, with all the lowercase characters converted to uppercase in place, with semantics that exactly match g_ascii_toupper.

Assign

function Assign (Self : Gstring; Rval : UTF8_String) return Gstring

Copies the bytes from a string into a Glib.String.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
Self
Rval

the string to copy into String

Return Value

String

Down

function Down (Self : Gstring) return Gstring

Converts a Glib.String.Gstring to lowercase. Deprecated since 2.2, 1

Parameters
Self
Return Value

the Glib.String.Gstring

Equal

function Equal (Self : Gstring; V2 : Gstring) return Boolean

Compares two strings for equality, returning True if they are equal. For use with GHash_Table.

Parameters
Self
V2

another Glib.String.Gstring

Return Value

True if the strings are the same length and contain the same bytes

Erase

function Erase
   (Self : Gstring;
    Pos  : Gssize;
    Len  : Gssize) return Gstring

Removes Len bytes from a Glib.String.Gstring, starting at position Pos. The rest of the Glib.String.Gstring is shifted down to fill the gap.

Parameters
Self
Pos

the position of the content to remove

Len

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

Return Value

String

Free

function Free (Self : Gstring; Free_Segment : Boolean) return UTF8_String

Frees the memory allocated for the Glib.String.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
Self
Free_Segment

if True, the actual character data is freed as well

Return Value

the character data of String (i.e. null if Free_Segment is True)

From_Object_Free

function From_Object_Free (B : access Gstring) return Gstring

The GString struct contains the public fields of a GString.

Parameters
B
Return Value

Get_Type

function Get_Type return Glib.GType
Return Value

Gstring

type Gstring is record
   Str : Gtkada.Types.Chars_Ptr;
   Len : Gsize;
   Allocated_Len : Gsize;
end record;
Record fields
Str
Len
Allocated_Len

Hash

function Hash (Self : Gstring) return Guint

Creates a hash code for Str; for use with GHash_Table.

Parameters
Self
Return Value

hash code for Str

Insert

function Insert
   (Self : Gstring;
    Pos  : Gssize;
    Val  : UTF8_String) return Gstring

Inserts a copy of a string into a Glib.String.Gstring, expanding it if necessary.

Parameters
Self
Pos

the position to insert the copy of the string

Val

the string to insert

Return Value

String

Insert_C

function Insert_C
   (Self : Gstring;
    Pos  : Gssize;
    C    : Gchar) return Gstring

Inserts a byte into a Glib.String.Gstring, expanding it if necessary.

Parameters
Self
Pos

the position to insert the byte

C

the byte to insert

Return Value

String

Insert_Len

function Insert_Len
   (Self : Gstring;
    Pos  : Gssize;
    Val  : UTF8_String;
    Len  : Gssize) return Gstring

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. Since this function does not stop at nul bytes, it is the caller's responsibility to ensure that Val has at least Len addressable bytes.

Parameters
Self
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

Return Value

String

Insert_Unichar

function Insert_Unichar
   (Self : Gstring;
    Pos  : Gssize;
    Wc   : Gunichar) return Gstring

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

Parameters
Self
Pos

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

Wc

a Unicode character

Return Value

String

Overwrite

function Overwrite
   (Self : Gstring;
    Pos  : Gsize;
    Val  : UTF8_String) return Gstring

Overwrites part of a string, lengthening it if necessary. Since: gtk+ 2.14

Parameters
Self
Pos

the position at which to start overwriting

Val

the string that will overwrite the String starting at Pos

Return Value

String

Overwrite_Len

function Overwrite_Len
   (Self : Gstring;
    Pos  : Gsize;
    Val  : UTF8_String;
    Len  : Gssize) return Gstring

Overwrites part of a string, lengthening it if necessary. This function will work with embedded nuls. Since: gtk+ 2.14

Parameters
Self
Pos

the position at which to start overwriting

Val

the string that will overwrite the String starting at Pos

Len

the number of bytes to write from Val

Return Value

String

Prepend

function Prepend (Self : Gstring; Val : UTF8_String) return Gstring

Adds a string on to the start of a Glib.String.Gstring, expanding it if necessary.

Parameters
Self
Val

the string to prepend on the start of String

Return Value

String

Prepend_C

function Prepend_C (Self : Gstring; C : Gchar) return Gstring

Adds a byte onto the start of a Glib.String.Gstring, expanding it if necessary.

Parameters
Self
C

the byte to prepend on the start of the Glib.String.Gstring

Return Value

String

Prepend_Len

function Prepend_Len
   (Self : Gstring;
    Val  : UTF8_String;
    Len  : Gssize) return Gstring

Prepends Len bytes of Val to String. Because Len is provided, Val 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 Val has at least Len addressable bytes.

Parameters
Self
Val

bytes to prepend

Len

number of bytes in Val to prepend

Return Value

String

Prepend_Unichar

function Prepend_Unichar (Self : Gstring; Wc : Gunichar) return Gstring

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

Parameters
Self
Wc

a Unicode character

Return Value

String

Set_Size

function Set_Size (Self : Gstring; Len : Gsize) return Gstring

Sets the length of a Glib.String.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
Self
Len

the new length

Return Value

String

Truncate

function Truncate (Self : Gstring; Len : Gsize) return Gstring

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

Parameters
Self
Len

the new size of String

Return Value

String

Up

function Up (Self : Gstring) return Gstring

Converts a Glib.String.Gstring to uppercase. Deprecated since 2.2, 1

Parameters
Self
Return Value

String