Class (GI Struct)

GObject-2.0GObjectValue

An opaque structure used to hold different types of values.

Before it can be used, a GObject.Value has to be initialized to a specific type by calling GObject.Value.init on it.

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

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

GObject.Value 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 GObject.VALUE_TYPE macro and related macros.

Index

Constructors

Properties

Methods

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

    This is an internal function introduced mainly for C marshallers.

    Returns boolean

    true if value will fit inside a pointer value; false otherwise

  • 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().

    Get the contents of a G_TYPE_CHAR GObject.Value.

    Returns number

    character contents of value

  • Initializes value to store values of the given type, and sets its value to the initial value for type.

    This must be called before any other methods on a GObject.Value, so the value knows what type it’s meant to store.

      GValue value = G_VALUE_INIT;

    g_value_init (&value, SOME_G_TYPE);

    g_value_unset (&value);

    Parameters

    Returns unknown

    the GObject.Value structure that has been passed in

  • Returns the value contents as a pointer.

    This function asserts that GObject.Value.fits_pointer returned true for the passed in value.

    This is an internal function introduced mainly for C marshallers.

    Returns any

    the value contents as a pointer

  • This is an internal function introduced mainly for C marshallers.

    Parameters

    • Optionalv_boxed: any

      duplicated unowned boxed value to be set

    Returns void

  • Set the contents of a G_TYPE_STRING GObject.Value 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 GObject.Value.

    Parameters

    • Optionalv_string: string

      static string to be set

    Returns void

  • Set the contents of a G_TYPE_OBJECT derived GObject.Value to v_object.

    g_value_set_object() increases the reference count of v_object (the GObject.Value holds a reference to v_object). If you do not wish to increase the reference count of the object (i.e. you wish to pass your current reference to the GObject.Value because you no longer need it), use g_value_take_object() instead.

    It is important that your GObject.Value holds a reference to v_object (either its own, or one it has taken) to ensure that the object won't be destroyed while the GObject.Value still exists).

    Parameters

    Returns void

  • Set the contents of a G_TYPE_BOXED derived GObject.Value to v_boxed.

    The boxed value is assumed to be static, and is thus not duplicated when setting the GObject.Value.

    Parameters

    • Optionalv_boxed: any

      static boxed value to be set

    Returns void

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

    If the the string is a canonical string, using g_value_set_interned_string() is more appropriate.

    Parameters

    • Optionalv_string: string

      static string to be set

    Returns void

  • This is an internal function introduced mainly for C marshallers.

    Parameters

    • Optionalv_string: string

      duplicated unowned string to be set

    Returns void

  • Steal ownership on contents of a G_TYPE_STRING GObject.Value. As a result of this operation the value's contents will be reset to null.

    The purpose of this call is to provide a way to avoid an extra copy when some object have been serialized into string through GObject.Value API.

    NOTE: for safety and compatibility purposes, if GObject.Value contains static string, or an interned one, this function will return a copy of the string. Otherwise the transfer notation would be ambiguous.

    Returns string

    string content of value; Should be freed with g_free() when no longer needed.

  • Sets the contents of a G_TYPE_BOXED derived GObject.Value 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.

    Parameters

    • Optionalv_boxed: any

      duplicated unowned boxed value to be set

    Returns void

  • Set the contents of a variant GObject.Value 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).

    If variant was floating then its floating reference is converted to a hard reference.

    If you want the GObject.Value to hold its own reference to variant, use g_value_set_variant() instead.

    This is an internal function introduced mainly for C marshallers.

    Parameters

    Returns void

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

    If a transformation is not possible, dest_value is not modified.

    For example, this could transform a G_TYPE_INT value into a G_TYPE_FLOAT value.

    Performing transformations between value types might incur precision loss. Especially transformations into strings might reveal seemingly arbitrary results and the format of particular transformations to strings is not guaranteed over time.

    Parameters

    • dest_value: any

      target value

    Returns boolean

    true on success; false otherwise

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

    This releases all resources associated with this GObject.Value. An unset value is the same as a cleared (zero-filled) GObject.Value structure set to G_VALUE_INIT.

    Returns void

  • Checks whether GObject.Value.transform is able to transform values of type src_type into values of type dest_type.

    Note that for the types to be transformable, they must be compatible or a transformation function must be registered using GObject.Value.register_transform_func.

    Parameters

    • src_type: GType

      source type

    • dest_type: GType

      target type

    Returns boolean