GLib.StrvBuilder

Fields

None

Methods

class

new ()

add (value)

addv (value)

end ()

ref ()

take (value)

unref ()

Details

class GLib.StrvBuilder

GStrvBuilder is a helper object to build a None-terminated string arrays.

The following example shows how to build a two element array:

``c

g_autoptr(GStrvBuilder) builder = g_strv_builder_new (); g_strv_builder_add (builder, “hello”); g_strv_builder_add (builder, “world”); g_auto(GStrv) array = g_strv_builder_end (builder);

``

New in version 2.68.

classmethod new()[source]
Returns:

the new GLib.StrvBuilder

Return type:

GLib.StrvBuilder

Creates a new GLib.StrvBuilder with a reference count of 1. Use GLib.StrvBuilder.unref() on the returned value when no longer needed.

New in version 2.68.

add(value)[source]
Parameters:

value (str) – a string.

Add a string to the end of the array.

New in version 2.68.

addv(value)[source]
Parameters:

value ([str]) – the vector of strings to add

Appends all the strings in the given vector to the builder.

New in version 2.70.

end()[source]
Returns:

the constructed string array.

Return type:

[str]

Ends the builder process and returns the constructed None-terminated string array. The returned value should be freed with GLib.strfreev() when no longer needed.

ref()[source]
Returns:

The passed in GLib.StrvBuilder

Return type:

GLib.StrvBuilder

Atomically increments the reference count of self by one. This function is thread-safe and may be called from any thread.

New in version 2.68.

take(value)[source]
Parameters:

value (str) – a string. Ownership of the string is transferred to the GLib.StrvBuilder

Add a string to the end of the array. After value belongs to the GLib.StrvBuilder and may no longer be modified by the caller.

New in version 2.80.

unref()[source]

Decreases the reference count on self.

In the event that there are no more references, releases all memory associated with the GLib.StrvBuilder.

New in version 2.68.