Blame docs/reference/gobject/html/gobject-Generic-values.html

Packit ae235b
Packit ae235b
<html>
Packit ae235b
<head>
Packit ae235b
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Packit ae235b
<title>Generic values: GObject Reference Manual</title>
Packit ae235b
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
Packit ae235b
<link rel="home" href="index.html" title="GObject Reference Manual">
Packit ae235b
<link rel="up" href="rn01.html" title="API Reference">
Packit ae235b
<link rel="prev" href="gobject-Boxed-Types.html" title="Boxed Types">
Packit ae235b
<link rel="next" href="gobject-Standard-Parameter-and-Value-Types.html" title="Parameters and Values">
Packit ae235b
<meta name="generator" content="GTK-Doc V1.27 (XML mode)">
Packit ae235b
<link rel="stylesheet" href="style.css" type="text/css">
Packit ae235b
</head>
Packit ae235b
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit ae235b
Packit ae235b
Packit ae235b
Top  | 
Packit ae235b
                  Description
Packit ae235b
Packit ae235b
Home
Packit ae235b
Up
Packit ae235b
Prev
Packit ae235b
Next
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generic values

Packit ae235b

Generic values — A polymorphic type that can hold values of any

Packit ae235b
    other type

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
Packit ae235b
G_VALUE_HOLDS()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
Packit ae235b
G_VALUE_TYPE()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
Packit ae235b
G_VALUE_TYPE_NAME()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
Packit ae235b
G_TYPE_IS_VALUE()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
Packit ae235b
G_TYPE_IS_VALUE_ABSTRACT()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
Packit ae235b
G_IS_VALUE()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GValue *
Packit ae235b
Packit ae235b
Packit ae235b
g_value_init ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_value_copy ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
GValue *
Packit ae235b
Packit ae235b
Packit ae235b
g_value_reset ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_value_unset ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_value_init_from_instance ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_value_set_instance ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_value_fits_pointer ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gpointer
Packit ae235b
Packit ae235b
Packit ae235b
g_value_peek_pointer ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_value_type_compatible ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_value_type_transformable ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gboolean
Packit ae235b
Packit ae235b
Packit ae235b
g_value_transform ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
(*GValueTransform) ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
void
Packit ae235b
Packit ae235b
Packit ae235b
g_value_register_transform_func ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
gchar *
Packit ae235b
Packit ae235b
Packit ae235b
g_strdup_value_contents ()
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
G_VALUE_INIT
Packit ae235b
Packit ae235b
Packit ae235b
 
Packit ae235b
GValue
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
G_TYPE_VALUE
Packit ae235b
Packit ae235b
Packit ae235b
#define
Packit ae235b
G_TYPE_VALUE_ARRAY
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Includes

Packit ae235b
#include <glib-object.h>
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Description

Packit ae235b

The GValue structure is basically a variable container that consists

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

Packit ae235b

The code in the example program below demonstrates GValue's

Packit ae235b
features.

Packit ae235b
Packit ae235b
  
Packit ae235b
    
Packit ae235b
      
Packit ae235b
        
1
Packit ae235b
2
Packit ae235b
3
Packit ae235b
4
Packit ae235b
5
Packit ae235b
6
Packit ae235b
7
Packit ae235b
8
Packit ae235b
9
Packit ae235b
10
Packit ae235b
11
Packit ae235b
12
Packit ae235b
13
Packit ae235b
14
Packit ae235b
15
Packit ae235b
16
Packit ae235b
17
Packit ae235b
18
Packit ae235b
19
Packit ae235b
20
Packit ae235b
21
Packit ae235b
22
Packit ae235b
23
Packit ae235b
24
Packit ae235b
25
Packit ae235b
26
Packit ae235b
27
Packit ae235b
28
Packit ae235b
29
Packit ae235b
30
Packit ae235b
31
Packit ae235b
32
Packit ae235b
33
Packit ae235b
34
Packit ae235b
35
Packit ae235b
36
Packit ae235b
37
Packit ae235b
38
Packit ae235b
39
Packit ae235b
40
Packit ae235b
41
Packit ae235b
42
Packit ae235b
43
Packit ae235b
44
Packit ae235b
45
Packit ae235b
46
Packit ae235b
47
Packit ae235b
48
Packit ae235b
49
Packit ae235b
50
Packit ae235b
51
Packit ae235b
52
Packit ae235b
        
#include <glib-object.h>
Packit ae235b
Packit ae235b
static void
Packit ae235b
int2string (const GValue *src_value,
Packit ae235b
            GValue       *dest_value)
Packit ae235b
{
Packit ae235b
  if (g_value_get_int (src_value) == 42)
Packit ae235b
    g_value_set_static_string (dest_value, "An important number");
Packit ae235b
  else
Packit ae235b
    g_value_set_static_string (dest_value, "What's that?");
Packit ae235b
}
Packit ae235b
Packit ae235b
int
Packit ae235b
main (int   argc,
Packit ae235b
      char *argv[])
