Class Value

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Value extends ProxyInstance

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 init(Type) on it.

Many types which are stored within a GValue need to allocate data on the heap, so 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 GObject.TypeValueTable 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 gType member should only be accessed through the GObjects.VALUETYPE macro and related macros.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocate a new Value.
    Value(Arena arena)
    Allocate a new Value.
    Create a Value proxy instance for the provided memory address.
    Value(Type gType, _ValueDataUnion[] data)
    Allocate a new Value with the fields set to the provided values.
    Value(Type gType, _ValueDataUnion[] data, Arena arena)
    Allocate a new Value with the fields set to the provided values.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    copy(Value destValue)
    Copies the value of this Value into destValue.
    @Nullable MemorySegment
    Get the contents of a G_TYPE_BOXED derived GValue.
    @Nullable GObject
    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.
    @Nullable String
    Get a copy the contents of a G_TYPE_STRING GValue.
    @Nullable Variant
    Get the contents of a variant GValue, increasing its refcount.
    boolean
    Determines if this Value will fit inside the size of a pointer value.
    boolean
    Get the contents of a G_TYPE_BOOLEAN GValue.
    @Nullable MemorySegment
    Get the contents of a G_TYPE_BOXED derived GValue.
    byte
    Deprecated.
    This function's return type is broken, see g_value_get_schar()
    double
    Get the contents of a G_TYPE_DOUBLE GValue.
    int
    Get the contents of a G_TYPE_ENUM GValue.
    int
    Get the contents of a G_TYPE_FLAGS GValue.
    float
    Get the contents of a G_TYPE_FLOAT GValue.
    Get the contents of a G_TYPE_GTYPE GValue.
    int
    Get the contents of a G_TYPE_INT GValue.
    long
    Get the contents of a G_TYPE_INT64 GValue.
    int
    Get the contents of a G_TYPE_LONG GValue.
    The memory layout of the native struct.
    @Nullable GObject
    Get the contents of a G_TYPE_OBJECT derived GValue.
    Get the contents of a G_TYPE_PARAM GValue.
    @Nullable MemorySegment
    Get the contents of a pointer GValue.
    byte
    Get the contents of a G_TYPE_CHAR GValue.
    @Nullable String
    Get the contents of a G_TYPE_STRING GValue.
    static @Nullable Type
    Get the GType of the Value class.
    byte
    Get the contents of a G_TYPE_UCHAR GValue.
    int
    Get the contents of a G_TYPE_UINT GValue.
    long
    Get the contents of a G_TYPE_UINT64 GValue.
    int
    Get the contents of a G_TYPE_ULONG GValue.
    @Nullable Variant
    Get the contents of a variant GValue.
    init(Type gType)
    Initializes this Value to store values of the given type, and sets its value to the initial value for type.
    void
    Initializes and sets this Value from an instantiatable type.
    @Nullable MemorySegment
    Returns the value contents as a pointer.
    @Nullable _ValueDataUnion @Nullable []
    Read the value of the field data.
    Read the value of the field g_type.
    static void
    registerTransformFunc(Type srcType, Type destType, @Nullable ValueTransform transformFunc)
    Registers a value transformation function for use in transform(Value).
    Clears the current value in this Value and resets it to the initial value (as if the value had just been initialized using init(Type)).
    void
    setBoolean(boolean vBoolean)
    Set the contents of a G_TYPE_BOOLEAN GValue to vBoolean.
    void
    setBoxed(@Nullable MemorySegment vBoxed)
    Set the contents of a G_TYPE_BOXED derived GValue to vBoxed.
    void
    Deprecated.
    Use g_value_take_boxed() instead.
    void
    setChar(byte vChar)
    Deprecated.
    This function's input type is broken, see g_value_set_schar()
    void
    setDouble(double vDouble)
    Set the contents of a G_TYPE_DOUBLE GValue to vDouble.
    void
    setEnum(int vEnum)
    Set the contents of a G_TYPE_ENUM GValue to vEnum.
    void
    setFlags(int vFlags)
    Set the contents of a G_TYPE_FLAGS GValue to vFlags.
    void
    setFloat(float vFloat)
    Set the contents of a G_TYPE_FLOAT GValue to vFloat.
    void
    setGtype(Type vGtype)
    Set the contents of a G_TYPE_GTYPE GValue to vGtype.
    void
    setInstance(@Nullable MemorySegment instance)
    Sets this Value from an instantiatable type.
    void
    setInt(int vInt)
    Set the contents of a G_TYPE_INT GValue to vInt.
    void
    setInt64(long vInt64)
    Set the contents of a G_TYPE_INT64 GValue to vInt64.
    void
    setInternedString(@Nullable String vString)
    Set the contents of a G_TYPE_STRING GValue to vString. 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.
    void
    setLong(int vLong)
    Set the contents of a G_TYPE_LONG GValue to vLong.
    void
    setObject(@Nullable GObject vObject)
    Set the contents of a G_TYPE_OBJECT derived GValue to vObject.
    void
    Deprecated.
    Use g_value_take_object() instead.
    void
    setParam(@Nullable ParamSpec param)
    Set the contents of a G_TYPE_PARAM GValue to param.
    void
    Deprecated.
    Use g_value_take_param() instead.
    void
    setPointer(@Nullable MemorySegment vPointer)
    Set the contents of a pointer GValue to vPointer.
    void
    setSchar(byte vChar)
    Set the contents of a G_TYPE_CHAR GValue to vChar.
    void
    setStaticBoxed(@Nullable MemorySegment vBoxed)
    Set the contents of a G_TYPE_BOXED derived GValue to vBoxed.
    void
    setStaticString(@Nullable String vString)
    Set the contents of a G_TYPE_STRING GValue to vString. The string is assumed to be static, and is thus not duplicated when setting the GValue.
    void
    setString(@Nullable String vString)
    Set the contents of a G_TYPE_STRING GValue to a copy of vString.
    void
    setStringTakeOwnership(@Nullable String vString)
    Deprecated.
    Use g_value_take_string() instead.
    void
    setUchar(byte vUchar)
    Set the contents of a G_TYPE_UCHAR GValue to vUchar.
    void
    setUint(int vUint)
    Set the contents of a G_TYPE_UINT GValue to vUint.
    void
    setUint64(long vUint64)
    Set the contents of a G_TYPE_UINT64 GValue to vUint64.
    void
    setUlong(int vUlong)
    Set the contents of a G_TYPE_ULONG GValue to vUlong.
    void
    setVariant(@Nullable Variant variant)
    Set the contents of a variant GValue to variant. If the variant is floating, it is consumed.
    @Nullable String
    Steal ownership on contents of a G_TYPE_STRING GValue.
    void
    takeBoxed(@Nullable MemorySegment vBoxed)
    Sets the contents of a G_TYPE_BOXED derived GValue to vBoxed and takes over the ownership of the caller’s reference to vBoxed; the caller doesn’t have to unref it any more.
    void
    takeObject(@Nullable MemorySegment vObject)
    Sets the contents of a G_TYPE_OBJECT derived GValue to vObject and takes over the ownership of the caller’s reference to vObject; the caller doesn’t have to unref it any more (i.e. the reference count of the object is not increased).
    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.
    void
    takeString(@Nullable String vString)
    Sets the contents of a G_TYPE_STRING GValue to vString.
    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).
    Returns a string representation of the object.
    boolean
    transform(Value destValue)
    Tries to cast the contents of this Value into a type appropriate to store in destValue.
    static boolean
    typeCompatible(Type srcType, Type destType)
    Checks whether a copy(Value) is able to copy values of type srcType into values of type destType.
    static boolean
    typeTransformable(Type srcType, Type destType)
    Checks whether transform(Value) is able to transform values of type srcType into values of type destType.
    void
    Clears the current value in this Value (if any) and ‘unsets’ the type.
    void
    writeData(@Nullable _ValueDataUnion @Nullable [] data, Arena _arena)
    Write a value in the field data.
    void
    Write a value in the field g_type.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Value

      public Value(MemorySegment address)
      Create a Value proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Value

      public Value(Arena arena)
      Allocate a new Value.
      Parameters:
      arena - to control the memory allocation scope
    • Value

      public Value()
      Allocate a new Value. The memory is allocated with Arena.ofAuto().
    • Value

      public Value(Type gType, _ValueDataUnion[] data, Arena arena)
      Allocate a new Value with the fields set to the provided values.
      Parameters:
      gType - value for the field gType
      data - value for the field data
      arena - to control the memory allocation scope
    • Value

      public Value(Type gType, _ValueDataUnion[] data)
      Allocate a new Value with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      gType - value for the field gType
      data - value for the field data
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Value class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readGType

      public Type readGType()
      Read the value of the field g_type.
      Returns:
      The value of the field g_type
    • writeGType

      public void writeGType(Type gType)
      Write a value in the field g_type.
      Parameters:
      gType - The new value for the field g_type
    • readData

      public @Nullable _ValueDataUnion @Nullable [] readData()
      Read the value of the field data.
      Returns:
      The value of the field data
    • writeData

      public void writeData(@Nullable _ValueDataUnion @Nullable [] data, Arena _arena)
      Write a value in the field data.
      Parameters:
      data - The new value for the field data
    • registerTransformFunc

      public static void registerTransformFunc(Type srcType, Type destType, @Nullable ValueTransform transformFunc)

      Registers a value transformation function for use in transform(Value).

      Any previously registered transformation function for srcType and destType will be replaced.

      Parameters:
      srcType - source type
      destType - target type
      transformFunc - a function which transforms values of type srcType into values of type destType
    • typeCompatible

      public static boolean typeCompatible(Type srcType, Type destType)
      Checks whether a copy(Value) is able to copy values of type srcType into values of type destType.
      Parameters:
      srcType - source type to be copied
      destType - destination type for copying
      Returns:
      true if the copy is possible; false otherwise
    • typeTransformable

      public static boolean typeTransformable(Type srcType, Type destType)

      Checks whether transform(Value) is able to transform values of type srcType into values of type destType.

      Note that for the types to be transformable, they must be compatible or a transformation function must be registered using registerTransformFunc(Type, Type, ValueTransform).

      Parameters:
      srcType - source type
      destType - target type
      Returns:
      true if the transformation is possible; false otherwise
    • copy

      public void copy(Value destValue)
      Copies the value of this Value into destValue.
      Parameters:
      destValue - an initialized GObject.Value structure of the same type as this Value
    • dupBoxed

      public @Nullable MemorySegment 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 this Value
    • dupObject

      public @Nullable GObject 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 @Nullable String dupString()
      Get a copy the contents of a G_TYPE_STRING GValue.
      Returns:
      a newly allocated copy of the string content of this Value
    • dupVariant

      public @Nullable Variant dupVariant()
      Get the contents of a variant GValue, increasing its refcount. The returned GVariant is never floating.
      Returns:
      variant contents of this Value (may be null); should be unreffed using g_variant_unref() when no longer needed
      Since:
      2.26
    • fitsPointer

      public boolean fitsPointer()

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

      This is an internal function introduced mainly for C marshallers.

      Returns:
      true if this Value will fit inside a pointer value; false otherwise
    • getBoolean

      public boolean getBoolean()
      Get the contents of a G_TYPE_BOOLEAN GValue.
      Returns:
      boolean contents of this Value
    • getBoxed

      public @Nullable MemorySegment getBoxed()
      Get the contents of a G_TYPE_BOXED derived GValue.
      Returns:
      boxed contents of this Value
    • getChar

      @Deprecated public byte getChar()
      Deprecated.
      This function's return type is broken, see g_value_get_schar()

      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 GValue.

      Returns:
      character contents of this Value
    • getDouble

      public double getDouble()
      Get the contents of a G_TYPE_DOUBLE GValue.
      Returns:
      double contents of this Value
    • getEnum

      public int getEnum()
      Get the contents of a G_TYPE_ENUM GValue.
      Returns:
      enum contents of this Value
    • getFlags

      public int getFlags()
      Get the contents of a G_TYPE_FLAGS GValue.
      Returns:
      flags contents of this Value
    • getFloat

      public float getFloat()
      Get the contents of a G_TYPE_FLOAT GValue.
      Returns:
      float contents of this Value
    • getGtype

      public Type getGtype()
      Get the contents of a G_TYPE_GTYPE GValue.
      Returns:
      the GType stored in this Value
      Since:
      2.12
    • getInt

      public int getInt()
      Get the contents of a G_TYPE_INT GValue.
      Returns:
      integer contents of this Value
    • getInt64

      public long getInt64()
      Get the contents of a G_TYPE_INT64 GValue.
      Returns:
      64bit integer contents of this Value
    • getLong

      public int getLong()
      Get the contents of a G_TYPE_LONG GValue.
      Returns:
      long integer contents of this Value
    • getObject

      public @Nullable GObject getObject()
      Get the contents of a G_TYPE_OBJECT derived GValue.
      Returns:
      object contents of this Value
    • getParam

      public ParamSpec getParam()
      Get the contents of a G_TYPE_PARAM GValue.
      Returns:
      GParamSpec content of this Value
    • getPointer

      public @Nullable MemorySegment getPointer()
      Get the contents of a pointer GValue.
      Returns:
      pointer contents of this Value
    • getSchar

      public byte getSchar()
      Get the contents of a G_TYPE_CHAR GValue.
      Returns:
      signed 8 bit integer contents of this Value
      Since:
      2.32
    • getString

      public @Nullable String getString()
      Get the contents of a G_TYPE_STRING GValue.
      Returns:
      string content of this Value
    • getUchar

      public byte getUchar()
      Get the contents of a G_TYPE_UCHAR GValue.
      Returns:
      unsigned character contents of this Value
    • getUint

      public int getUint()
      Get the contents of a G_TYPE_UINT GValue.
      Returns:
      unsigned integer contents of this Value
    • getUint64

      public long getUint64()
      Get the contents of a G_TYPE_UINT64 GValue.
      Returns:
      unsigned 64bit integer contents of this Value
    • getUlong

      public int getUlong()
      Get the contents of a G_TYPE_ULONG GValue.
      Returns:
      unsigned long integer contents of this Value
    • getVariant

      public @Nullable Variant getVariant()
      Get the contents of a variant GValue.
      Returns:
      variant contents of this Value (may be null)
      Since:
      2.26
    • init

      public Value init(Type gType)

      Initializes this 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:
      gType - type the GObject.Value should hold values of
      Returns:
      the GObject.Value structure that has been passed in
    • initFromInstance

      public void initFromInstance(TypeInstance instance)

      Initializes and sets this Value from an instantiatable type.

      This calls the GObject.TypeValueCollectFunc function for the type the GObject.Value contains.

      Note: The this Value will be initialised with the exact type of instance. If you wish to set the value’s type to a different GObject.Type (such as a parent class type), you need to manually call init(Type) and setInstance(MemorySegment).

      Parameters:
      instance - the instance
      Since:
      2.42
    • peekPointer

      public @Nullable MemorySegment peekPointer()

      Returns the value contents as a pointer.

      This function asserts that fitsPointer() returned true for the passed in value.

      This is an internal function introduced mainly for C marshallers.

      Returns:
      the value contents as a pointer
    • reset

      public Value reset()
      Clears the current value in this Value and resets it to the initial value (as if the value had just been initialized using init(Type)).
      Returns:
      the GObject.Value structure that has been passed in
    • setBoolean

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

      public void setBoxed(@Nullable MemorySegment vBoxed)
      Set the contents of a G_TYPE_BOXED derived GValue to vBoxed.
      Parameters:
      vBoxed - caller-owned boxed object to be duplicated for the GValue
    • setBoxedTakeOwnership

      @Deprecated public void setBoxedTakeOwnership(@Nullable MemorySegment vBoxed)
      Deprecated.
      Use g_value_take_boxed() instead.
      This is an internal function introduced mainly for C marshallers.
      Parameters:
      vBoxed - duplicated unowned boxed value to be set
    • setChar

      @Deprecated public void setChar(byte vChar)
      Deprecated.
      This function's input type is broken, see g_value_set_schar()
      Set the contents of a G_TYPE_CHAR GValue to vChar.
      Parameters:
      vChar - character value to be set
    • setDouble

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

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

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

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

      public void setGtype(Type vGtype)
      Set the contents of a G_TYPE_GTYPE GValue to vGtype.
      Parameters:
      vGtype - GType to be set
      Since:
      2.12
    • setInstance

      public void setInstance(@Nullable MemorySegment instance)

      Sets this Value from an instantiatable type.

      This calls the GObject.TypeValueCollectFunc function for the type the GObject.Value contains.

      Parameters:
      instance - the instance
    • setInt

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

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

      public void setInternedString(@Nullable String vString)
      Set the contents of a G_TYPE_STRING GValue to vString. 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:
      vString - static string to be set
      Since:
      2.66
    • setLong

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

      public void setObject(@Nullable GObject vObject)

      Set the contents of a G_TYPE_OBJECT derived GValue to vObject.

      g_value_set_object() increases the reference count of vObject (the GValue holds a reference to vObject). 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 vObject (either its own, or one it has taken) to ensure that the object won't be destroyed while the GValue still exists).

      Parameters:
      vObject - object value to be set
    • setObjectTakeOwnership

      @Deprecated public void setObjectTakeOwnership(@Nullable MemorySegment vObject)
      Deprecated.
      Use g_value_take_object() instead.
      This is an internal function introduced mainly for C marshallers.
      Parameters:
      vObject - 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
    • setParamTakeOwnership

      @Deprecated public void setParamTakeOwnership(@Nullable ParamSpec param)
      Deprecated.
      Use g_value_take_param() instead.
      This is an internal function introduced mainly for C marshallers.
      Parameters:
      param - the GParamSpec to be set
    • setPointer

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

      public void setSchar(byte vChar)
      Set the contents of a G_TYPE_CHAR GValue to vChar.
      Parameters:
      vChar - signed 8 bit integer to be set
      Since:
      2.32
    • setStaticBoxed

      public void setStaticBoxed(@Nullable MemorySegment vBoxed)

      Set the contents of a G_TYPE_BOXED derived GValue to vBoxed.

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

      Parameters:
      vBoxed - static boxed value to be set
    • setStaticString

      public void setStaticString(@Nullable String vString)

      Set the contents of a G_TYPE_STRING GValue to vString. 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:
      vString - static string to be set
    • setString

      public void setString(@Nullable String vString)
      Set the contents of a G_TYPE_STRING GValue to a copy of vString.
      Parameters:
      vString - caller-owned string to be duplicated for the GValue
    • setStringTakeOwnership

      @Deprecated public void setStringTakeOwnership(@Nullable String vString)
      Deprecated.
      Use g_value_take_string() instead.
      This is an internal function introduced mainly for C marshallers.
      Parameters:
      vString - duplicated unowned string to be set
    • setUchar

      public void setUchar(byte vUchar)
      Set the contents of a G_TYPE_UCHAR GValue to vUchar.
      Parameters:
      vUchar - unsigned character value to be set
    • setUint

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

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

      public void setUlong(int vUlong)
      Set the contents of a G_TYPE_ULONG GValue to vUlong.
      Parameters:
      vUlong - 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
      Since:
      2.26
    • stealString

      public @Nullable String stealString()

      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.

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

      NOTE: for safety and compatibility purposes, if GValue 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 content of value; Should be freed with g_free() when no longer needed.
      Since:
      2.80
    • takeBoxed

      public void takeBoxed(@Nullable MemorySegment vBoxed)
      Sets the contents of a G_TYPE_BOXED derived GValue to vBoxed and takes over the ownership of the caller’s reference to vBoxed; the caller doesn’t have to unref it any more.
      Parameters:
      vBoxed - duplicated unowned boxed value to be set
      Since:
      2.4
    • takeObject

      public void takeObject(@Nullable MemorySegment vObject)

      Sets the contents of a G_TYPE_OBJECT derived GValue to vObject and takes over the ownership of the caller’s reference to vObject; 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 vObject, use g_value_set_object() instead.

      Parameters:
      vObject - object value to be set
      Since:
      2.4
    • 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
      Since:
      2.4
    • takeString

      public void takeString(@Nullable String vString)
      Sets the contents of a G_TYPE_STRING GValue to vString.
      Parameters:
      vString - string to take ownership of
      Since:
      2.4
    • 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
      Since:
      2.26
    • transform

      public boolean transform(Value destValue)

      Tries to cast the contents of this Value into a type appropriate to store in destValue.

      If a transformation is not possible, destValue 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:
      destValue - target value
      Returns:
      true on success; false otherwise
    • unset

      public void unset()

      Clears the current value in this 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.

    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object