Value

The GValue structure is basically a variable container that consists of a type identifier and a specific value of that type. The type identifier within a GValue structure always determines the type of the associated value. To create a undefined GValue structure, simply create a zero-filled GValue structure. To initialize the GValue, use the g_value_init() function. A GValue cannot be used until it is initialized. The basic type operations (such as freeing and copying) are determined by the GTypeValueTable associated with the type ID stored in the GValue. Other GValue operations (such as converting values between types) are provided by this interface.

The code in the example program below demonstrates GValue's features.

class Value {}

Constructors

this
this(GValue* gValue)

Sets our main struct and passes it to the parent class

this
this()
this
this(Pixbuf pixbuf)
this
this(string value)
this
this(int value)
this
this(float value)
this
this(double value)

Members

Functions

copy
void copy(Value destValue)

Copies the value of src_value into dest_value.

dupBoxed
void* 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);

dupObject
void* 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.

dupParam
ParamSpec dupParam()

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

dupString
string dupString()

Get a copy the contents of a G_TYPE_STRING GValue.

dupVariant
Variant dupVariant()

Get the contents of a variant GValue, increasing its refcount. Since 2.26

fitsPointer
int fitsPointer()

Determines if value will fit inside the size of a pointer value. This is an internal function introduced mainly for C marshallers.

gStrdupValueContents
string gStrdupValueContents()

Return a newly allocated string, which describes the contents of a GValue. The main purpose of this function is to describe GValue contents for debugging output, the way in which the contents are described may change between different GLib versions.

getBoolean
int getBoolean()

Get the contents of a G_TYPE_BOOLEAN GValue.

getBoxed
void* getBoxed()

Get the contents of a G_TYPE_BOXED derived GValue.

getChar
char getChar()

Warning g_value_get_char has been deprecated since version 2.32 and should not be used in newly-written code. 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.

getDouble
double getDouble()

Get the contents of a G_TYPE_DOUBLE GValue.

getEnum
int getEnum()

Get the contents of a G_TYPE_ENUM GValue.

getFlags
uint getFlags()

Get the contents of a G_TYPE_FLAGS GValue.

getFloat
float getFloat()

Get the contents of a G_TYPE_FLOAT GValue.

getGtype
GType getGtype()

Get the contents of a G_TYPE_GTYPE GValue. Since 2.12

getInt
int getInt()

Get the contents of a G_TYPE_INT GValue.

getInt64
long getInt64()

Get the contents of a G_TYPE_INT64 GValue.

getLong
glong getLong()

Get the contents of a G_TYPE_LONG GValue.

getObject
void* getObject()

Get the contents of a G_TYPE_OBJECT derived GValue.

getParam
ParamSpec getParam()

Get the contents of a G_TYPE_PARAM GValue.

getPointer
void* getPointer()

Get the contents of a pointer GValue.

getSchar
byte getSchar()

Get the contents of a G_TYPE_CHAR GValue. Since 2.32

getString
string getString()

Get the contents of a G_TYPE_STRING GValue.

getStruct
void* getStruct()

the main Gtk struct as a void*

getUchar
char getUchar()

Get the contents of a G_TYPE_UCHAR GValue.

getUint
uint getUint()

Get the contents of a G_TYPE_UINT GValue.

getUint64
ulong getUint64()

Get the contents of a G_TYPE_UINT64 GValue.

getUlong
gulong getUlong()

Get the contents of a G_TYPE_ULONG GValue.

getValueStruct
GValue* getValueStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getVariant
Variant getVariant()

Get the contents of a variant GValue. Since 2.26

init
Value init(GType gType)

Initializes value with the default value of type.

peekPointer
void* peekPointer()
reset
Value reset()

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

setBoolean
void setBoolean(int vBoolean)

Set the contents of a G_TYPE_BOOLEAN GValue to v_boolean.

setBoxed
void setBoxed(void* vBoxed)

Set the contents of a G_TYPE_BOXED derived GValue to v_boxed.

setBoxedTakeOwnership
void setBoxedTakeOwnership(void* vBoxed)

Warning g_value_set_boxed_take_ownership has been deprecated since version 2.4 and should not be used in newly-written code. Use g_value_take_boxed() instead. This is an internal function introduced mainly for C marshallers.

setChar
void setChar(char vChar)

Warning g_value_set_char has been deprecated since version 2.32 and should not be used in newly-written code. This function's input type is broken, see g_value_set_schar() Set the contents of a G_TYPE_CHAR GValue to v_char.

setDouble
void setDouble(double vDouble)

Set the contents of a G_TYPE_DOUBLE GValue to v_double.

setEnum
void setEnum(int vEnum)

Set the contents of a G_TYPE_ENUM GValue to v_enum.

setFlags
void setFlags(uint vFlags)

Set the contents of a G_TYPE_FLAGS GValue to v_flags.

setFloat
void setFloat(float vFloat)

Set the contents of a G_TYPE_FLOAT GValue to v_float.

setGtype
void setGtype(GType vGtype)

Set the contents of a G_TYPE_GTYPE GValue to v_gtype. Since 2.12

setInstance
void setInstance(void* instanc)