Packit ae235b
{
Packit ae235b
  // GValues must be initialized
Packit ae235b
  GValue a = G_VALUE_INIT;
Packit ae235b
  GValue b = G_VALUE_INIT;
Packit ae235b
  const gchar *message;
Packit ae235b
Packit ae235b
  // The GValue starts empty
Packit ae235b
  g_assert (!G_VALUE_HOLDS_STRING (&a));
Packit ae235b
Packit ae235b
  // Put a string in it
Packit ae235b
  g_value_init (&a, G_TYPE_STRING);
Packit ae235b
  g_assert (G_VALUE_HOLDS_STRING (&a));
Packit ae235b
  g_value_set_static_string (&a, "Hello, world!");
Packit ae235b
  g_printf ("%s\n", g_value_get_string (&a));
Packit ae235b
Packit ae235b
  // Reset it to its pristine state
Packit ae235b
  g_value_unset (&a);
Packit ae235b
Packit ae235b
  // It can then be reused for another type
Packit ae235b
  g_value_init (&a, G_TYPE_INT);
Packit ae235b
  g_value_set_int (&a, 42);
Packit ae235b
Packit ae235b
  // Attempt to transform it into a GValue of type STRING
Packit ae235b
  g_value_init (&b, G_TYPE_STRING);
Packit ae235b
Packit ae235b
  // An INT is transformable to a STRING
Packit ae235b
  g_assert (g_value_type_transformable (G_TYPE_INT, G_TYPE_STRING));
Packit ae235b
Packit ae235b
  g_value_transform (&a, &b);
Packit ae235b
  g_printf ("%s\n", g_value_get_string (&b));
Packit ae235b
Packit ae235b
  // Attempt to transform it again using a custom transform function
Packit ae235b
  g_value_register_transform_func (G_TYPE_INT, G_TYPE_STRING, int2string);
Packit ae235b
  g_value_transform (&a, &b);
Packit ae235b
  g_printf ("%s\n", g_value_get_string (&b));
Packit ae235b
  return 0;
Packit ae235b
}
Packit ae235b
      
Packit ae235b
    
Packit ae235b
  
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b
Packit ae235b

Functions

Packit ae235b
Packit ae235b

G_VALUE_HOLDS()

Packit ae235b
#define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type)))
Packit ae235b
Packit ae235b

Checks if value

Packit ae235b
 holds (or contains) a value of type
Packit ae235b
.
Packit ae235b
This macro will also check for value
Packit ae235b
 != NULL and issue a
Packit ae235b
warning if the check fails.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

A GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

type

Packit ae235b

A GType value.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if value

Packit ae235b
holds the type
Packit ae235b
.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

G_VALUE_TYPE()

Packit ae235b
#define G_VALUE_TYPE(value)		(((GValue*) (value))->g_type)
Packit ae235b
Packit ae235b

Get the type identifier of value

Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

A GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the GType.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

G_VALUE_TYPE_NAME()

Packit ae235b
#define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value)))
Packit ae235b
Packit ae235b

Gets the type name of value

Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

A GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the type name.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

G_TYPE_IS_VALUE()

Packit ae235b
#define G_TYPE_IS_VALUE(type)		(g_type_check_is_value_type (type))
Packit ae235b
Packit ae235b

Checks whether the passed in type ID can be used for g_value_init().

Packit ae235b
That is, this macro checks whether this type provides an implementation
Packit ae235b
of the GTypeValueTable functions required for a type to create a GValue of.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

type

Packit ae235b

A GType value.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

Whether type

Packit ae235b
is suitable as a GValue type.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

G_TYPE_IS_VALUE_ABSTRACT()

Packit ae235b
#define G_TYPE_IS_VALUE_ABSTRACT(type)          (g_type_test_flags ((type), G_TYPE_FLAG_VALUE_ABSTRACT))
Packit ae235b
Packit ae235b

Checks if type

Packit ae235b
 is an abstract value type.  An abstract value type introduces
Packit ae235b
a value table, but can't be used for g_value_init() and is normally used as
Packit ae235b
an abstract base type for derived value types.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

type

Packit ae235b

A GType value

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE on success

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

G_IS_VALUE()

Packit ae235b
#define G_IS_VALUE(value)		(G_TYPE_CHECK_VALUE (value))
Packit ae235b
Packit ae235b

Checks if value

Packit ae235b
 is a valid and initialized GValue structure.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

A GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE on success.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_init ()

Packit ae235b
GValue *
Packit ae235b
g_value_init (GValue *value,
Packit ae235b
              GType g_type);
Packit ae235b

Initializes value

Packit ae235b
 with the default value of type
Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

A zero-filled (uninitialized) GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

g_type

