Method

GIRepositoryBaseInfoiterate_attributes

since: 2.80

Declaration

gboolean
gi_base_info_iterate_attributes (
  GIBaseInfo* info,
  GIAttributeIter* iterator,
  const char** name,
  const char** value
)

Description

Iterate over all attributes associated with this node.

The iterator structure is typically stack allocated, and must have its first member initialized to NULL. Attributes are arbitrary namespaced key–value pairs which can be attached to almost any item. They are intended for use by software higher in the toolchain than bindings, and are distinct from normal GIR annotations.

Both the name and value should be treated as constants and must not be freed.

void
print_attributes (GIBaseInfo *info)
{
  GIAttributeIter iter = GI_ATTRIBUTE_ITER_INIT;
  const char *name;
  const char *value;
  while (gi_base_info_iterate_attributes (info, &iter, &name, &value))
    {
      g_print ("attribute name: %s value: %s", name, value);
    }
}

Available since: 2.80

Parameters

iterator

Type: GIAttributeIter

A GIAttributeIter structure, must be initialized; see below.

The argument will be modified by the function.
The instance takes ownership of the data, and is responsible for freeing it.
name

Type: const char**

Returned name, must not be freed.

The argument will be set by the function.
The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.
value

Type: const char**

Returned name, must not be freed.

The argument will be set by the function.
The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.

Return value

Type: gboolean

TRUE if there are more attributes.