Sets value from an instantiatable type via the value_table's collect_value() function.

setInt
void setInt(int vInt)

Set the contents of a G_TYPE_INT GValue to v_int.

setInt64
void setInt64(long vInt64)

Set the contents of a G_TYPE_INT64 GValue to v_int64.

setLong
void setLong(glong vLong)

Set the contents of a G_TYPE_LONG GValue to v_long.

setObject
void setObject(void* vObject)

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

setObjectTakeOwnership
void setObjectTakeOwnership(void* vObject)

Warning g_value_set_object_take_ownership has been deprecated since version 2.4 and should not be used in newly-written code. Use g_value_take_object() instead. This is an internal function introduced mainly for C marshallers.

setParam
void setParam(ParamSpec param)

Set the contents of a G_TYPE_PARAM GValue to param.

setParamTakeOwnership
void setParamTakeOwnership(ParamSpec param)

Warning g_value_set_param_take_ownership has been deprecated since version 2.4 and should not be used in newly-written code. Use g_value_take_param() instead. This is an internal function introduced mainly for C marshallers.

setPointer
void setPointer(void* vPointer)

Set the contents of a pointer GValue to v_pointer.

setSchar
void setSchar(byte vChar)

Set the contents of a G_TYPE_CHAR GValue to v_char. Since 2.32

setStaticBoxed
void setStaticBoxed(void* vBoxed)

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.

setStaticString
void setStaticString(string vString)

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.

setString
void setString(string vString)

Set the contents of a G_TYPE_STRING GValue to v_string.

setStringTakeOwnership
void setStringTakeOwnership(string vString)

Warning g_value_set_string_take_ownership has been deprecated since version 2.4 and should not be used in newly-written code. Use g_value_take_string() instead. This is an internal function introduced mainly for C marshallers.

setUchar
void setUchar(char vUchar)

Set the contents of a G_TYPE_UCHAR GValue to v_uchar.

setUint
void setUint(uint vUint)

Set the contents of a G_TYPE_UINT GValue to v_uint.

setUint64
void setUint64(ulong vUint64)

Set the contents of a G_TYPE_UINT64 GValue to v_uint64.

setUlong
void setUlong(gulong vUlong)

Set the contents of a G_TYPE_ULONG GValue to v_ulong.

setVariant
void setVariant(Variant variant)

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

takeBoxed
void takeBoxed(void* vBoxed)

Sets the contents of a G_TYPE_BOXED derived GValue to v_boxed and takes over the ownership of the callers reference to v_boxed; the caller doesn't have to unref it any more. Since 2.4

takeObject
void takeObject(void* vObject)

Sets the contents of a G_TYPE_OBJECT derived GValue to v_object and takes over the ownership of the callers 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. Since 2.4

takeParam
void takeParam(ParamSpec param)

Sets the contents of a G_TYPE_PARAM GValue to param and takes over the ownership of the callers reference to param; the caller doesn't have to unref it any more. Since 2.4

takeString
void takeString(string vString)

Sets the contents of a G_TYPE_STRING GValue to v_string. Since 2.4

