GObject.Value
Description: Reference for GObject.Value

### Struct

# GObjectValue

#### Description [src]

    struct GValue {
      None data[2];
    }

An opaque structure used to hold different types of values.

Before it can be used, a `GValue` has to be initialized to a specific type by calling `g_value_init()` on it.

Many types which are stored within a `GValue` need to allocate data on the heap, so `g_value_unset()` must always be called on a `GValue` to free any such data once you’re finished with the `GValue`, even if the `GValue` itself is stored on the stack.

The data within the structure has protected scope: it is accessible only to functions within a `GTypeValueTable` structure, or implementations of the `g_value_*()` API. That is, code which implements new fundamental types.

`GValue` users cannot make any assumptions about how data is stored within the 2 element `data` union, and the `g_type` member should only be accessed through the `G_VALUE_TYPE()` macro and related macros.

###### Structure members

`data:` `None`

  No description available.

#### Functions

###### g_value_register_transform_func

Registers a value transformation function for use in `g_value_transform()`.

###### g_value_type_compatible

Checks whether a `g_value_copy()` is able to copy values of type `src_type` into values of type `dest_type`.

###### g_value_type_transformable

Checks whether `g_value_transform()` is able to transform values of type `src_type` into values of type `dest_type`.

#### Instance methods

###### g_value_copy

Copies the value of `src_value` into `dest_value`.

###### g_value_dup_boxed

Get the contents of a `G_TYPE_BOXED` derived `GValue`. Upon getting, the boxed value is duplicated and needs to be later freed with g_boxed_free(), e.g. like: g_boxed_free (G_VALUE_TYPE (`value`), return_value);.

###### g_value_dup_object

Get the contents of a `G_TYPE_OBJECT` derived `GValue`, increasing its reference count. If the contents of the `GValue` are `NULL`, then `NULL` will be returned.

###### g_value_dup_param

Get the contents of a `G_TYPE_PARAM` `GValue`, increasing its reference count.

###### g_value_dup_string

Get a copy the contents of a `G_TYPE_STRING` `GValue`.

###### g_value_dup_variant

Get the contents of a variant `GValue`, increasing its refcount. The returned `GVariant` is never floating.

since: 2.26

###### g_value_fits_pointer

Determines if `value` will fit inside the size of a pointer value.

###### g_value_get_boolean

Get the contents of a `G_TYPE_BOOLEAN` `GValue`.

###### g_value_get_boxed

Get the contents of a `G_TYPE_BOXED` derived `GValue`.

###### g_value_get_char

Do not use this function; it is broken on platforms where the %char type is unsigned, such as ARM and PowerPC. See g_value_get_schar().

deprecated: 2.32

###### g_value_get_double

Get the contents of a `G_TYPE_DOUBLE` `GValue`.

###### g_value_get_enum

Get the contents of a `G_TYPE_ENUM` `GValue`.

###### g_value_get_flags

Get the contents of a `G_TYPE_FLAGS` `GValue`.

###### g_value_get_float

Get the contents of a `G_TYPE_FLOAT` `GValue`.

###### g_value_get_gtype

Get the contents of a `G_TYPE_GTYPE` `GValue`.

since: 2.12

###### g_value_get_int

Get the contents of a `G_TYPE_INT` `GValue`.

###### g_value_get_int64

Get the contents of a `G_TYPE_INT64` `GValue`.

###### g_value_get_long

Get the contents of a `G_TYPE_LONG` `GValue`.

###### g_value_get_object

Get the contents of a `G_TYPE_OBJECT` derived `GValue`.

###### g_value_get_param

Get the contents of a `G_TYPE_PARAM` `GValue`.

###### g_value_get_pointer

Get the contents of a pointer `GValue`.

###### g_value_get_schar

Get the contents of a `G_TYPE_CHAR` `GValue`.

since: 2.32

###### g_value_get_string

Get the contents of a `G_TYPE_STRING` `GValue`.

###### g_value_get_uchar

Get the contents of a `G_TYPE_UCHAR` `GValue`.

###### g_value_get_uint

Get the contents of a `G_TYPE_UINT` `GValue`.

###### g_value_get_uint64

Get the contents of a `G_TYPE_UINT64` `GValue`.

###### g_value_get_ulong

Get the contents of a `G_TYPE_ULONG` `GValue`.

###### g_value_get_variant

Get the contents of a variant `GValue`.

since: 2.26

###### g_value_init

Initializes `value` to store values of the given `type`, and sets its value to the default for `type`.

###### g_value_init_from_instance

Initializes and sets `value` from an instantiatable type.

since: 2.42

###### g_value_peek_pointer

Returns the value contents as a pointer.

###### g_value_reset

Clears the current value in `value` and resets it to the default value (as if the value had just been initialized using `g_value_init()`).

###### g_value_set_boolean

Set the contents of a `G_TYPE_BOOLEAN` `GValue` to `v_boolean`.

