:right-sidebar: True StrvBuilder =================================================================== .. currentmodule:: gi.repository.GLib .. versionadded:: 2.68 .. class:: StrvBuilder(**kwargs) :no-contents-entry: ``GStrvBuilder`` is a helper object to build a :const:`None`-terminated string arrays. The following example shows how to build a two element array: .. code-block:: c :dedent: 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); g_assert_true (g_strv_equal (array, (const char *[]) { "hello", "world", NULL })); Constructors ------------ .. rst-class:: interim-class .. class:: StrvBuilder :no-index: .. classmethod:: new() -> ~gi.repository.GLib.StrvBuilder Creates a new :obj:`~gi.repository.GLib.StrvBuilder` with a reference count of 1. Use :func:`~gi.repository.GLib.StrvBuilder.unref` on the returned value when no longer needed. .. versionadded:: 2.68 Methods ------- .. rst-class:: interim-class .. class:: StrvBuilder :no-index: .. method:: add(value: str) -> None Add a string to the end of the array. Since 2.68 :param value: a string. .. method:: addv(value: list[str]) -> None Appends all the strings in the given vector to the builder. Since 2.70 :param value: the vector of strings to add .. method:: end() -> list[str] Ends the builder process and returns the constructed NULL-terminated string array. The returned value should be freed with :func:`~gi.repository.GLib.strfreev` when no longer needed. .. method:: take(value: str) -> None Add a string to the end of the array. After ``value`` belongs to the :obj:`~gi.repository.GLib.StrvBuilder` and may no longer be modified by the caller. Since 2.80 :param value: a string. Ownership of the string is transferred to the :obj:`~gi.repository.GLib.StrvBuilder`