GIBaseInfo

## GIBaseInfo GIBaseInfo — Base struct for all GITypelib structs |

## Synopsis

    enum                GIInfoType;
    const gchar *       g_info_type_to_string               (GIInfoType type);
                        GIAttributeIter;
    typedef             GIBaseInfo;
    GIBaseInfo *        g_base_info_ref                     (GIBaseInfo *info);
    void                g_base_info_unref                   (GIBaseInfo *info);
    GIInfoType          g_base_info_get_type                (GIBaseInfo *info);
    const gchar *       g_base_info_get_name                (GIBaseInfo *info);
    const gchar *       g_base_info_get_namespace           (GIBaseInfo *info);
    gboolean            g_base_info_is_deprecated           (GIBaseInfo *info);
    const gchar *       g_base_info_get_attribute           (GIBaseInfo *info,
                                                             const gchar *name);
    gboolean            g_base_info_iterate_attributes      (GIBaseInfo *info,
                                                             GIAttributeIter *iterator,
                                                             char **name,
                                                             char **value);
    GIBaseInfo *        g_base_info_get_container           (GIBaseInfo *info);
    GITypelib *         g_base_info_get_typelib             (GIBaseInfo *info);
    gboolean            g_base_info_equal                   (GIBaseInfo *info1,
                                                             GIBaseInfo *info2);

## Description

GIBaseInfo is the common base struct of all other *Info structs accessible through the GIRepository API. All other structs can be casted to a GIBaseInfo, for instance:

Example 1. Casting a GIFunctionInfo to GIBaseInfo

    1
    2
    GIFunctionInfo *function_info = ...;
       GIBaseInfo *info = (GIBaseInfo*)function_info;

Most GIRepository APIs returning a GIBaseInfo is actually creating a new struct, in other words, `g_base_info_unref()` has to be called when done accessing the data. GIBaseInfos are normally accessed by calling either `g_irepository_find_by_name()`, `g_irepository_find_by_gtype()` or `g_irepository_get_info()`.

Example 2. Getting the Button of the Gtk typelib

    1
    2
    3
    GIBaseInfo *button_info = g_irepository_find_by_name(NULL, "Gtk", "Button");
       ... use button_info ...
       g_base_info_unref(button_info);

## Struct hierarchy

      GIBaseInfo
       +----GIArgInfo
       +----GICallableInfo
       +----GIConstantInfo
       +----GIFieldInfo
       +----GIPropertyInfo
       +----GIRegisteredTypeInfo
       +----GITypeInfo

## Details

### enum GIInfoType

    typedef enum {
      GI_INFO_TYPE_INVALID,
      GI_INFO_TYPE_FUNCTION,
      GI_INFO_TYPE_CALLBACK,
      GI_INFO_TYPE_STRUCT,
      GI_INFO_TYPE_BOXED,
      GI_INFO_TYPE_ENUM,         /*  5 */
      GI_INFO_TYPE_FLAGS,
      GI_INFO_TYPE_OBJECT,
      GI_INFO_TYPE_INTERFACE,
      GI_INFO_TYPE_CONSTANT,
      GI_INFO_TYPE_INVALID_0,    /* 10 */  /** DELETED - used to be ERROR_DOMAIN **/
      GI_INFO_TYPE_UNION,
      GI_INFO_TYPE_VALUE,
      GI_INFO_TYPE_SIGNAL,
      GI_INFO_TYPE_VFUNC,
      GI_INFO_TYPE_PROPERTY,     /* 15 */
      GI_INFO_TYPE_FIELD,
      GI_INFO_TYPE_ARG,
      GI_INFO_TYPE_TYPE,
      GI_INFO_TYPE_UNRESOLVED
    } GIInfoType;

The type of a GIBaseInfo struct.

`GI_INFO_TYPE_INVALID` | invalid type
`GI_INFO_TYPE_FUNCTION` | function, see GIFunctionInfo
`GI_INFO_TYPE_CALLBACK` | callback, see GIFunctionInfo
`GI_INFO_TYPE_STRUCT` | struct, see GIStructInfo
`GI_INFO_TYPE_BOXED` | boxed, see GIStructInfo or GIUnionInfo
`GI_INFO_TYPE_ENUM` | enum, see GIEnumInfo
`GI_INFO_TYPE_FLAGS` | flags, see GIEnumInfo
`GI_INFO_TYPE_OBJECT` | object, see GIObjectInfo
`GI_INFO_TYPE_INTERFACE` | interface, see GIInterfaceInfo
`GI_INFO_TYPE_CONSTANT` | contant, see GIConstantInfo
`GI_INFO_TYPE_INVALID_0` |
`GI_INFO_TYPE_UNION` | union, see GIUnionInfo
`GI_INFO_TYPE_VALUE` | enum value, see GIValueInfo
`GI_INFO_TYPE_SIGNAL` | signal, see GISignalInfo
`GI_INFO_TYPE_VFUNC` | virtual function, see GIVFuncInfo
`GI_INFO_TYPE_PROPERTY` | GObject property, see GIPropertyInfo
`GI_INFO_TYPE_FIELD` | struct or union field, see GIFieldInfo
`GI_INFO_TYPE_ARG` | argument of a function or callback, see GIArgInfo
`GI_INFO_TYPE_TYPE` | type information, see GITypeInfo
`GI_INFO_TYPE_UNRESOLVED` | unresolved type, a type which is not present in the typelib, or any of its dependencies.