Packit ae235b

Type the GValue should hold values of.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the GValue structure that has been passed in.

Packit ae235b

[transfer none]

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_copy ()

Packit ae235b
void
Packit ae235b
g_value_copy (const GValue *src_value,
Packit ae235b
              GValue *dest_value);
Packit ae235b

Copies the value of src_value

Packit ae235b
 into dest_value
Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

src_value

Packit ae235b

An initialized GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

dest_value

Packit ae235b

An initialized GValue structure of the same type as src_value

Packit ae235b
.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_reset ()

Packit ae235b
GValue *
Packit ae235b
g_value_reset (GValue *value);
Packit ae235b

Clears the current value in value

Packit ae235b
 and resets it to the default value
Packit ae235b
(as if the value had just been initialized).

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

An initialized GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the GValue structure that has been passed in

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_unset ()

Packit ae235b
void
Packit ae235b
g_value_unset (GValue *value);
Packit ae235b

Clears the current value in value

Packit ae235b
 (if any) and "unsets" the type,
Packit ae235b
this releases all resources associated with this GValue. An unset
Packit ae235b
value is the same as an uninitialized (zero-filled) GValue
Packit ae235b
structure.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

An initialized GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_init_from_instance ()

Packit ae235b
void
Packit ae235b
g_value_init_from_instance (GValue *value,
Packit ae235b
                            gpointer instance);
Packit ae235b

Initializes and sets value

Packit ae235b
 from an instantiatable type via the
Packit ae235b
value_table's collect_value() function.

Packit ae235b

Note: The value

Packit ae235b
 will be initialised with the exact type of
Packit ae235b
instance
Packit ae235b
.  If you wish to set the value
Packit ae235b
's type to a different GType
Packit ae235b
(such as a parent class GType), you need to manually call
Packit ae235b
g_value_init() and g_value_set_instance().

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

An uninitialized GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

instance

Packit ae235b

the instance.

Packit ae235b
[type GObject.TypeInstance]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Since: 2.42

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_set_instance ()

Packit ae235b
void
Packit ae235b
g_value_set_instance (GValue *value,
Packit ae235b
                      gpointer instance);
Packit ae235b

Sets value

Packit ae235b
 from an instantiatable type via the
Packit ae235b
value_table's collect_value() function.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

An initialized GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

instance

Packit ae235b

the instance.

Packit ae235b
[nullable]
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_fits_pointer ()

Packit ae235b
gboolean
Packit ae235b
g_value_fits_pointer (const GValue *value);
Packit ae235b

Determines if value

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

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

An initialized GValue structure.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if value

Packit ae235b
will fit inside a pointer value.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_peek_pointer ()

Packit ae235b
gpointer
Packit ae235b
g_value_peek_pointer (const GValue *value);
Packit ae235b

Returns the value contents as pointer. This function asserts that

Packit ae235b
g_value_fits_pointer() returned TRUE for the passed in value.
Packit ae235b
This is an internal function introduced mainly for C marshallers.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

An initialized GValue structure

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

the value contents as pointer.

Packit ae235b

[transfer none]

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_type_compatible ()

Packit ae235b
gboolean
Packit ae235b
g_value_type_compatible (GType src_type,
Packit ae235b
                         GType dest_type);
Packit ae235b

Returns whether a GValue of type src_type

Packit ae235b
 can be copied into
Packit ae235b
a GValue of type dest_type
Packit ae235b
.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

src_type

Packit ae235b

source type to be copied.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

dest_type

Packit ae235b

destination type for copying.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if g_value_copy() is possible with src_type

Packit ae235b
and dest_type
Packit ae235b
.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_type_transformable ()

Packit ae235b
gboolean
Packit ae235b
g_value_type_transformable (GType src_type,
Packit ae235b
                            GType dest_type);
Packit ae235b

Check whether g_value_transform() is able to transform values

Packit ae235b
of type src_type
Packit ae235b
 into values of type dest_type
Packit ae235b
. Note that for
Packit ae235b
the types to be transformable, they must be compatible or a
Packit ae235b
transformation function must be registered.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

src_type

Packit ae235b

Source type.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

dest_type

Packit ae235b

Target type.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

TRUE if the transformation is possible, FALSE otherwise.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_transform ()

Packit ae235b
gboolean
Packit ae235b
g_value_transform (const GValue *src_value,
Packit ae235b
                   GValue *dest_value);
Packit ae235b

Tries to cast the contents of src_value

Packit ae235b
 into a type appropriate
Packit ae235b
to store in dest_value
Packit ae235b
, e.g. to transform a G_TYPE_INT value
Packit ae235b
into a G_TYPE_FLOAT value. Performing transformations between
Packit ae235b
value types might incur precision lossage. Especially
Packit ae235b
transformations into strings might reveal seemingly arbitrary
Packit ae235b
results and shouldn't be relied upon for production code (such
Packit ae235b
as rcfile value or object property serialization).

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