###### g_value_set_boxed

Set the contents of a `G_TYPE_BOXED` derived `GValue` to `v_boxed`.

###### g_value_set_boxed_take_ownership

This is an internal function introduced mainly for C marshallers.

deprecated: 2.4

###### g_value_set_char

Set the contents of a `G_TYPE_CHAR` `GValue` to `v_char`.

deprecated: 2.32

###### g_value_set_double

Set the contents of a `G_TYPE_DOUBLE` `GValue` to `v_double`.

###### g_value_set_enum

Set the contents of a `G_TYPE_ENUM` `GValue` to `v_enum`.

###### g_value_set_flags

Set the contents of a `G_TYPE_FLAGS` `GValue` to `v_flags`.

###### g_value_set_float

Set the contents of a `G_TYPE_FLOAT` `GValue` to `v_float`.

###### g_value_set_gtype

Set the contents of a `G_TYPE_GTYPE` `GValue` to `v_gtype`.

since: 2.12

###### g_value_set_instance

Sets `value` from an instantiatable type.

###### g_value_set_int

Set the contents of a `G_TYPE_INT` `GValue` to `v_int`.

###### g_value_set_int64

Set the contents of a `G_TYPE_INT64` `GValue` to `v_int64`.

###### g_value_set_interned_string

Set the contents of a `G_TYPE_STRING` `GValue` to `v_string`. The string is assumed to be static and interned (canonical, for example from g_intern_string()), and is thus not duplicated when setting the `GValue`.

since: 2.66

###### g_value_set_long

Set the contents of a `G_TYPE_LONG` `GValue` to `v_long`.

###### g_value_set_object

Set the contents of a `G_TYPE_OBJECT` derived `GValue` to `v_object`.

###### g_value_set_object_take_ownership

This is an internal function introduced mainly for C marshallers.

deprecated: 2.4

###### g_value_set_param

Set the contents of a `G_TYPE_PARAM` `GValue` to `param`.

###### g_value_set_param_take_ownership

This is an internal function introduced mainly for C marshallers.

deprecated: 2.4

###### g_value_set_pointer

Set the contents of a pointer `GValue` to `v_pointer`.

###### g_value_set_schar

Set the contents of a `G_TYPE_CHAR` `GValue` to `v_char`.

since: 2.32

###### g_value_set_static_boxed

Set the contents of a `G_TYPE_BOXED` derived `GValue` to `v_boxed`.

###### g_value_set_static_string

Set the contents of a `G_TYPE_STRING` `GValue` to `v_string`. The string is assumed to be static, and is thus not duplicated when setting the `GValue`.

###### g_value_set_string

Set the contents of a `G_TYPE_STRING` `GValue` to a copy of `v_string`.

###### g_value_set_string_take_ownership

This is an internal function introduced mainly for C marshallers.

deprecated: 2.4

###### g_value_set_uchar

Set the contents of a `G_TYPE_UCHAR` `GValue` to `v_uchar`.

###### g_value_set_uint

Set the contents of a `G_TYPE_UINT` `GValue` to `v_uint`.

###### g_value_set_uint64

Set the contents of a `G_TYPE_UINT64` `GValue` to `v_uint64`.

###### g_value_set_ulong

Set the contents of a `G_TYPE_ULONG` `GValue` to `v_ulong`.

###### g_value_set_variant

Set the contents of a variant `GValue` to `variant`. If the variant is floating, it is consumed.

since: 2.26

###### g_value_steal_string

Steal ownership on contents of a `G_TYPE_STRING` `GValue`. As a result of this operation the value’s contents will be reset to `NULL`.

since: 2.80

###### g_value_take_boxed

Sets the contents of a `G_TYPE_BOXED` derived `GValue` to `v_boxed` and takes over the ownership of the caller’s reference to `v_boxed`; the caller doesn’t have to unref it any more.

since: 2.4

###### g_value_take_object

Sets the contents of a `G_TYPE_OBJECT` derived `GValue` to `v_object` and takes over the ownership of the caller’s reference to `v_object`; the caller doesn’t have to unref it any more (i.e. the reference count of the object is not increased).

since: 2.4

###### g_value_take_param

Sets the contents of a `G_TYPE_PARAM` `GValue` to `param` and takes over the ownership of the caller’s reference to `param`; the caller doesn’t have to unref it any more.

since: 2.4

###### g_value_take_string

Sets the contents of a `G_TYPE_STRING` `GValue` to `v_string`.

since: 2.4

###### g_value_take_variant

Set the contents of a variant `GValue` to `variant`, and takes over the ownership of the caller’s reference to `variant`; the caller doesn’t have to unref it any more (i.e. the reference count of the variant is not increased).

since: 2.26

###### g_value_transform

Tries to cast the contents of `src_value` into a type appropriate to store in `dest_value`.

###### g_value_unset

Clears the current value in `value` (if any) and ‘unsets’ the type.