Class Value

All Implemented Interfaces:
PointerInterface

public class Value extends Record
An opaque structure used to hold different types of values.

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 portions which implement 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.

https://docs.gtk.org/gobject/struct.Value.html

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class ch.bailu.gtk.type.Pointer

    NULL
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    copy(Value dest_value)
    Copies the value of @src_value into @dest_value.
    Get the contents of a %G_TYPE_BOXED derived #GValue.
    Get the contents of a %G_TYPE_OBJECT derived #GValue, increasing
    its reference count.
    Get the contents of a %G_TYPE_PARAM #GValue, increasing its
    reference count.
    Get a copy the contents of a %G_TYPE_STRING #GValue.
    Get the contents of a variant #GValue, increasing its refcount.
    boolean
    Determines if @value will fit inside the size of a pointer value.
    boolean
    Get the contents of a %G_TYPE_BOOLEAN #GValue.
    Get the contents of a %G_TYPE_BOXED derived #GValue.
     
    double
    Get the contents of a %G_TYPE_DOUBLE #GValue.
    int
    Get the contents of a %G_TYPE_ENUM #GValue.
    long
     
    int
    Get the contents of a %G_TYPE_FLAGS #GValue.
    float
    Get the contents of a %G_TYPE_FLOAT #GValue.
    long
    Get the contents of a %G_TYPE_GTYPE #GValue.
    static int
     
    int
    Get the contents of a %G_TYPE_INT #GValue.
    long
    Get the contents of a %G_TYPE_INT64 #GValue.
    long
    Get the contents of a %G_TYPE_LONG #GValue.
    Get the contents of a %G_TYPE_OBJECT derived #GValue.
    Get the contents of a %G_TYPE_PARAM #GValue.
    static long
     
     
    Get the contents of a pointer #GValue.
    int
    Get the contents of a %G_TYPE_CHAR #GValue.
    Get the contents of a %G_TYPE_STRING #GValue.
    static long
     
     
    int
    Get the contents of a %G_TYPE_UINT #GValue.
    long
    Get the contents of a %G_TYPE_UINT64 #GValue.
    long
    Get the contents of a %G_TYPE_ULONG #GValue.
    Get the contents of a variant #GValue.
    init(long g_type)
    Initializes @value with the default value of @type.
    void
    Initializes and sets @value from an instantiatable type via the
    value_table's collect_value() function.
    Returns the value contents as pointer.
    static void
    registerTransformFunc(long src_type, long dest_type, Value.OnValueTransform transform_func)
    Registers a value transformation function for use in g_value_transform().
    Clears the current value in @value and resets it to the default value
    (as if the value had just been initialized).
    void
    setBoolean(boolean v_boolean)
    Set the contents of a %G_TYPE_BOOLEAN #GValue to @v_boolean.
    void
    setBoxed(Pointer v_boxed)
    Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.
    void
    setDouble(double v_double)
    Set the contents of a %G_TYPE_DOUBLE #GValue to @v_double.
    void
    setEnum(int v_enum)
    Set the contents of a %G_TYPE_ENUM #GValue to @v_enum.
    void
    setFlags(int v_flags)
    Set the contents of a %G_TYPE_FLAGS #GValue to @v_flags.
    void
    setFloat(float v_float)
    Set the contents of a %G_TYPE_FLOAT #GValue to @v_float.
    void
    setGtype(long v_gtype)
    Set the contents of a %G_TYPE_GTYPE #GValue to @v_gtype.
    void
    setInstance(Pointer instance)
    Sets @value from an instantiatable type via the
    value_table's collect_value() function.
    void
    setInt(int v_int)
    Set the contents of a %G_TYPE_INT #GValue to @v_int.
    void
    setInt64(long v_int64)
    Set the contents of a %G_TYPE_INT64 #GValue to @v_int64.
    void
    Set the contents of a %G_TYPE_STRING #GValue to @v_string.
    void
    Set the contents of a %G_TYPE_STRING #GValue to @v_string.
    void
    setLong(long v_long)
    Set the contents of a %G_TYPE_LONG #GValue to @v_long.
    void
    setObject(Pointer v_object)
    Set the contents of a %G_TYPE_OBJECT derived #GValue to @v_object.
    void
    Set the contents of a %G_TYPE_PARAM #GValue to @param.
    void
    setPointer(Pointer v_pointer)
    Set the contents of a pointer #GValue to @v_pointer.
    void
    setSchar(int v_char)
    Set the contents of a %G_TYPE_CHAR #GValue to @v_char.
    void
    Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.
    void
    setStaticString(Str v_string)
    Set the contents of a %G_TYPE_STRING #GValue to @v_string.
    void
    Set the contents of a %G_TYPE_STRING #GValue to @v_string.
    void
    setString(Str v_string)
    Set the contents of a %G_TYPE_STRING #GValue to a copy of @v_string.
    void
    setString(String v_string)
    Set the contents of a %G_TYPE_STRING #GValue to a copy of @v_string.
    void
    setUint(int v_uint)
    Set the contents of a %G_TYPE_UINT #GValue to @v_uint.
    void
    setUint64(long v_uint64)
    Set the contents of a %G_TYPE_UINT64 #GValue to @v_uint64.
    void
    setUlong(long v_ulong)
    Set the contents of a %G_TYPE_ULONG #GValue to @v_ulong.
    void
    Set the contents of a variant #GValue to @variant.
    void
    takeBoxed(Pointer v_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.
    void
    takeObject(Pointer v_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).
    void
    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.
    void
    takeString(Str v_string)
    Sets the contents of a %G_TYPE_STRING #GValue to @v_string.
    void
    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).
    boolean
    transform(Value dest_value)
    Tries to cast the contents of @src_value into a type appropriate
    to store in @dest_value, e.g. to transform a %G_TYPE_INT value
    into a %G_TYPE_FLOAT value.
    static boolean
    typeCompatible(long src_type, long dest_type)
    Returns whether a #GValue of type @src_type can be copied into
    a #GValue of type @dest_type.
    static boolean
    typeTransformable(long src_type, long dest_type)
    Check whether g_value_transform() is able to transform values
    of type @src_type into values of type @dest_type.
    void
    Clears the current value in @value (if any) and "unsets" the type,
    this releases all resources associated with this GValue.

    Methods inherited from class ch.bailu.gtk.type.Record

    destroy

    Methods inherited from class ch.bailu.gtk.type.Type

    asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface ch.bailu.gtk.type.PointerInterface

    asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
  • Field Details

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getFieldGType

      public long getFieldGType()
    • copy

      public void copy(@Nonnull Value dest_value)
      Copies the value of @src_value into @dest_value.
      Parameters:
      dest_value - An initialized #GValue structure of the same type as @src_value.
    • dupBoxed

      public Pointer dupBoxed()
      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);
      Returns:
      boxed contents of @value
    • dupObject

      public Pointer dupObject()
      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.
      Returns:
      object content of @value, should be unreferenced when no longer needed.
    • dupParam

      public ParamSpec dupParam()
      Get the contents of a %G_TYPE_PARAM #GValue, increasing its
      reference count.
      Returns:
      #GParamSpec content of @value, should be unreferenced when no longer needed.
    • dupString

      public Str dupString()
      Get a copy the contents of a %G_TYPE_STRING #GValue.
      Returns:
      a newly allocated copy of the string content of @value
    • dupVariant

      public Variant dupVariant()
      Get the contents of a variant #GValue, increasing its refcount. The returned
      #GVariant is never floating.
      Returns:
      variant contents of @value (may be %NULL); should be unreffed using g_variant_unref() when no longer needed
    • fitsPointer

      public boolean fitsPointer()
      Determines if @value will fit inside the size of a pointer value.
      This is an internal function introduced mainly for C marshallers.
      Returns:
      %TRUE if @value will fit inside a pointer value.
    • getBoolean

      public boolean getBoolean()
      Get the contents of a %G_TYPE_BOOLEAN #GValue.
      Returns:
      boolean contents of @value
    • getBoxed

      public Pointer getBoxed()
      Get the contents of a %G_TYPE_BOXED derived #GValue.
      Returns:
      boxed contents of @value
    • getDouble

      public double getDouble()
      Get the contents of a %G_TYPE_DOUBLE #GValue.
      Returns:
      double contents of @value
    • getEnum

      public int getEnum()
      Get the contents of a %G_TYPE_ENUM #GValue.
      Returns:
      enum contents of @value
    • getFlags

      public int getFlags()
      Get the contents of a %G_TYPE_FLAGS #GValue.
      Returns:
      flags contents of @value
    • getFloat

      public float getFloat()
      Get the contents of a %G_TYPE_FLOAT #GValue.
      Returns:
      float contents of @value
    • getGtype

      public long getGtype()
      Get the contents of a %G_TYPE_GTYPE #GValue.
      Returns:
      the #GType stored in @value
    • getInt

      public int getInt()
      Get the contents of a %G_TYPE_INT #GValue.
      Returns:
      integer contents of @value
    • getInt64

      public long getInt64()
      Get the contents of a %G_TYPE_INT64 #GValue.
      Returns:
      64bit integer contents of @value
    • getLong

      public long getLong()
      Get the contents of a %G_TYPE_LONG #GValue.
      Returns:
      long integer contents of @value
    • getObject

      public Pointer getObject()
      Get the contents of a %G_TYPE_OBJECT derived #GValue.
      Returns:
      object contents of @value
    • getParam

      public ParamSpec getParam()
      Get the contents of a %G_TYPE_PARAM #GValue.
      Returns:
      #GParamSpec content of @value
    • getPointer

      public Pointer getPointer()
      Get the contents of a pointer #GValue.
      Returns:
      pointer contents of @value
    • getSchar

      public int getSchar()
      Get the contents of a %G_TYPE_CHAR #GValue.
      Returns:
      signed 8 bit integer contents of @value
    • getString

      public Str getString()
      Get the contents of a %G_TYPE_STRING #GValue.
      Returns:
      string content of @value
    • getUint

      public int getUint()
      Get the contents of a %G_TYPE_UINT #GValue.
      Returns:
      unsigned integer contents of @value
    • getUint64

      public long getUint64()
      Get the contents of a %G_TYPE_UINT64 #GValue.
      Returns:
      unsigned 64bit integer contents of @value
    • getUlong

      public long getUlong()
      Get the contents of a %G_TYPE_ULONG #GValue.
      Returns:
      unsigned long integer contents of @value
    • getVariant

      public Variant getVariant()
      Get the contents of a variant #GValue.
      Returns:
      variant contents of @value (may be %NULL)
    • init

      public Value init(long g_type)
      Initializes @value with the default value of @type.
      Parameters:
      g_type - Type the #GValue should hold values of.
      Returns:
      the #GValue structure that has been passed in
    • initFromInstance

      public void initFromInstance(@Nonnull Pointer instance)
      Initializes and sets @value from an instantiatable type via the
      value_table's collect_value() function.

      Note: The @value will be initialised with the exact type of
      @instance. If you wish to set the @value's type to a different GType
      (such as a parent class GType), you need to manually call
      g_value_init() and g_value_set_instance().
      Parameters:
      instance - the instance
    • peekPointer

      public Pointer peekPointer()
      Returns the value contents as pointer. This function asserts that
      g_value_fits_pointer() returned %TRUE for the passed in value.
      This is an internal function introduced mainly for C marshallers.
      Returns:
      the value contents as pointer
    • reset

      public Value reset()
      Clears the current value in @value and resets it to the default value
      (as if the value had just been initialized).
      Returns:
      the #GValue structure that has been passed in
    • setBoolean

      public void setBoolean(boolean v_boolean)
      Set the contents of a %G_TYPE_BOOLEAN #GValue to @v_boolean.
      Parameters:
      v_boolean - boolean value to be set
    • setBoxed

      public void setBoxed(@Nullable Pointer v_boxed)
      Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.
      Parameters:
      v_boxed - boxed value to be set
    • setDouble

      public void setDouble(double v_double)
      Set the contents of a %G_TYPE_DOUBLE #GValue to @v_double.
      Parameters:
      v_double - double value to be set
    • setEnum

      public void setEnum(int v_enum)
      Set the contents of a %G_TYPE_ENUM #GValue to @v_enum.
      Parameters:
      v_enum - enum value to be set
    • setFlags

      public void setFlags(int v_flags)
      Set the contents of a %G_TYPE_FLAGS #GValue to @v_flags.
      Parameters:
      v_flags - flags value to be set
    • setFloat

      public void setFloat(float v_float)
      Set the contents of a %G_TYPE_FLOAT #GValue to @v_float.
      Parameters:
      v_float - float value to be set
    • setGtype

      public void setGtype(long v_gtype)
      Set the contents of a %G_TYPE_GTYPE #GValue to @v_gtype.
      Parameters:
      v_gtype - #GType to be set
    • setInstance

      public void setInstance(@Nullable Pointer instance)
      Sets @value from an instantiatable type via the
      value_table's collect_value() function.
      Parameters:
      instance - the instance
    • setInt

      public void setInt(int v_int)
      Set the contents of a %G_TYPE_INT #GValue to @v_int.
      Parameters:
      v_int - integer value to be set
    • setInt64

      public void setInt64(long v_int64)
      Set the contents of a %G_TYPE_INT64 #GValue to @v_int64.
      Parameters:
      v_int64 - 64bit integer value to be set
    • setInternedString

      public void setInternedString(@Nullable Str v_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.
      Parameters:
      v_string - static string to be set
    • setInternedString

      public void setInternedString(String v_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.
      Parameters:
      v_string - static string to be set
    • setLong

      public void setLong(long v_long)
      Set the contents of a %G_TYPE_LONG #GValue to @v_long.
      Parameters:
      v_long - long integer value to be set
    • setObject

      public void setObject(@Nullable Pointer v_object)
      Set the contents of a %G_TYPE_OBJECT derived #GValue to @v_object.

      g_value_set_object() increases the reference count of @v_object
      (the #GValue 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 #GValue because you no longer
      need it), use g_value_take_object() instead.

      It is important that your #GValue 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 #GValue still exists).
      Parameters:
      v_object - object value to be set
    • setParam

      public void setParam(@Nullable ParamSpec param)
      Set the contents of a %G_TYPE_PARAM #GValue to @param.
      Parameters:
      param - the #GParamSpec to be set
    • setPointer

      public void setPointer(@Nullable Pointer v_pointer)
      Set the contents of a pointer #GValue to @v_pointer.
      Parameters:
      v_pointer - pointer value to be set
    • setSchar

      public void setSchar(int v_char)
      Set the contents of a %G_TYPE_CHAR #GValue to @v_char.
      Parameters:
      v_char - signed 8 bit integer to be set
    • setStaticBoxed

      public void setStaticBoxed(@Nullable Pointer v_boxed)
      Set the contents of a %G_TYPE_BOXED derived #GValue to @v_boxed.

      The boxed value is assumed to be static, and is thus not duplicated
      when setting the #GValue.
      Parameters:
      v_boxed - static boxed value to be set
    • setStaticString

      public void setStaticString(@Nullable Str v_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.

      If the the string is a canonical string, using g_value_set_interned_string()
      is more appropriate.
      Parameters:
      v_string - static string to be set
    • setStaticString

      public void setStaticString(String v_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.

      If the the string is a canonical string, using g_value_set_interned_string()
      is more appropriate.
      Parameters:
      v_string - static string to be set
    • setString

      public void setString(@Nullable Str v_string)
      Set the contents of a %G_TYPE_STRING #GValue to a copy of @v_string.
      Parameters:
      v_string - caller-owned string to be duplicated for the #GValue
    • setString

      public void setString(String v_string)
      Set the contents of a %G_TYPE_STRING #GValue to a copy of @v_string.
      Parameters:
      v_string - caller-owned string to be duplicated for the #GValue
    • setUint

      public void setUint(int v_uint)
      Set the contents of a %G_TYPE_UINT #GValue to @v_uint.
      Parameters:
      v_uint - unsigned integer value to be set
    • setUint64

      public void setUint64(long v_uint64)
      Set the contents of a %G_TYPE_UINT64 #GValue to @v_uint64.
      Parameters:
      v_uint64 - unsigned 64bit integer value to be set
    • setUlong

      public void setUlong(long v_ulong)
      Set the contents of a %G_TYPE_ULONG #GValue to @v_ulong.
      Parameters:
      v_ulong - unsigned long integer value to be set
    • setVariant

      public void setVariant(@Nullable Variant variant)
      Set the contents of a variant #GValue to @variant.
      If the variant is floating, it is consumed.
      Parameters:
      variant - a #GVariant, or %NULL
    • takeBoxed

      public void takeBoxed(@Nullable Pointer v_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.
      Parameters:
      v_boxed - duplicated unowned boxed value to be set
    • takeObject

      public void takeObject(@Nullable Pointer v_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).

      If you want the #GValue to hold its own reference to @v_object, use
      g_value_set_object() instead.
      Parameters:
      v_object - object value to be set
    • takeParam

      public void takeParam(@Nullable ParamSpec 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.
      Parameters:
      param - the #GParamSpec to be set
    • takeString

      public void takeString(@Nullable Str v_string)
      Sets the contents of a %G_TYPE_STRING #GValue to @v_string.
      Parameters:
      v_string - string to take ownership of
    • takeVariant

      public void takeVariant(@Nullable Variant 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).

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

      If you want the #GValue to hold its own reference to @variant, use
      g_value_set_variant() instead.

      This is an internal function introduced mainly for C marshallers.
      Parameters:
      variant - a #GVariant, or %NULL
    • transform

      public boolean transform(@Nonnull Value dest_value)
      Tries to cast the contents of @src_value into a type appropriate
      to store in @dest_value, e.g. to transform a %G_TYPE_INT value
      into a %G_TYPE_FLOAT value. Performing transformations between
      value types might incur precision lossage. Especially
      transformations into strings might reveal seemingly arbitrary
      results and shouldn't be relied upon for production code (such
      as rcfile value or object property serialization).
      Parameters:
      dest_value - Target value.
      Returns:
      Whether a transformation rule was found and could be applied. Upon failing transformations, @dest_value is left untouched.
    • unset

      public void unset()
      Clears the current value in @value (if any) and "unsets" the type,
      this releases all resources associated with this GValue. An unset
      value is the same as an uninitialized (zero-filled) #GValue
      structure.
    • registerTransformFunc

      public static void registerTransformFunc(long src_type, long dest_type, Value.OnValueTransform transform_func)
      Registers a value transformation function for use in g_value_transform().
      A previously registered transformation function for @src_type and @dest_type
      will be replaced.
      Parameters:
      src_type - Source type.
      dest_type - Target type.
      transform_func - a function which transforms values of type @src_type into value of type @dest_type
    • typeCompatible

      public static boolean typeCompatible(long src_type, long dest_type)
      Returns whether a #GValue of type @src_type can be copied into
      a #GValue of type @dest_type.
      Parameters:
      src_type - source type to be copied.
      dest_type - destination type for copying.
      Returns:
      %TRUE if g_value_copy() is possible with @src_type and @dest_type.
    • typeTransformable

      public static boolean typeTransformable(long src_type, long dest_type)
      Check whether g_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.
      Parameters:
      src_type - Source type.
      dest_type - Target type.
      Returns:
      %TRUE if the transformation is possible, %FALSE otherwise.
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()