src_value

Packit ae235b

Source value.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

dest_value

Packit ae235b

Target value.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

Whether a transformation rule was found and could be applied.

Packit ae235b
Upon failing transformations, dest_value
Packit ae235b
is left untouched.

Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

GValueTransform ()

Packit ae235b
void
Packit ae235b
(*GValueTransform) (const GValue *src_value,
Packit ae235b
                    GValue *dest_value);
Packit ae235b

The type of value transformation functions which can be registered with

Packit ae235b
g_value_register_transform_func().

Packit ae235b

dest_value

Packit ae235b
 will be initialized to the correct destination type.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

src_value

Packit ae235b

Source value.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

dest_value

Packit ae235b

Target value.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_value_register_transform_func ()

Packit ae235b
void
Packit ae235b
g_value_register_transform_func (GType src_type,
Packit ae235b
                                 GType dest_type,
Packit ae235b
                                 GValueTransform transform_func);
Packit ae235b

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

Packit ae235b
A previously registered transformation function for src_type
Packit ae235b
 and dest_type
Packit ae235b
Packit ae235b
will be replaced.

Packit ae235b

[skip]

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

src_type

Packit ae235b

Source type.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

dest_type

Packit ae235b

Target type.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b

transform_func

Packit ae235b

a function which transforms values of type src_type

Packit ae235b
into value of type dest_type
Packit ae235b

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

g_strdup_value_contents ()

Packit ae235b
gchar *
Packit ae235b
g_strdup_value_contents (const GValue *value);
Packit ae235b

Return a newly allocated string, which describes the contents of a

Packit ae235b
GValue.  The main purpose of this function is to describe GValue
Packit ae235b
contents for debugging output, the way in which the contents are
Packit ae235b
described may change between different GLib versions.

Packit ae235b
Packit ae235b

Parameters

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

value

Packit ae235b

GValue which contents are to be described.

Packit ae235b
 
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Returns

Packit ae235b

Newly allocated string.

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Types and Values

Packit ae235b
Packit ae235b

G_VALUE_INIT

Packit ae235b
#define G_VALUE_INIT  { 0, { { 0 } } }
Packit ae235b
Packit ae235b

A GValue must be initialized before it can be used. This macro can

Packit ae235b
be used as initializer instead of an explicit { 0 } when declaring
Packit ae235b
a variable, but it cannot be assigned to a variable.

Packit ae235b
Packit ae235b
  
Packit ae235b
    
Packit ae235b
      
Packit ae235b
        
1
Packit ae235b
        
GValue value = G_VALUE_INIT;
Packit ae235b
      
Packit ae235b
    
Packit ae235b
  
Packit ae235b
Packit ae235b
Packit ae235b

Packit ae235b

Since: 2.30

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

GValue

Packit ae235b
typedef struct {
Packit ae235b
} GValue;
Packit ae235b
Packit ae235b

An opaque structure used to hold different types of values.

Packit ae235b
The data within the structure has protected scope: it is accessible only
Packit ae235b
to functions within a GTypeValueTable structure, or implementations of
Packit ae235b
the g_value_*() API. That is, code portions which implement new fundamental
Packit ae235b
types.
Packit ae235b
GValue users cannot make any assumptions about how data is stored
Packit ae235b
within the 2 element data
Packit ae235b
 union, and the g_type
Packit ae235b
 member should
Packit ae235b
only be accessed through the G_VALUE_TYPE() macro.

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

G_TYPE_VALUE

Packit ae235b
#define G_TYPE_VALUE (g_value_get_type ())
Packit ae235b
Packit ae235b

The type ID of the "GValue" type which is a boxed type,

Packit ae235b
used to pass around pointers to GValues.

Packit ae235b
Packit ae235b

Packit ae235b
Packit ae235b

G_TYPE_VALUE_ARRAY

Packit ae235b
#define G_TYPE_VALUE_ARRAY (g_value_array_get_type ())
Packit ae235b
Packit ae235b
Packit ae235b

G_TYPE_VALUE_ARRAY has been deprecated since version 2.32 and should not be used in newly-written code.

Packit ae235b

Use GArray instead of GValueArray

Packit ae235b
Packit ae235b

The type ID of the "GValueArray" type which is a boxed type,

Packit ae235b
used to pass around pointers to GValueArrays.

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

See Also

Packit ae235b

The fundamental types which all support GValue

Packit ae235b
    operations and thus can be used as a type initializer for
Packit ae235b
    g_value_init() are defined by a separate interface.  See the
Packit ae235b
    standard values API
Packit ae235b
    for details

Packit ae235b
Packit ae235b
Packit ae235b
Packit ae235b

Generated by GTK-Doc V1.27
Packit ae235b
</body>
Packit ae235b
</html>