gboxed.h 3.82 KB
Newer Older
1
/* GObject - GLib Type, Object, Parameter and Signal Library
2
 * Copyright (C) 2000-2001 Red Hat, Inc.
3 4 5 6 7 8 9 10 11 12 13 14
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
15
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
16
 */
17 18 19
#ifndef __G_BOXED_H__
#define __G_BOXED_H__

20 21 22 23
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
#error "Only <glib-object.h> can be included directly."
#endif

24 25
#include        <gobject/gtype.h>

26 27 28 29
#ifndef __GI_SCANNER__
#include        <gobject/glib-types.h>
#endif

30
G_BEGIN_DECLS
31 32

/* --- type macros --- */
Matthias Clasen's avatar
Matthias Clasen committed
33
#define G_TYPE_IS_BOXED(type)      (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED)
Stefan Kost's avatar
Stefan Kost committed
34 35 36
/**
 * G_VALUE_HOLDS_BOXED:
 * @value: a valid #GValue structure
Matthias Clasen's avatar
Matthias Clasen committed
37 38 39 40
 *
 * Checks whether the given #GValue can hold values derived
 * from type %G_TYPE_BOXED.
 *
Stefan Kost's avatar
Stefan Kost committed
41 42
 * Returns: %TRUE on success.
 */
43
#define G_VALUE_HOLDS_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED))
44 45 46


/* --- typedefs --- */
Stefan Kost's avatar
Stefan Kost committed
47 48 49
/**
 * GBoxedCopyFunc:
 * @boxed: The boxed structure to be copied.
Matthias Clasen's avatar
Matthias Clasen committed
50 51 52 53
 *
 * This function is provided by the user and should produce a copy
 * of the passed in boxed structure.
 *
Stefan Kost's avatar
Stefan Kost committed
54 55 56 57 58 59 60
 * Returns: The newly created copy of the boxed structure.
 */
typedef gpointer (*GBoxedCopyFunc) (gpointer boxed);

/**
 * GBoxedFreeFunc:
 * @boxed: The boxed structure to be freed.
Matthias Clasen's avatar
Matthias Clasen committed
61
 *
Stefan Kost's avatar
Stefan Kost committed
62 63 64 65
 * This function is provided by the user and should free the boxed
 * structure passed.
 */
typedef void (*GBoxedFreeFunc) (gpointer boxed);
66 67 68


/* --- prototypes --- */
69
GLIB_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
70 71
gpointer g_boxed_copy                     (GType boxed_type,
                                           gconstpointer  src_boxed);
72
GLIB_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
73 74
void     g_boxed_free                     (GType          boxed_type,
                                           gpointer       boxed);
75
GLIB_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
76 77
void     g_value_set_boxed                (GValue        *value,
                                           gconstpointer  v_boxed);
78
GLIB_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
79 80
void     g_value_set_static_boxed         (GValue        *value,
                                           gconstpointer  v_boxed);
81
GLIB_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
82 83
void     g_value_take_boxed               (GValue        *value,
                                           gconstpointer  v_boxed);
84
GLIB_DEPRECATED_FOR(g_value_take_boxed)
Matthias Clasen's avatar
Matthias Clasen committed
85
void     g_value_set_boxed_take_ownership (GValue        *value,
86
                                           gconstpointer  v_boxed);
87
GLIB_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
88
gpointer g_value_get_boxed                (const GValue  *value);
89
GLIB_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
90
gpointer g_value_dup_boxed                (const GValue  *value);
91 92 93


/* --- convenience --- */
94
GLIB_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
95 96 97
GType    g_boxed_type_register_static     (const gchar   *name,
                                           GBoxedCopyFunc boxed_copy,
                                           GBoxedFreeFunc boxed_free);
98

99
/* --- GObject boxed types --- */
Stefan Kost's avatar
Stefan Kost committed
100 101
/**
 * G_TYPE_CLOSURE:
Matthias Clasen's avatar
Matthias Clasen committed
102
 *
Stefan Kost's avatar
Stefan Kost committed
103 104
 * The #GType for #GClosure.
 */
Matthias Clasen's avatar
Matthias Clasen committed
105 106
#define G_TYPE_CLOSURE (g_closure_get_type ())

Stefan Kost's avatar
Stefan Kost committed
107 108
/**
 * G_TYPE_VALUE:
Matthias Clasen's avatar
Matthias Clasen committed
109
 *
Stefan Kost's avatar
Stefan Kost committed
110 111 112
 * The type ID of the "GValue" type which is a boxed type,
 * used to pass around pointers to GValues.
 */
Matthias Clasen's avatar
Matthias Clasen committed
113 114
#define G_TYPE_VALUE (g_value_get_type ())

115
GLIB_AVAILABLE_IN_ALL
116
GType   g_closure_get_type         (void) G_GNUC_CONST;
117
GLIB_AVAILABLE_IN_ALL
118
GType   g_value_get_type           (void) G_GNUC_CONST;
Emmanuele Bassi's avatar
Emmanuele Bassi committed
119

120
G_END_DECLS
121

Matthias Clasen's avatar
Matthias Clasen committed
122
#endif  /* __G_BOXED_H__ */