Add a boxed type for nul-terminated string arrays. (#110528)

Fri Jan  9 23:41:00 2004  Matthias Clasen  <maclas@gmx.de>

	* gboxed.h:
	* gboxed.c (g_strv_get_type): Add a boxed type for nul-terminated
	string arrays.  (#110528)
This commit is contained in:
Matthias Clasen 2004-01-09 22:39:55 +00:00 committed by Matthias Clasen
parent ba482c66c3
commit b4f769efaf
6 changed files with 67 additions and 1 deletions

View File

@ -1,3 +1,8 @@
Fri Jan 9 23:40:23 2004 Matthias Clasen <maclas@gmx.de>
* gobject/tmpl/gboxed.sgml:
* gobject/gobject-sections.txt: Add G_TYPE_STRV and GStrv.
Fri Dec 26 02:04:49 2003 Matthias Clasen <maclas@gmx.de>
* glib/glib-sections.txt: Add g_ptr_array_foreach().

View File

@ -291,12 +291,15 @@ g_pointer_type_register_static
<SUBSECTION>
G_TYPE_GSTRING
G_TYPE_STRV
GStrv
<SUBSECTION Standard>
G_TYPE_IS_BOXED
<SUBSECTION Private>
g_gstring_get_type
g_strv_get_type
</SECTION>
<SECTION>

View File

@ -82,3 +82,39 @@ The #GType for #GString.
<!-- ##### MACRO G_TYPE_STRV ##### -->
<para>
The #GType for a boxed type holding a %NULL-terminated array of strings.
</para>
<para>
The code fragments in the following example show the use of a property of
type #G_TYPE_STRV with g_object_class_install_property(), g_object_set()
and g_object_get().
</para>
<informalexample><programlisting>
g_object_class_install_property (object_class,
PROP_AUTHORS,
g_param_spec_boxed ("authors",
_("Authors"),
_("List of authors"),
G_TYPE_STRV,
G_PARAM_READWRITE));
gchar *authors[] = { "Owen", "Tim", NULL };
g_object_set (obj, "authors", authors, NULL);
gchar *writers[];
g_object_get (obj, "authors", &amp;writers, NULL);
/* do something with writers */
g_strfreev (writers);
</programlisting></informalexample>
@Since: 2.4
<!-- ##### TYPEDEF GStrv ##### -->
<para>
A C representable type name for #G_TYPE_STRV.
</para>

View File

@ -1,3 +1,9 @@
Fri Jan 9 23:41:00 2004 Matthias Clasen <maclas@gmx.de>
* gboxed.h:
* gboxed.c (g_strv_get_type): Add a boxed type for nul-terminated
string arrays. (#110528)
Fri Jan 9 15:34:15 2004 Tim Janik <timj@gtk.org>
* gtype.h: added convenience macros G_IMPLEMENT_INTERFACE() and

View File

@ -170,6 +170,18 @@ g_value_array_get_type (void)
return type_id;
}
GType
g_strv_get_type (void)
{
static GType type_id = 0;
if (!type_id)
type_id = g_boxed_type_register_static ("GStrv",
(GBoxedCopyFunc) g_strdupv,
(GBoxedFreeFunc) g_strfreev);
return type_id;
}
GType
g_gstring_get_type (void)
{

View File

@ -60,6 +60,7 @@ GType g_boxed_type_register_static (const gchar *name,
#define G_TYPE_CLOSURE (g_closure_get_type ())
#define G_TYPE_VALUE (g_value_get_type ())
#define G_TYPE_VALUE_ARRAY (g_value_array_get_type ())
#define G_TYPE_STRV (g_strv_get_type ())
#define G_TYPE_GSTRING (g_gstring_get_type ())
@ -72,7 +73,10 @@ void g_value_set_boxed_take_ownership (GValue *value,
GType g_closure_get_type (void) G_GNUC_CONST;
GType g_value_get_type (void) G_GNUC_CONST;
GType g_value_array_get_type (void) G_GNUC_CONST;
GType g_gstring_get_type (void) G_GNUC_CONST;
GType g_strv_get_type (void) G_GNUC_CONST;
GType g_gstring_get_type (void) G_GNUC_CONST;
typedef gchar** GStrv;
G_END_DECLS