takeVariant
void takeVariant(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. Since 2.26

transform
int transform(Value destValue)

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

unset
void unset()

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

Static functions

gParamSpecBoolean
ParamSpec gParamSpecBoolean(string name, string nick, string blurb, int defaultValue, GParamFlags flags)

Creates a new GParamSpecBoolean instance specifying a G_TYPE_BOOLEAN property. See g_param_spec_internal() for details on property names.

gParamSpecBoxed
ParamSpec gParamSpecBoxed(string name, string nick, string blurb, GType boxedType, GParamFlags flags)

Creates a new GParamSpecBoxed instance specifying a G_TYPE_BOXED derived property. See g_param_spec_internal() for details on property names.

gParamSpecChar
ParamSpec gParamSpecChar(string name, string nick, string blurb, byte minimum, byte maximum, byte defaultValue, GParamFlags flags)

Creates a new GParamSpecChar instance specifying a G_TYPE_CHAR property.

gParamSpecDouble
ParamSpec gParamSpecDouble(string name, string nick, string blurb, double minimum, double maximum, double defaultValue, GParamFlags flags)

Creates a new GParamSpecDouble instance specifying a G_TYPE_DOUBLE property. See g_param_spec_internal() for details on property names.

gParamSpecEnum
ParamSpec gParamSpecEnum(string name, string nick, string blurb, GType enumType, int defaultValue, GParamFlags flags)

Creates a new GParamSpecEnum instance specifying a G_TYPE_ENUM property. See g_param_spec_internal() for details on property names.

gParamSpecFlags
ParamSpec gParamSpecFlags(string name, string nick, string blurb, GType flagsType, uint defaultValue, GParamFlags flags)

Creates a new GParamSpecFlags instance specifying a G_TYPE_FLAGS property. See g_param_spec_internal() for details on property names.

gParamSpecFloat
ParamSpec gParamSpecFloat(string name, string nick, string blurb, float minimum, float maximum, float defaultValue, GParamFlags flags)

Creates a new GParamSpecFloat instance specifying a G_TYPE_FLOAT property. See g_param_spec_internal() for details on property names.

gParamSpecGtype
ParamSpec gParamSpecGtype(string name, string nick, string blurb, GType isAType, GParamFlags flags)

Creates a new GParamSpecGType instance specifying a G_TYPE_GTYPE property. See g_param_spec_internal() for details on property names. Since 2.10

gParamSpecInt
ParamSpec gParamSpecInt(string name, string nick, string blurb, int minimum, int maximum, int defaultValue, GParamFlags flags)

Creates a new GParamSpecInt instance specifying a G_TYPE_INT property. See g_param_spec_internal() for details on property names.

gParamSpecInt64
ParamSpec gParamSpecInt64(string name, string nick, string blurb, long minimum, long maximum, long defaultValue, GParamFlags flags)

Creates a new GParamSpecInt64 instance specifying a G_TYPE_INT64 property. See g_param_spec_internal() for details on property names.

gParamSpecLong
ParamSpec gParamSpecLong(string name, string nick, string blurb, glong minimum, glong maximum, glong defaultValue, GParamFlags flags)

Creates a new GParamSpecLong instance specifying a G_TYPE_LONG property. See g_param_spec_internal() for details on property names.

gParamSpecObject
ParamSpec gParamSpecObject(string name, string nick, string blurb, GType objectType, GParamFlags flags)

Creates a new GParamSpecBoxed instance specifying a G_TYPE_OBJECT derived property. See g_param_spec_internal() for details on property names.

gParamSpecOverride
ParamSpec gParamSpecOverride(string name, ParamSpec overridden)

Creates a new property of type GParamSpecOverride. This is used to direct operations to another paramspec, and will not be directly useful unless you are implementing a new base type similar to GObject. Since 2.4

gParamSpecParam
ParamSpec gParamSpecParam(string name, string nick, string blurb, GType paramType, GParamFlags flags)

Creates a new GParamSpecParam instance specifying a G_TYPE_PARAM property. See g_param_spec_internal() for details on property names.

gParamSpecPointer
ParamSpec gParamSpecPointer(string name, string nick, string blurb, GParamFlags flags)

Creates a new GParamSpecPointer instance specifying a pointer property. See g_param_spec_internal() for details on property names.

gParamSpecString
ParamSpec gParamSpecString(string name, string nick, string blurb, string defaultValue, GParamFlags flags)

Creates a new GParamSpecString instance. See g_param_spec_internal() for details on property names.

gParamSpecUchar
ParamSpec gParamSpecUchar(string name, string nick, string blurb, ubyte minimum, ubyte maximum, ubyte defaultValue, GParamFlags flags)

Creates a new GParamSpecUChar instance specifying a G_TYPE_UCHAR property.

gParamSpecUint
ParamSpec gParamSpecUint(string name, string nick, string blurb, uint minimum, uint maximum, uint defaultValue, GParamFlags flags)

Creates a new GParamSpecUInt instance specifying a G_TYPE_UINT property. See g_param_spec_internal() for details on property names.

gParamSpecUint64
ParamSpec gParamSpecUint64(string name, string nick, string blurb, ulong minimum, ulong maximum, ulong defaultValue, GParamFlags flags)

Creates a new GParamSpecUInt64 instance specifying a G_TYPE_UINT64 property. See g_param_spec_internal() for details on property names.

gParamSpecUlong
ParamSpec gParamSpecUlong(string name, string nick, string blurb, gulong minimum, gulong maximum, gulong defaultValue, GParamFlags flags)

Creates a new GParamSpecULong instance specifying a G_TYPE_ULONG property. See g_param_spec_internal() for details on property names.

gParamSpecUnichar
ParamSpec gParamSpecUnichar(string name, string nick, string blurb, gunichar defaultValue, GParamFlags flags)

Creates a new GParamSpecUnichar instance specifying a G_TYPE_UINT property. GValue structures for this property can be accessed with g_value_set_uint() and g_value_get_uint(). See g_param_spec_internal() for details on property names.

gParamSpecValueArray
ParamSpec gParamSpecValueArray(string name, string nick, string blurb, ParamSpec elementSpec, GParamFlags flags)

Creates a new GParamSpecValueArray instance specifying a G_TYPE_VALUE_ARRAY property. G_TYPE_VALUE_ARRAY is a G_TYPE_BOXED type, as such, GValue structures for this property can be accessed with g_value_set_boxed() and g_value_get_boxed(). See g_param_spec_internal() for details on property names.

gParamSpecVariant
ParamSpec gParamSpecVariant(string name, string nick, string blurb, VariantType type, Variant defaultValue, GParamFlags flags)

Creates a new GParamSpecVariant instance specifying a GVariant property. If default_value is floating, it is consumed. See g_param_spec_internal() for details on property names. Since 2.26

registerTransformFunc
void registerTransformFunc(GType srcType, GType destType, GValueTransform transformFunc)

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.

typeCompatible
int typeCompatible(GType srcType, GType destType)

Returns whether a GValue of type src_type can be copied into a GValue of type dest_type.

typeTransformable
int typeTransformable(GType srcType, GType destType)

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

Variables

gValue
GValue* gValue;

the main Gtk struct

Meta