### g_info_type_to_string ()

    const gchar *       g_info_type_to_string               (GIInfoType type);

Obtain a string representation of `type`

`type` : | the info type
Returns : | the string

### GIAttributeIter

    typedef struct {
    } GIAttributeIter;

An opaque structure used to iterate over attributes in a GIBaseInfo struct.

### GIBaseInfo

    typedef struct _GIBaseInfoStub GIBaseInfo;

### g_base_info_ref ()

    GIBaseInfo *        g_base_info_ref                     (GIBaseInfo *info);

Increases the reference count of `info`.

`info` : | a GIBaseInfo
Returns : | the same `info`.

### g_base_info_unref ()

    void                g_base_info_unref                   (GIBaseInfo *info);

Decreases the reference count of `info`. When its reference count drops to 0, the info is freed.

`info` : | a GIBaseInfo

### g_base_info_get_type ()

    GIInfoType          g_base_info_get_type                (GIBaseInfo *info);

Obtain the info type of the GIBaseInfo.

`info` : | a GIBaseInfo
Returns : | the info type of `info`

### g_base_info_get_name ()

    const gchar *       g_base_info_get_name                (GIBaseInfo *info);

Obtain the name of the `info`. What the name represents depends on the GIInfoType of the `info`. For instance for GIFunctionInfo it is the name of the function.

`info` : | a GIBaseInfo
Returns : | the name of `info` or `NULL` if it lacks a name.

### g_base_info_get_namespace ()

    const gchar *       g_base_info_get_namespace           (GIBaseInfo *info);

Obtain the namespace of `info`.

`info` : | a GIBaseInfo
Returns : | the namespace

### g_base_info_is_deprecated ()

    gboolean            g_base_info_is_deprecated           (GIBaseInfo *info);

Obtain whether the `info` is represents a metadata which is deprecated or not.

`info` : | a GIBaseInfo
Returns : | `TRUE` if deprecated

### g_base_info_get_attribute ()

    const gchar *       g_base_info_get_attribute           (GIBaseInfo *info,
                                                             const gchar *name);

Retrieve an arbitrary attribute associated with this node.

`info` : | a GIBaseInfo
`name` : | a freeform string naming an attribute
Returns : | The value of the attribute, or `NULL` if no such attribute exists

### g_base_info_iterate_attributes ()

    gboolean            g_base_info_iterate_attributes      (GIBaseInfo *info,
                                                             GIAttributeIter *iterator,
                                                             char **name,
                                                             char **value);

Iterate over all attributes associated with this node. The iterator structure is typically stack allocated, and must have its first member initialized to `NULL`.

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

Example 3. Iterating over attributes

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    void
    print_attributes (GIBaseInfo *info)
    {
      GIAttributeIter iter = { 0, };
      char *name;
      char *value;
      while (g_base_info_iterate_attributes (info, &iter, &name, &value))
        {
          g_print ("attribute name: %s value: %s", name, value);
        }
    }

`info` : | a GIBaseInfo
`iterator` : | a GIAttributeIter structure, must be initialized; see below
`name` : | Returned name, must not be freed. [out][transfer none]
`value` : | Returned name, must not be freed. [out][transfer none]
Returns : | `TRUE` if there are more attributes

### g_base_info_get_container ()

    GIBaseInfo *        g_base_info_get_container           (GIBaseInfo *info);

Obtain the container of the `info`. The container is the parent GIBaseInfo. For instance, the parent of a GIFunctionInfo is an GIObjectInfo or GIInterfaceInfo.

`info` : | a GIBaseInfo
Returns : | the container. [transfer none]

### g_base_info_get_typelib ()

    GITypelib *         g_base_info_get_typelib             (GIBaseInfo *info);

Obtain the typelib this `info` belongs to

`info` : | a GIBaseInfo
Returns : | the typelib. [transfer none]

### g_base_info_equal ()

    gboolean            g_base_info_equal                   (GIBaseInfo *info1,
                                                             GIBaseInfo *info2);

Compare two GIBaseInfo.

Using pointer comparison is not practical since many functions return different instances of GIBaseInfo that refers to the same part of the TypeLib; use this function instead to do GIBaseInfo comparisons.

`info1` : | a GIBaseInfo
`info2` : | a GIBaseInfo
Returns : | `TRUE` if and only if `info1` equals `info2`.